bito-code-review[bot] commented on code in PR #37494: URL: https://github.com/apache/superset/pull/37494#discussion_r2732950667
########## superset-frontend/playwright/tests/experimental/docs/docs-screenshots.spec.ts: ########## @@ -0,0 +1,163 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Documentation Screenshot Tests + * + * Captures screenshots for the Superset documentation site. + * Depends on example data loaded via `superset load_examples` in CI. + * + * Run with: INCLUDE_EXPERIMENTAL=true npx playwright test experimental/docs/ + * + * Screenshots are saved to docs/static/img/screenshots/ for use in + * the README and documentation site. + */ + +import path from 'path'; +import { test, expect } from '@playwright/test'; +import { URL } from '../../../utils/urls'; + +const SCREENSHOTS_DIR = path.resolve( + __dirname, + '../../../../../docs/static/img/screenshots', +); + +test('chart gallery screenshot', async ({ page }) => { + await page.goto(URL.CHART_ADD); + + // Wait for chart creation page to load + await expect(page.getByText('Choose chart type')).toBeVisible({ + timeout: 15000, + }); + await page.getByRole('tab', { name: 'All charts' }).click(); + + // Wait for viz gallery to render chart type thumbnails + const vizGallery = page.locator('.viz-gallery'); + await expect(vizGallery).toBeVisible(); + await expect( + vizGallery.locator('[data-test="viztype-selector-container"]').first(), + ).toBeVisible(); + + await page.addStyleTag({ content: 'body { zoom: 0.8 }' }); + await vizGallery.screenshot({ + path: path.join(SCREENSHOTS_DIR, 'gallery.jpg'), + type: 'jpeg', + }); +}); + +test('dashboard screenshot', async ({ page }) => { + // Navigate to the World Bank dashboard via its slug (reliable example data) + await page.goto('superset/dashboard/world_health/'); + + // Wait for dashboard to fully render + const dashboardWrapper = page.locator( + '[data-test="dashboard-content-wrapper"]', + ); + await expect(dashboardWrapper).toBeVisible({ timeout: 30000 }); + + // Wait for charts to load inside the dashboard + await expect( + page.locator('.dashboard-component-chart-holder').first(), + ).toBeVisible({ timeout: 15000 }); + + // Allow charts a moment to finish rendering + await page.waitForTimeout(3000); + + await page.addStyleTag({ content: 'body { zoom: 0.8 }' }); Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Deprecated API Usage</b></div> <div id="fix"> The code uses page.addStyleTag, which is not available in Playwright 1.58.0, leading to runtime errors during test execution. Official docs confirm it was removed before v1.9. </div> <details> <summary> <b>Code suggestion</b> </summary> <blockquote>Check the AI-generated fix before applying</blockquote> <div id="code"> ````suggestion await page.evaluate(() => { const style = document.createElement('style'); style.textContent = 'body { zoom: 0.8 }'; document.head.appendChild(style); }); ```` </div> </details> </div> <small><i>Code Review Run #01afcd</i></small> </div> --- Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>) - [ ] Yes, avoid them -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
