-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32af69c
commit 9fec0db
Showing
11 changed files
with
1,212 additions
and
831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
cache: yarn | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Build overboard | ||
run: yarn build | ||
|
||
- name: Run Playwright tests | ||
run: yarn test:playwright | ||
env: | ||
PLAYWRIGHT_REPLAY_API_KEY: ${{ secrets.PLAYWRIGHT_REPLAY_API_KEY }} | ||
REPLAY_PLAYWRIGHT_FIXTURE: ${{ secrets.REPLAY_PLAYWRIGHT_FIXTURE }} | ||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ node_modules | |
out | ||
packages/site/cypress/screenshots | ||
*.log | ||
.yarn | ||
.yarnrc.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { test, expect, Page } from '@playwright/test'; | ||
|
||
async function selectColor(page: Page, color: "blue" | "green" | "red") { | ||
await page.locator(`[data-cy=${color}]`).click(); | ||
} | ||
|
||
async function addToCart(page: Page) { | ||
await page.locator(`[data-cy=AddToCartButton]`).click(); | ||
} | ||
|
||
async function verifyAddToCartDidNotFail(page) { | ||
const errorElement = await page.locator('[data-cy=AddToCartButtonError]'); | ||
await expect(errorElement).toHaveCount(0); | ||
} | ||
|
||
test('select color', async ({ page }) => { | ||
await page.goto('http://localhost:3000'); | ||
|
||
await selectColor(page, "blue") | ||
await selectColor(page, "green") | ||
}); | ||
|
||
test('can buy board', async ({ page }) => { | ||
await page.goto('http://localhost:3000'); | ||
|
||
await selectColor(page, "blue") | ||
await selectColor(page, "green") | ||
await selectColor(page, "blue") | ||
await addToCart(page) | ||
|
||
// Wait for any potential network requests or changes after clicking the button | ||
await page.waitForTimeout(1_000); | ||
await verifyAddToCartDidNotFail(page); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { devices, PlaywrightTestConfig, defineConfig } from '@playwright/test'; | ||
import { devices as replayDevices } from "@replayio/playwright"; | ||
|
||
import dotenv from 'dotenv'; | ||
dotenv.config({ path: '.env' }); | ||
|
||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
const config: PlaywrightTestConfig = defineConfig({ | ||
testDir: './playwright-tests', | ||
/* 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'], | ||
[ | ||
"@replayio/playwright/reporter", | ||
{ | ||
apiKey: process.env.PLAYWRIGHT_REPLAY_API_KEY, | ||
upload: true, | ||
}, | ||
], | ||
], | ||
/* 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', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: "replay-chromium", | ||
use: { ...(replayDevices["Replay Chromium"] as any) }, | ||
}, | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'yarn dev', | ||
url: 'http://127.0.0.1:3000', | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}); | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.