Skip to content

Commit

Permalink
Merge f20bfe5 into e9f7879
Browse files Browse the repository at this point in the history
  • Loading branch information
ejaffee01 committed Sep 27, 2023
2 parents e9f7879 + f20bfe5 commit 4abd696
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 66 deletions.
Binary file added .DS_Store
Binary file not shown.
21 changes: 11 additions & 10 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
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: 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 playwright.test.ts -g "test\s+Fire\s+Search\s+Event\s+on\s+Chromium,\s+Firefox,\s+and\s+Webkit$"

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dist/
docs/
etc/
lib/
test-e2e/
node_modules/
package*.json
LICENSE
Expand Down
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
53 changes: 18 additions & 35 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,60 +19,42 @@ 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 */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] }
use: { ...devices['Desktop Chrome'], headless: true }
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] }
use: { ...devices['Desktop Firefox'], headless: true }
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] }
use: { ...devices['Desktop Safari'], headless: true }
}

/* 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.

84 changes: 84 additions & 0 deletions test-e2e/playwright.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { test, expect } from '@playwright/test';

test('test Fire Chat Event on Chromium, Firefox, and Webkit', async ({
page
}) => {
await Promise.all([
page.waitForResponse((res) => res.status() != 202),
page.click('button:has-text("Fire Chat Event")')
])
.then((responses) => {
console.log(responses.at(0));
console.log(responses.at(0)?.status());
console.log(responses.at(0)?.statusText());
console.log(responses.at(0)?.ok());

console.log(responses.at(1));
console.log(responses.at(1)?.status());
console.log(responses.at(1)?.statusText());
console.log(responses.at(1)?.ok());
expect(responses.at(0)?.status()).toBe(202);
})
.catch((e) => {
console.log(e);
console.log(e.status());
console.log(e.statusText());
console.log(e.message());
console.log(e.name());
test.fail(e);
});
});

test('test Fire Search Event on Chromium, 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 Chromium, 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 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 Chromium, 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 4abd696

Please sign in to comment.