-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
9 changed files
with
323 additions
and
7 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,27 @@ | ||
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/* | ||
- name: Install dependencies | ||
run: npm install -g pnpm && pnpm install | ||
- name: Install Playwright Browsers | ||
run: pnpm exec playwright install --with-deps | ||
- name: Run Playwright tests | ||
run: pnpm exec playwright test | ||
- 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 |
---|---|---|
|
@@ -38,3 +38,8 @@ next-env.d.ts | |
|
||
# IDE | ||
.idea | ||
|
||
/e2e-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('should navigate to the dashboard page', async ({ page }) => { | ||
// Start from the index page (the baseURL is set via the webServer in the playwright.config.ts) | ||
await page.goto('/') | ||
// Find an element with the text 'About' and click on it | ||
await page.click('text=dashboard') | ||
// The new URL should be "/about" (baseURL is used there) | ||
await expect(page).toHaveURL('/dashboard') | ||
// The new page should contain an h1 with "About" | ||
await expect(page.locator('h2')).toContainText('Dashboard') | ||
}) | ||
|
||
test('app journey', async ({ page }) => { | ||
await page.goto('/') | ||
const footerText = page.locator('footer p') | ||
await expect(footerText).toBeVisible() | ||
|
||
const navLinks = page.locator('nav a') | ||
const expectedLinksText = ['Loading', 'dashboard', 'todo demos', 'GitHub'] | ||
|
||
for (let i = 0; i < expectedLinksText.length; i++) { | ||
const linkText = await navLinks.nth(i).textContent() | ||
expect(linkText).toContain(expectedLinksText[i]) | ||
} | ||
|
||
await navLinks.nth(0).click() | ||
await expect(page).toHaveURL('/loading-and-streaming') | ||
|
||
await expect( | ||
page.getByRole('heading', { name: 'Show loading UI and streaming' }), | ||
).toBeVisible() | ||
|
||
await navLinks.nth(2).click() | ||
await expect(page).toHaveURL('/todo') | ||
await expect( | ||
page.getByRole('heading', { name: 'Todo demo with RCC' }), | ||
).toBeVisible() | ||
// todo test submit | ||
}) |
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,105 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
import path from 'path' | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
// Use process.env.PORT by default and fallback to port 3000 | ||
const PORT = process.env.PORT || 3000 | ||
|
||
// Set webServer.url and use.baseURL with the location of the WebServer respecting the correct set port | ||
const baseURL = `http://localhost:${PORT}` | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
// Timeout per test | ||
timeout: 30 * 1000, | ||
// Test directory | ||
testDir: path.join(__dirname, '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: process.env.CI ? 'github' : 'html', | ||
// Artifacts folder where screenshots, videos, and traces are stored. | ||
outputDir: 'e2e-results/', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
|
||
// Run your local dev server before starting the tests: | ||
// https://playwright.dev/docs/test-advanced#launching-a-development-web-server-during-the-tests | ||
webServer: { | ||
command: process.env.CI ? 'pnpm run start' : 'pnpm run dev:turbo', | ||
url: baseURL, | ||
timeout: 2 * 60 * 1000, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
use: { | ||
// Use baseURL so to make navigations relative. | ||
// More information: https://playwright.dev/docs/api/class-testoptions#test-options-base-url | ||
baseURL, | ||
|
||
// Retry a test if its failing with enabled tracing. This allows you to analyze the DOM, console logs, network traffic etc. | ||
// More information: https://playwright.dev/docs/trace-viewer | ||
trace: 'retry-with-trace', | ||
|
||
// All available context options: https://playwright.dev/docs/api/class-browser#browser-new-context | ||
// contextOptions: { | ||
// ignoreHTTPSErrors: true, | ||
// }, | ||
}, | ||
|
||
/* 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: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}) |
Oops, something went wrong.