Skip to content

Commit

Permalink
Merge 104664c into e9f7879
Browse files Browse the repository at this point in the history
  • Loading branch information
ejaffee01 committed Sep 27, 2023
2 parents e9f7879 + 104664c commit e09cef5
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 58 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Playwright Tests
on: [push, pull_request]

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

jobs:
test:
timeout-minutes: 5
Expand All @@ -11,13 +15,15 @@ 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
run: npx playwright install --with-deps
- name: Build test site
run: npm run build --prefix ./test-site
- name: Start test site
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
42 changes: 10 additions & 32 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ 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: 4,
/* 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'
},

/* Configure projects for major browsers */
Expand All @@ -46,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: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
webServer: {
command: 'npm run serve --prefix ./test-site',
port: 3030,
reuseExistingServer: true
}
});
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://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),
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),
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),
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);
});
});

0 comments on commit e09cef5

Please sign in to comment.