From d9c3f97f43515331530fabec620edef5a39026f9 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Mon, 25 Sep 2023 22:20:09 -0400 Subject: [PATCH 01/32] EventsSDK: Add Playwright Tests Add playwright tests to serve as acceptance tests for this SDK. They will run the test site and click the buttons on three browsers, Chromium, Firefox, and Webkit and check for a 202 response. They can be run with the other unit tests using npm run test, or on their own with npx playwright test. The browsers can also be viewed live as they execute by using npx playwright test --headed. J=FUS-5909 R=mtian, sawong TEST=auto Ran npm run test all pass. --- playwright.config.ts | 77 +++++++++++++++++++++++++++++++++++++ test-e2e/playwright.test.ts | 71 ++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 playwright.config.ts create mode 100644 test-e2e/playwright.test.ts diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 00000000..aff7d44a --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,77 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './test-e2e', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'line', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://127.0.0.1:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + video: 'on' + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] } + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] } + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] } + } + + /* Test against mobile viewports. */ + // { + // 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' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + webServer: { + command: 'cd test-site && npm i && npm run build && npm run serve', + port: 3030 + } +}); diff --git a/test-e2e/playwright.test.ts b/test-e2e/playwright.test.ts new file mode 100644 index 00000000..e3d40513 --- /dev/null +++ b/test-e2e/playwright.test.ts @@ -0,0 +1,71 @@ +import { test, expect } from '@playwright/test'; + +test('test Fire Chat Event on chrome, firefox, and webkit', async ({ + page +}) => { + await page.goto('http://127.0.0.1:3030'); + + await Promise.all([ + page.waitForResponse((res) => res.status() == 202), + await page.click('button:has-text("Fire Chat Event")') + ]) + .then((responses) => { + expect(responses.at(0)?.status()).toBe(202); + }) + .catch((e) => { + console.log(e); + test.fail(e); + }); +}); + +test('test Fire Search Event on chrome, firefox, and webkit', async ({ + page +}) => { + await page.goto('http://127.0.0.1:3030'); + + await Promise.all([ + page.waitForResponse((res) => res.status() == 202), + await page.click('button:has-text("Fire Search Event")') + ]) + .then((responses) => { + expect(responses.at(0)?.status()).toBe(202); + }) + .catch((e) => { + console.log(e); + test.fail(e); + }); +}); + +test('test Fire CTA Event on chrome, firefox, and webkit', async ({ page }) => { + await page.goto('http://127.0.0.1:3030'); + + await Promise.all([ + page.waitForResponse((res) => res.status() == 202), + await page.click('button:has-text("Fire CTA Event")') + ]) + .then((responses) => { + expect(responses.at(0)?.status()).toBe(202); + }) + .catch((e) => { + console.log(e); + test.fail(e); + }); +}); + +test('test Fire Event w/ Session Tracking on chrome, firefox, and webkit', async ({ + page +}) => { + await page.goto('http://127.0.0.1:3030'); + + await Promise.all([ + page.waitForResponse((res) => res.status() == 202), + await page.click('button:has-text("Fire Event w/ Session Tracking")') + ]) + .then((responses) => { + expect(responses.at(0)?.status()).toBe(202); + }) + .catch((e) => { + console.log(e); + test.fail(e); + }); +}); From 44353def16b55c4708ac80b4029b7b4982462387 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 15:47:56 -0400 Subject: [PATCH 02/32] fix typo --- playwright.config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/playwright.config.ts b/playwright.config.ts index ab085e62..aff7d44a 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -74,5 +74,4 @@ export default defineConfig({ command: 'cd test-site && npm i && npm run build && npm run serve', port: 3030 } -] }); From 152e15af88cebd35ceef0dbd0cc7d00abec90b79 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 15:59:41 -0400 Subject: [PATCH 03/32] revise build chain --- .github/workflows/playwright.yml | 4 ++++ playwright.config.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 0d337c5d..d53b91d0 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -11,8 +11,12 @@ jobs: node-version: 18 - name: Install dependencies run: npm ci + - name: Install test site dependencies + run: npm i --prefix ./test-site - name: Install Playwright Browsers run: npx playwright install --with-deps + - name: Build and start test site + run: npm run build --prefix ./test-site - name: Run Playwright tests run: npx playwright test - uses: actions/upload-artifact@v3 diff --git a/playwright.config.ts b/playwright.config.ts index aff7d44a..48a7bd42 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -71,7 +71,7 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: 'cd test-site && npm i && npm run build && npm run serve', + command: 'npm run serve --prefix ./test-site', port: 3030 } }); From 6c15342baea5a70408d7648b7815f3ff791dba72 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 16:04:56 -0400 Subject: [PATCH 04/32] update yaml --- .github/workflows/playwright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index d53b91d0..be71ba4d 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -11,6 +11,8 @@ jobs: node-version: 18 - name: Install dependencies run: npm ci + - name: build main package + run: npm run build - name: Install test site dependencies run: npm i --prefix ./test-site - name: Install Playwright Browsers From 2266985ad0db2c0803f09be0acde2fd0cb7ceb83 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 16:15:06 -0400 Subject: [PATCH 05/32] increase timeout --- playwright.config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/playwright.config.ts b/playwright.config.ts index 48a7bd42..14229b4e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -73,5 +73,6 @@ export default defineConfig({ webServer: { command: 'npm run serve --prefix ./test-site', port: 3030 - } + }, + timeout: 60000 }); From 7335c86a1455f5c958b2985b2eda5586fb57aa8a Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 16:45:02 -0400 Subject: [PATCH 06/32] increase timeout --- playwright.config.ts | 3 ++- test-e2e/example.spec.ts | 20 -------------------- 2 files changed, 2 insertions(+), 21 deletions(-) delete mode 100644 test-e2e/example.spec.ts diff --git a/playwright.config.ts b/playwright.config.ts index 14229b4e..1f1e296c 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -72,7 +72,8 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { command: 'npm run serve --prefix ./test-site', - port: 3030 + port: 3030, + timeout: 60000 }, timeout: 60000 }); diff --git a/test-e2e/example.spec.ts b/test-e2e/example.spec.ts deleted file mode 100644 index 7c90d85c..00000000 --- a/test-e2e/example.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/); -}); - -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click(); - - // Expects page to have a heading with the name of Installation. - await expect( - page.getByRole('heading', { name: 'Installation' }) - ).toBeVisible(); -}); From 1637a16b9551a6aa13c639cffae43903d63041ec Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 16:51:59 -0400 Subject: [PATCH 07/32] add more workers, start server in action --- .github/workflows/playwright.yml | 4 +++- playwright.config.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index be71ba4d..53f9934b 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -17,8 +17,10 @@ jobs: run: npm i --prefix ./test-site - name: Install Playwright Browsers run: npx playwright install --with-deps - - name: Build and start test site + - name: Build test site run: npm run build --prefix ./test-site + - name: RUn test site + run: npm run start --prefix ./test-site - name: Run Playwright tests run: npx playwright test - uses: actions/upload-artifact@v3 diff --git a/playwright.config.ts b/playwright.config.ts index 1f1e296c..5c6f8703 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -18,7 +18,7 @@ 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: 5, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: 'line', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ From 5de98a65f458156ad4fb4c1947d18b97ea6f29c6 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 17:37:10 -0400 Subject: [PATCH 08/32] start -> serve --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 53f9934b..9c89ac6c 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -20,7 +20,7 @@ jobs: - name: Build test site run: npm run build --prefix ./test-site - name: RUn test site - run: npm run start --prefix ./test-site + run: npm run serve --prefix ./test-site - name: Run Playwright tests run: npx playwright test - uses: actions/upload-artifact@v3 From 87201fefc06f779ee57155fdb0ec7e05738a4585 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 17:44:51 -0400 Subject: [PATCH 09/32] remove serve from action --- .github/workflows/playwright.yml | 2 -- playwright.config.ts | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 9c89ac6c..abfda4f2 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -19,8 +19,6 @@ jobs: run: npx playwright install --with-deps - name: Build test site run: npm run build --prefix ./test-site - - name: RUn test site - run: npm run serve --prefix ./test-site - name: Run Playwright tests run: npx playwright test - uses: actions/upload-artifact@v3 diff --git a/playwright.config.ts b/playwright.config.ts index 5c6f8703..6528fcf6 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -72,8 +72,6 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { command: 'npm run serve --prefix ./test-site', - port: 3030, - timeout: 60000 - }, - timeout: 60000 + port: 3030 + } }); From 5869cc56b6cc9ba1bc27b93e243876c96e7d0d34 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 17:55:10 -0400 Subject: [PATCH 10/32] remove await --- test-e2e/playwright.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test-e2e/playwright.test.ts b/test-e2e/playwright.test.ts index e3d40513..d3bdb1ce 100644 --- a/test-e2e/playwright.test.ts +++ b/test-e2e/playwright.test.ts @@ -25,7 +25,7 @@ test('test Fire Search Event on chrome, firefox, and webkit', async ({ await Promise.all([ page.waitForResponse((res) => res.status() == 202), - await page.click('button:has-text("Fire Search Event")') + page.click('button:has-text("Fire Search Event")') ]) .then((responses) => { expect(responses.at(0)?.status()).toBe(202); @@ -41,7 +41,7 @@ test('test Fire CTA Event on chrome, firefox, and webkit', async ({ page }) => { await Promise.all([ page.waitForResponse((res) => res.status() == 202), - await page.click('button:has-text("Fire CTA Event")') + page.click('button:has-text("Fire CTA Event")') ]) .then((responses) => { expect(responses.at(0)?.status()).toBe(202); @@ -59,7 +59,7 @@ test('test Fire Event w/ Session Tracking on chrome, firefox, and webkit', async await Promise.all([ page.waitForResponse((res) => res.status() == 202), - await page.click('button:has-text("Fire Event w/ Session Tracking")') + page.click('button:has-text("Fire Event w/ Session Tracking")') ]) .then((responses) => { expect(responses.at(0)?.status()).toBe(202); From 457b5bb4cf39c79089646b8d453edb31ab3b1d6c Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 21:17:40 -0400 Subject: [PATCH 11/32] add secrets in workflow --- .github/workflows/playwright.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index abfda4f2..6409f2dd 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -18,12 +18,8 @@ jobs: - name: Install Playwright Browsers run: npx playwright install --with-deps - name: Build test site + env: + YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} run: npm run build --prefix ./test-site - name: Run Playwright tests run: npx playwright test - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 From 7437eb4934d5835f466db8765910680737ed8bae Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 21:25:05 -0400 Subject: [PATCH 12/32] secrets -> env --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 6409f2dd..ae18a679 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -19,7 +19,7 @@ jobs: run: npx playwright install --with-deps - name: Build test site env: - YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} + YEXT_API_KEY: ${{ env.YEXT_API_KEY }} run: npm run build --prefix ./test-site - name: Run Playwright tests run: npx playwright test From 6245c86112994feffba0b1c985578b556b9e5995 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 21:30:12 -0400 Subject: [PATCH 13/32] fix action --- .github/workflows/playwright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ae18a679..456d460e 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -21,5 +21,7 @@ jobs: env: YEXT_API_KEY: ${{ env.YEXT_API_KEY }} run: npm run build --prefix ./test-site + - name: Start dev server + run: npm run serve --prefix ./test-site - name: Run Playwright tests run: npx playwright test From bda6eb7d3e9a8530e85137d9024f0b907f91ca3f Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 21:49:18 -0400 Subject: [PATCH 14/32] try & --- playwright.config.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 6528fcf6..ac257e54 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -71,7 +71,8 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: 'npm run serve --prefix ./test-site', - port: 3030 + command: 'npm run serve --prefix ./test-site &', + port: 3030, + reuseExistingServer: true } }); From 1c66d5300ab5175153989fb2825e9bcc6ea98817 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 21:55:12 -0400 Subject: [PATCH 15/32] add workflow --- .github/workflows/playwright.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 456d460e..ae18a679 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -21,7 +21,5 @@ jobs: env: YEXT_API_KEY: ${{ env.YEXT_API_KEY }} run: npm run build --prefix ./test-site - - name: Start dev server - run: npm run serve --prefix ./test-site - name: Run Playwright tests run: npx playwright test From 66cf92b9a0620f8f27e7ba1dc1c443df546717d9 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 21:58:13 -0400 Subject: [PATCH 16/32] undo --- .github/workflows/playwright.yml | 2 ++ playwright.config.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ae18a679..aeb40e93 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -21,5 +21,7 @@ jobs: env: YEXT_API_KEY: ${{ env.YEXT_API_KEY }} run: npm run build --prefix ./test-site + - name: Start dev server + run: npm run serve --prefix ./test-site & - name: Run Playwright tests run: npx playwright test diff --git a/playwright.config.ts b/playwright.config.ts index ac257e54..d6f6c118 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -71,7 +71,7 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: 'npm run serve --prefix ./test-site &', + command: 'npm run serve --prefix ./test-site', port: 3030, reuseExistingServer: true } From e506b38caf40caa06d635665f1d0283d896a41c7 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 22:05:24 -0400 Subject: [PATCH 17/32] try diff config --- playwright.config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index d6f6c118..57d28762 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -24,7 +24,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', + baseURL: 'http://127.0.0.1:3000', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', @@ -72,7 +72,7 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { command: 'npm run serve --prefix ./test-site', - port: 3030, - reuseExistingServer: true + reuseExistingServer: true, + url: 'http://localhost:3030/' } }); From bf1712f505ffe5b4e40feaf5b2dbf8e81858df2e Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 22:16:11 -0400 Subject: [PATCH 18/32] use secrets instead of env --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index aeb40e93..62520229 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -19,7 +19,7 @@ jobs: run: npx playwright install --with-deps - name: Build test site env: - YEXT_API_KEY: ${{ env.YEXT_API_KEY }} + YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} run: npm run build --prefix ./test-site - name: Start dev server run: npm run serve --prefix ./test-site & From fa70ead96cbe7399d41839b62375cb127bfc550b Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 22:22:39 -0400 Subject: [PATCH 19/32] fix commands --- .github/workflows/playwright.yml | 8 ++------ playwright.config.ts | 3 ++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 62520229..19642c35 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -4,6 +4,8 @@ jobs: test: timeout-minutes: 5 runs-on: ubuntu-latest + env: + YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 @@ -17,11 +19,5 @@ jobs: run: npm i --prefix ./test-site - name: Install Playwright Browsers run: npx playwright install --with-deps - - name: Build test site - env: - YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} - run: npm run build --prefix ./test-site - - name: Start dev server - run: npm run serve --prefix ./test-site & - name: Run Playwright tests run: npx playwright test diff --git a/playwright.config.ts b/playwright.config.ts index 57d28762..8986e3d0 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -71,7 +71,8 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: 'npm run serve --prefix ./test-site', + command: + 'npm run build --prefix ./test-site && npm run serve --prefix ./test-site', reuseExistingServer: true, url: 'http://localhost:3030/' } From afa4cb5e4bed53cd260bff35a3b6f85f4fac311a Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 22:29:57 -0400 Subject: [PATCH 20/32] try this --- playwright.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 8986e3d0..eaeedd0f 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -24,7 +24,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: 'http://127.0.0.1:3000', + baseURL: 'http://localhost:3000', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', @@ -74,6 +74,6 @@ export default defineConfig({ command: 'npm run build --prefix ./test-site && npm run serve --prefix ./test-site', reuseExistingServer: true, - url: 'http://localhost:3030/' + port: 3030 } }); From 1ca721cc8f69f326e9162fcf87e4bae3aeedc84a Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Tue, 26 Sep 2023 22:35:57 -0400 Subject: [PATCH 21/32] 3030 --- playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright.config.ts b/playwright.config.ts index eaeedd0f..1675ee94 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -24,7 +24,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: 'http://localhost:3000', + baseURL: 'http://localhost:3030', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', From 7d51da505b01d8e36f88ecdab5c2ae23c4fd92ee Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 11:18:46 -0400 Subject: [PATCH 22/32] try this --- .github/workflows/playwright.yml | 6 ++++-- playwright.config.ts | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 19642c35..b06a5a32 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -4,8 +4,6 @@ jobs: test: timeout-minutes: 5 runs-on: ubuntu-latest - env: - YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 @@ -19,5 +17,9 @@ jobs: run: npm i --prefix ./test-site - name: Install Playwright Browsers run: npx playwright install --with-deps + - name: Build test site + env: + YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} + run: npm run build --prefix ./test-site & - name: Run Playwright tests run: npx playwright test diff --git a/playwright.config.ts b/playwright.config.ts index 1675ee94..3e9b46bc 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -71,9 +71,8 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: - 'npm run build --prefix ./test-site && npm run serve --prefix ./test-site', + command: 'npm run serve --prefix ./test-site', reuseExistingServer: true, - port: 3030 + url: 'http://localhost:3030' } }); From f1d1e17f81f45590bc40ea03803c78cf5259668d Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 11:29:16 -0400 Subject: [PATCH 23/32] print env var --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index b06a5a32..65c440c2 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -20,6 +20,6 @@ jobs: - name: Build test site env: YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} - run: npm run build --prefix ./test-site & + run: echo "key:$YEXT_API_KEY" && npm run build --prefix ./test-site & - name: Run Playwright tests run: npx playwright test From 78e9c75b5a913c0f8b4da174e0d8e994de43fcc2 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 11:37:53 -0400 Subject: [PATCH 24/32] reformat --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 65c440c2..92db0f69 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -5,7 +5,7 @@ jobs: timeout-minutes: 5 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3di - uses: actions/setup-node@v3 with: node-version: 18 @@ -20,6 +20,6 @@ jobs: - name: Build test site env: YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} - run: echo "key:$YEXT_API_KEY" && npm run build --prefix ./test-site & + run: echo 'Key:' '${{ env.YEXT_API_KEY }}' && npm run build --prefix ./test-site & - name: Run Playwright tests run: npx playwright test From c364d39f3ff871a56da2b6d57661edaccb4c8168 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 11:39:47 -0400 Subject: [PATCH 25/32] fix typo --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 92db0f69..a7007366 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -5,7 +5,7 @@ jobs: timeout-minutes: 5 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3di + - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 18 From 0855aa54260e4110c4d16b237353085a1a9b3f71 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 11:46:46 -0400 Subject: [PATCH 26/32] set env at highter level --- .github/workflows/playwright.yml | 10 ++++++++-- playwright.config.ts | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index a7007366..5e1daa27 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,10 +1,18 @@ name: Playwright Tests on: [push, pull_request] + +env: + YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} + jobs: test: timeout-minutes: 5 runs-on: ubuntu-latest steps: + - if: ${{ env.YEXT_API_KEY == ''}} + run: | + echo "YEXT_API_KEY is not set" + exit 1 - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: @@ -18,8 +26,6 @@ jobs: - name: Install Playwright Browsers run: npx playwright install --with-deps - name: Build test site - env: - YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} run: echo 'Key:' '${{ env.YEXT_API_KEY }}' && npm run build --prefix ./test-site & - name: Run Playwright tests run: npx playwright test diff --git a/playwright.config.ts b/playwright.config.ts index 3e9b46bc..14961f3f 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -71,8 +71,8 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: 'npm run serve --prefix ./test-site', + command: 'cd test-site && yarn dev', reuseExistingServer: true, - url: 'http://localhost:3030' + port: 3030 } }); From e03cacd54d1e0d10c1d558339c13e8ee01228019 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 11:53:26 -0400 Subject: [PATCH 27/32] set env at highter level --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 5e1daa27..6d16f836 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -2,7 +2,7 @@ name: Playwright Tests on: [push, pull_request] env: - YEXT_API_KEY: ${{ secrets.YEXT_API_KEY }} + YEXT_API_KEY: ${{ secrets.GCP_SA_KEY }} jobs: test: From 93135f3d79e5b7cafcef4f9c82a9ce813a1eae92 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 12:12:58 -0400 Subject: [PATCH 28/32] modify config --- playwright.config.ts | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 14961f3f..76bd3d25 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -18,17 +18,14 @@ export default defineConfig({ /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Opt out of parallel tests on CI. */ - workers: 5, + workers: 4, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'line', + reporter: process.env.CI ? 'dot' : 'list', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { - /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: 'http://localhost:3030', - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry', - video: 'on' + trace: process.env.CI ? 'off' : 'on-first-retry', + video: process.env.CI ? 'off' : 'on' }, /* Configure projects for major browsers */ @@ -47,32 +44,12 @@ export default defineConfig({ name: 'webkit', use: { ...devices['Desktop Safari'] } } - - /* Test against mobile viewports. */ - // { - // 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' }, - // }, ], /* Run your local dev server before starting the tests */ webServer: { - command: 'cd test-site && yarn dev', - reuseExistingServer: true, - port: 3030 + command: 'npm run serve --prefix ./test-site', + port: 3030, + reuseExistingServer: true } }); From 371ff6efd6df43d78e8f3d730a0ce39fa1f87c45 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 12:16:32 -0400 Subject: [PATCH 29/32] start server in action --- .github/workflows/playwright.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 6d16f836..df238826 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -9,10 +9,6 @@ jobs: timeout-minutes: 5 runs-on: ubuntu-latest steps: - - if: ${{ env.YEXT_API_KEY == ''}} - run: | - echo "YEXT_API_KEY is not set" - exit 1 - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: @@ -26,6 +22,8 @@ jobs: - name: Install Playwright Browsers run: npx playwright install --with-deps - name: Build test site - run: echo 'Key:' '${{ env.YEXT_API_KEY }}' && npm run build --prefix ./test-site & + run: npm run build --prefix ./test-site + - name: Start test site + run: npm run start --prefix ./test-site & - name: Run Playwright tests run: npx playwright test From bd0dc9f13baf21ec716ad2b9c8b07c8115587396 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 12:19:15 -0400 Subject: [PATCH 30/32] serve not start --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index df238826..b85ac331 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -24,6 +24,6 @@ jobs: - name: Build test site run: npm run build --prefix ./test-site - name: Start test site - run: npm run start --prefix ./test-site & + run: npm run serve --prefix ./test-site & - name: Run Playwright tests run: npx playwright test From 53a5c1e8a764cb03aa39ccadeb8f6a8302db5d8d Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 12:26:50 -0400 Subject: [PATCH 31/32] try macOs --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index b85ac331..1233c198 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -7,7 +7,7 @@ env: jobs: test: timeout-minutes: 5 - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 From 104664c620d485f8a933bca7dada0a4b3a564440 Mon Sep 17 00:00:00 2001 From: Ethan Jaffee Date: Wed, 27 Sep 2023 12:27:39 -0400 Subject: [PATCH 32/32] try no & --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 1233c198..7b745270 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -7,7 +7,7 @@ env: jobs: test: timeout-minutes: 5 - runs-on: macos-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 @@ -24,6 +24,6 @@ jobs: - name: Build test site run: npm run build --prefix ./test-site - name: Start test site - run: npm run serve --prefix ./test-site & + run: npm run serve --prefix ./test-site - name: Run Playwright tests run: npx playwright test