Skip to content

Commit

Permalink
Merge 41f326d into e9f7879
Browse files Browse the repository at this point in the history
  • Loading branch information
ejaffee01 committed Sep 27, 2023
2 parents e9f7879 + 41f326d commit 497ffbe
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 63 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
name: Playwright Tests
on: [push, pull_request]

env:
YEXT_API_KEY: ${{ secrets.GCP_SA_KEY }}

jobs:
test:
timeout-minutes: 5
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.38.0-jammy
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
run: npm ci && npm i --prefix ./test-site
- name: build package
run: npm run build
- name: Start server
run: npm run serve --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
run: DEBUG=pw:api npx playwright test

69 changes: 69 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"generate-notices": "generate-license-file --input package.json --output THIRD-PARTY-NOTICES --overwrite"
},
"devDependencies": {
"@actions/core": "^1.10.1",
"@babel/preset-env": "^7.14.7",
"@babel/preset-typescript": "^7.14.5",
"@microsoft/api-documenter": "^7.15.3",
Expand Down
47 changes: 15 additions & 32 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable indent */
import { defineConfig, devices } from '@playwright/test';

/**
Expand All @@ -18,16 +19,15 @@ 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: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
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://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry'
trace: process.env.CI ? 'off' : 'on-first-retry',
video: process.env.CI ? 'off' : 'on',
baseURL: 'http://localhost:3000'
},

/* Configure projects for major browsers */
Expand All @@ -46,32 +46,15 @@ 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: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
webServer: {
command: 'npm run build && npm run serve',
cwd: './test-site',
url: 'http://localhost:3000/',
reuseExistingServer: true,
stderr: 'pipe',
stdout: 'pipe'
}
});
20 changes: 0 additions & 20 deletions test-e2e/example.spec.ts

This file was deleted.

71 changes: 71 additions & 0 deletions test-e2e/playwright.test.ts
Original file line number Diff line number Diff line change
@@ -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://localhost:3000');

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://localhost:3000');

await Promise.all([
page.waitForResponse((res) => res.status() == 202),
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://localhost:3000');

await Promise.all([
page.waitForResponse((res) => res.status() == 202),
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://localhost:3000');

await Promise.all([
page.waitForResponse((res) => res.status() == 202),
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);
});
});
2 changes: 1 addition & 1 deletion test-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"dev": "webpack --watch",
"serve": "serve dist -p 3030"
"serve": "serve dist -p 3000"
},
"author": "slapshot@yext.com",
"devDependencies": {
Expand Down

0 comments on commit 497ffbe

Please sign in to comment.