feat(visual-regression): protótipo testes visuais Playwright#2764
feat(visual-regression): protótipo testes visuais Playwright#2764alinelariguet wants to merge 1 commit into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
313ae15 to
42ebf80
Compare
| test('basic', async ({ page }) => { | ||
| await page.goto('/visual/po-button-group-basic'); | ||
| await page.waitForSelector('po-button-group'); | ||
| await expect(page.locator('po-button-group')).toHaveScreenshot('po-button-group-basic.png'); |
There was a problem hiding this comment.
🟡 po-button-group visual test uses wrong locator for screenshot, inconsistent with all other tests
All 10 other visual test specs use the sample wrapper selector (sample-po-<component>-basic) as the locator for toHaveScreenshot, but po-button-group.visual.spec.ts uses the inner component selector po-button-group instead of the expected sample-po-button-group-basic. This means the screenshot captures only the inner <po-button-group> element rather than the full routed sample component host element. Compare with e.g. e2e/visual/po-button.visual.spec.ts:7 which correctly uses page.locator('sample-po-button-basic').
| await expect(page.locator('po-button-group')).toHaveScreenshot('po-button-group-basic.png'); | |
| await expect(page.locator('sample-po-button-group-basic')).toHaveScreenshot('po-button-group-basic.png'); |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Good catch — this was intentional. The sample-po-button-group-basic host element had zero dimensions when I tested, so using it as the locator for toHaveScreenshot produced an empty screenshot. That's why I fell back to po-button-group directly. This is already noted in the PR description under "Review & Testing Checklist" as something to verify.
If the sample wrapper renders correctly in another environment, we can switch to sample-po-button-group-basic for consistency.
9f2f50d to
80b9274
Compare
feat(visual-regression): protótipo testes visuais Playwright
Summary
Adds a visual regression testing prototype using Playwright against the existing sample components in
po-angular. The setup uses a dedicatedvisual-appAngular project (registered inangular.json, rooted ate2e/visual/), completely separate fromprojects/app/(which remains untouched for internal behavior validation). Playwright captures screenshots and compares them pixel-by-pixel against committed baselines.Architecture:
visual-app— standalone Angular project inangular.jsonwith root ate2e/visual/, its owntsconfig.visual.json(with@po-ui/ng-componentspath mappings to UI source), bootstrap files ine2e/visual/app/e2e/visual/containing spec files, and baselines are organized per-component undere2e/visual/__snapshots__/<component>/projects/app/is not modified — reverted to original master stateFolder structure:
What's included:
playwright.config.ts— Chromium-only, auto-startsng serve visual-app,maxDiffPixelRatio: 0.01, animations disabledpo-input-statesdeep-dive — a dedicatedVisualTestPoInputStatesComponentthat renderspo-inputin 13 distinct property combinations, each with its own Playwright test and baseline snapshot:e2e/visual/__snapshots__/organized per componenttest:visual,test:visual:update,test:visual:reportDemo — regression detection working:
Updates since last revision
visual-appAngular project inangular.json(root ate2e/visual/) — no longer usesprojects/app/projects/app/to original master state (no visual test code remains there)e2e/visual/with co-localized folder structure: each component gets its own folder containing spec + component files + baselinesplaywright.config.tsto servevisual-appinstead ofappp-labelon loading/loading+helper states (removed — those states should not have labels)p-required-field-error-messagebinding — changed from bare attribute to[p-required-field-error-message]="true"(bare attribute evaluates to empty string, preventing error message display)p-show-requiredbinding — changed from bare attribute to[p-show-required]="true"(bare attribute evaluates to empty string, preventing required indicator asterisk)Review & Testing Checklist for Human
npx playwright install chromiumthennpm run test:visualon your machine — baselines will mismatch on Windows. Regenerate withnpm run test:visual:update. Decide whether baselines should be committed or generated in CI only.npx playwright install chromiumthennpm run test:visual— all 24 tests should pass. Try modifying a component's template/style and confirm the test fails with a visual diff. Verify the HTML report shows clear before/after comparison.state-loadingandstate-loading-helper(should have no label), andstate-requiredandstate-required-error(should show asterisk and error message respectively). Compare with the previous broken versions if possible.visual-appproject: Verify that registering the newvisual-appproject inangular.jsondoesn't interfere with existing builds or CI workflows. Trynpm run build:ui:liteand other standard build commands to ensure no regressions.tsconfig.visual.jsonpaths resolution: The paths use relative references like./projects/ui/src/public-apifrome2e/visual/tsconfig.visual.json. Verify that these resolve correctly when building/servingvisual-app.e2e/visual/app/app.module.tsimports sample components using paths like../../../projects/ui/src/lib/components/po-button/samples/.... These are fragile if folder structure changes. Verify they work correctly.po-button-grouplocator inconsistency: This test usespage.locator('po-button-group')instead ofpage.locator('sample-po-button-group-basic')like all other tests. Verify this is acceptable or investigate the root cause.Notes
webServerconfig inplaywright.config.tshandles local dev automatically. Visual tests do not run in CI yet.npx playwright install chromiumbefore running tests. On Windows, baselines will need regeneration withnpm run test:visual:update.