From 5f38e4757a759d4bcc432ed235f07f3d33abbbdd Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 22 Jul 2024 11:30:40 -0400 Subject: [PATCH 1/3] run tests for mobile as well as desktop, use parallel in all environments --- playwright.config.ts | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 4a501ea..d441ffd 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -19,7 +19,8 @@ export default defineConfig({ /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Opt out of parallel tests on CI. */ - workers: process.env.CI ? 1 : undefined, + // workers: process.env.CI ? 1 : undefined, + workers: undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ @@ -49,24 +50,24 @@ export default defineConfig({ }, /* Test against mobile viewports. */ - // { - // name: 'Mobile Chrome', - // use: { ...devices['Pixel 5'] }, - // }, - // { - // name: 'Mobile Safari', - // use: { ...devices['iPhone 12'] }, - // }, + { + name: 'Mobile Chrome', + use: { ...devices['Pixel 5'] }, + }, + { + name: 'Mobile Safari', + use: { ...devices['iPhone 12'] }, + }, /* Test against branded browsers. */ - // { - // name: 'Microsoft Edge', - // use: { ...devices['Desktop Edge'], channel: 'msedge' }, - // }, - // { - // name: 'Google Chrome', - // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, - // }, + { + name: 'Microsoft Edge', + use: { ...devices['Desktop Edge'], channel: 'msedge' }, + }, + { + name: 'Google Chrome', + use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + }, ], /* Run your local dev server before starting the tests */ From 21536a6f0422aed3c574ab8973adc12cd47acee9 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 22 Jul 2024 14:13:27 -0400 Subject: [PATCH 2/3] minor test restructuring, run base then mask then full component tests --- playwright.config.ts | 16 ++++++++++++++++ tests/base.spec.ts | 22 ++++++++++++++++++++++ tests/test.spec.ts | 16 ---------------- 3 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 tests/base.spec.ts diff --git a/playwright.config.ts b/playwright.config.ts index d441ffd..6a45cf2 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -34,39 +34,55 @@ export default defineConfig({ /* Configure projects for major browsers */ projects: [ + { + name: 'base tests', + testMatch: '**/base.spec.ts', + }, + { + name: 'mask tests', + testMatch: '**/mask.spec.ts', + dependencies: ['base tests'], + }, { name: 'chromium', use: { ...devices['Desktop Chrome'] }, + dependencies: ['base tests', 'mask tests'], }, { name: 'firefox', use: { ...devices['Desktop Firefox'] }, + dependencies: ['base tests', 'mask tests'], }, { name: 'webkit', use: { ...devices['Desktop Safari'] }, + dependencies: ['base tests', 'mask tests'], }, /* Test against mobile viewports. */ { name: 'Mobile Chrome', use: { ...devices['Pixel 5'] }, + dependencies: ['base tests', 'mask tests'], }, { name: 'Mobile Safari', use: { ...devices['iPhone 12'] }, + dependencies: ['base tests', 'mask tests'], }, /* Test against branded browsers. */ { name: 'Microsoft Edge', use: { ...devices['Desktop Edge'], channel: 'msedge' }, + dependencies: ['base tests', 'mask tests'], }, { name: 'Google Chrome', use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + dependencies: ['base tests', 'mask tests'], }, ], diff --git a/tests/base.spec.ts b/tests/base.spec.ts new file mode 100644 index 0000000..b1a3896 --- /dev/null +++ b/tests/base.spec.ts @@ -0,0 +1,22 @@ +import { test, expect } from '@playwright/test'; +import * as path from 'path'; + +const projectDir = path.resolve(__dirname, '../'); +const filePath = path.join(projectDir, 'examples/index.html'); +const fileUrl = `file://${filePath}`; + +test.describe('base tests', () => { + test.beforeEach(async ({ page }) => { + await page.goto(fileUrl); + }); + + test('sanity startup', async ({ page }) => { + const currencyInput = await page.locator('#currency-input'); + await expect(currencyInput).toHaveValue('$0.00 USD'); + }); + + test('undefined value results in correct 0 of input', async ({ page }) => { + const nullInputTest = await page.locator('#null-input-test'); + await expect(nullInputTest).toHaveValue('$0.00 USD'); + }); +}); diff --git a/tests/test.spec.ts b/tests/test.spec.ts index c3f779f..f6499a3 100644 --- a/tests/test.spec.ts +++ b/tests/test.spec.ts @@ -5,22 +5,6 @@ const projectDir = path.resolve(__dirname, '../'); const filePath = path.join(projectDir, 'examples/index.html'); const fileUrl = `file://${filePath}`; -test.describe('test', () => { - test.beforeEach(async ({ page }) => { - await page.goto(fileUrl); - }); - - test('sanity startup', async ({ page }) => { - const currencyInput = await page.locator('#currency-input'); - await expect(currencyInput).toHaveValue('$0.00 USD'); - }); - - test('undefined value results in correct 0 of input', async ({ page }) => { - const nullInputTest = await page.locator('#null-input-test'); - await expect(nullInputTest).toHaveValue('$0.00 USD'); - }); -}); - test.describe('input caret selection', () => { const suffix = ' USD'; const prefix = '$'; From fa196a33fc3cb99dab54c72e489d23fca218e17d Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 22 Jul 2024 14:14:58 -0400 Subject: [PATCH 3/3] test.spec.ts => caret-selection.spec.ts --- tests/base.spec.ts | 2 ++ tests/{test.spec.ts => caret-selection.spec.ts} | 0 2 files changed, 2 insertions(+) rename tests/{test.spec.ts => caret-selection.spec.ts} (100%) diff --git a/tests/base.spec.ts b/tests/base.spec.ts index b1a3896..875c8d2 100644 --- a/tests/base.spec.ts +++ b/tests/base.spec.ts @@ -20,3 +20,5 @@ test.describe('base tests', () => { await expect(nullInputTest).toHaveValue('$0.00 USD'); }); }); + +// TODO: add tests for each of the possible parameters diff --git a/tests/test.spec.ts b/tests/caret-selection.spec.ts similarity index 100% rename from tests/test.spec.ts rename to tests/caret-selection.spec.ts