From 17c16eba503fbae8c903672b6a80a8de2bb33e9c Mon Sep 17 00:00:00 2001 From: Michael Rogers Date: Fri, 20 May 2022 17:11:32 -0500 Subject: [PATCH] Added visual test for capturing the Save Successful Banner (#5237) Co-authored-by: John Hill --- e2e/playwright-visual.config.js | 11 +++++------ e2e/tests/visual/default.visual.spec.js | 26 ++++++++++++++++++++++++- package.json | 2 +- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/e2e/playwright-visual.config.js b/e2e/playwright-visual.config.js index 7f6df513fc..fbf2c02011 100644 --- a/e2e/playwright-visual.config.js +++ b/e2e/playwright-visual.config.js @@ -4,10 +4,10 @@ /** @type {import('@playwright/test').PlaywrightTestConfig} */ const config = { - retries: 0, - testDir: 'tests', + retries: 0, // visual tests should never retry due to snapshot comparison errors + testDir: 'tests/visual', timeout: 90 * 1000, - workers: 1, + workers: 1, // visual tests should never run in parallel due to test pollution webServer: { command: 'npm run start', port: 8080, @@ -17,7 +17,7 @@ const config = { use: { browserName: "chromium", baseURL: 'http://localhost:8080/', - headless: true, + headless: true, // this needs to remain headless to avoid visual changes due to GPU ignoreHTTPSErrors: true, screenshot: 'on', trace: 'off', @@ -25,8 +25,7 @@ const config = { }, reporter: [ ['list'], - ['junit', { outputFile: 'test-results/results.xml' }], - ['allure-playwright'] + ['junit', { outputFile: 'test-results/results.xml' }] ] }; diff --git a/e2e/tests/visual/default.visual.spec.js b/e2e/tests/visual/default.visual.spec.js index 7a870c4128..364cdb9d1d 100644 --- a/e2e/tests/visual/default.visual.spec.js +++ b/e2e/tests/visual/default.visual.spec.js @@ -47,7 +47,10 @@ test.beforeEach(async ({ context }) => { path: path.join(__dirname, '../../..', './node_modules/sinon/pkg/sinon.js') }); await context.addInitScript(() => { - window.__clock = sinon.useFakeTimers(); //Set browser clock to UNIX Epoch + window.__clock = sinon.useFakeTimers({ + now: 0, + shouldAdvanceTime: true + }); //Set browser clock to UNIX Epoch }); }); @@ -171,3 +174,24 @@ test('Visual - Sine Wave Generator Form', async ({ page }) => { await page.waitForTimeout(VISUAL_GRACE_PERIOD); await percySnapshot(page, 'removed amplitude property value'); }); + +test('Visual - Save Successful Banner', async ({ page }) => { + //Go to baseURL + await page.goto('/', { waitUntil: 'networkidle' }); + + //Click the Create button + await page.click('button:has-text("Create")'); + + //NOTE Something other than example imagery + await page.click('text=Timer'); + + // Click text=OK + await page.click('text=OK'); + await page.locator('.c-message-banner__message').hover({ trial: true }); + await percySnapshot(page, 'Banner message shown'); + + //Wait until Save Banner is gone + await page.waitForSelector('.c-message-banner__message', { state: 'detached'}); + await percySnapshot(page, 'Banner message gone'); + +}); diff --git a/package.json b/package.json index 0497345d35..9d273c729b 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "test:e2e:ci": "npx playwright test --config=e2e/playwright-ci.config.js --project=chrome smoke default condition timeConductor branding clock exampleImagery", "test:e2e:local": "npx playwright test --config=e2e/playwright-local.config.js --project=chrome", "test:e2e:updatesnapshots": "npx playwright test --config=e2e/playwright-local.config.js --project=chrome --grep @snapshot --update-snapshots", - "test:e2e:visual": "percy exec --config ./e2e/.percy.yml -- npx playwright test --config=e2e/playwright-visual.config.js default", + "test:e2e:visual": "percy exec --config ./e2e/.percy.yml -- npx playwright test --config=e2e/playwright-visual.config.js", "test:e2e:full": "npx playwright test --config=e2e/playwright-ci.config.js", "test:watch": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" karma start --no-single-run", "jsdoc": "jsdoc -c jsdoc.json -R API.md -r -d dist/docs/api",