-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dina/create-new-test-template-for-public-good
- Loading branch information
Showing
8 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Visual regression | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Visual regression | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- run: corepack enable | ||
shell: bash | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'pnpm' | ||
|
||
- run: pnpm install --frozen-lockfile | ||
shell: bash | ||
|
||
- name: Install Playwright Browsers | ||
run: pnpm playwright install --with-deps chromium | ||
|
||
- name: Start Commercial Templates | ||
run: pnpm dev & npx wait-on -v -i 1000 http://localhost:7777 | ||
|
||
- name: Run Playwright | ||
run: pnpm playwright test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { PlaywrightTestConfig } from '@playwright/test'; | ||
|
||
const config: PlaywrightTestConfig = { | ||
testMatch: 'playwright/**/*.test.ts', | ||
projects: [ | ||
{ | ||
name: 'Chrome Stable', | ||
use: { | ||
browserName: 'chromium', | ||
channel: 'chrome', | ||
}, | ||
}, | ||
], | ||
testDir: './playwright', | ||
snapshotPathTemplate: '{testDir}/reference-images/{arg}{ext}', | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
const viewport = { width: 1600, height: 1000 }; | ||
|
||
const widths = ['360', '740', '980', '1300', '100%']; | ||
|
||
test.describe('Manual Multiple visual regression testing', () => { | ||
for (const breakpoint of widths) { | ||
test(`Manual Multiple: ${breakpoint}`, async ({ page }) => { | ||
await page.setViewportSize(viewport); | ||
|
||
await page.goto( | ||
'https://guardian.github.io/commercial-templates/csr/manual-multiple/', | ||
{ | ||
waitUntil: 'networkidle', | ||
}, | ||
); | ||
|
||
const referenceTemplateLocator = page | ||
.frameLocator(`[name='width-${breakpoint}']`) | ||
.locator('html'); | ||
// check that the template is present on the page | ||
await referenceTemplateLocator.isVisible(); | ||
// scroll to it | ||
await referenceTemplateLocator.scrollIntoViewIfNeeded(); | ||
// take a reference screenshot | ||
await referenceTemplateLocator.screenshot({ | ||
path: `./playwright/reference-images/Manual-multiple-${breakpoint.replace('%', '')}.png`, | ||
}); | ||
|
||
await page.goto('http://localhost:7777/csr/manual-multiple', { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const testTemplateLocator = page | ||
.frameLocator(`[name='width-${breakpoint}']`) | ||
.locator('html'); | ||
// check that the template is present on the page | ||
await testTemplateLocator.isVisible(); | ||
// scroll to it | ||
await testTemplateLocator.scrollIntoViewIfNeeded(); | ||
// compare screenshot to reference | ||
await expect(testTemplateLocator).toHaveScreenshot( | ||
`Manual-multiple-${breakpoint.replace('%', '')}.png`, | ||
{ maxDiffPixelRatio: 0.004 }, | ||
); | ||
}); | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters