-
Notifications
You must be signed in to change notification settings - Fork 0
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
96f2544
commit f11947d
Showing
13 changed files
with
246 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
MONGO_DB_URL= | ||
NEXT_PUBLIC_NODE_ENV= | ||
PLAYWRIGHT_BASE_URL= |
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,36 @@ | ||
name: E2e tests | ||
|
||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 60 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
|
||
- name: Run Playwright tests | ||
env: | ||
PLAYWRIGHT_BASE_URL: ${{ github.event.deployment_status.environment_url }} | ||
run: npx 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 |
---|---|---|
|
@@ -36,3 +36,7 @@ yarn-error.log* | |
|
||
# editor | ||
.vscode | ||
/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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,66 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
|
||
export default defineConfig({ | ||
testDir: './src/', | ||
|
||
testMatch: '**/*.e2e.ts', | ||
|
||
/* 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: 'html', | ||
/* 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: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:3000', | ||
|
||
screenshot: 'only-on-failure', // Capture screenshot after each test failure. | ||
trace: 'retain-on-failure', // Record trace only when retrying a test for the first time. | ||
video: 'retain-on-failure', // Record video only when retrying a test for the first time. | ||
}, | ||
|
||
/* 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' }, | ||
// }, | ||
], | ||
}) |
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,2 @@ | ||
export * from './page/AppPage' | ||
export * from './test/testAppPage' |
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,8 @@ | ||
import { BasePage } from 'src/tests/playwright/fixtures' | ||
|
||
|
||
export class AppPage extends BasePage { | ||
async goto(): Promise<void> { | ||
await this.page.goto('/') | ||
} | ||
} |
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,11 @@ | ||
import test from '@playwright/test' | ||
|
||
import { AppPage } from '../page/AppPage' | ||
|
||
|
||
export const testAppPage = test.extend<{ appPage: AppPage }>({ | ||
async appPage({ page }, use) { | ||
const appPage = new AppPage(page) | ||
await use(appPage) | ||
} | ||
}) |
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,22 @@ | ||
import { expect } from '@playwright/test' | ||
|
||
import { testAppPage as test } from './__e2e__/fixtures' | ||
|
||
|
||
test.beforeEach(async ({ appPage }) => { | ||
await appPage.goto() | ||
}) | ||
|
||
test.describe('src / app / [locale] > app', () => { | ||
test('should check header', async ({ appPage }) => { | ||
expect(appPage.header.getElement()).toBeInViewport() | ||
}) | ||
|
||
test('should check locales menu', async ({ appPage }) => { | ||
expect(appPage.header.getLocales()).toBeInViewport() | ||
}) | ||
|
||
test('should check navigation menu', async ({ appPage }) => { | ||
expect(appPage.header.getNavigation()).toBeInViewport() | ||
}) | ||
}) |
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,2 @@ | ||
export * from '@playwright/test' | ||
export * from './page/BasePage' |
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,28 @@ | ||
import type { Locator, Page } from 'playwright/test' | ||
|
||
|
||
export class BasePage { | ||
constructor( | ||
public readonly page: Page, | ||
|
||
public readonly header: Header = new Header(page), | ||
) {} | ||
} | ||
|
||
class Header { | ||
constructor( | ||
private readonly page: Page, | ||
) {} | ||
|
||
getElement(): Locator { | ||
return this.page.locator('header') | ||
} | ||
|
||
getNavigation(): Locator { | ||
return this.page.getByRole('menubar', { name: /menu/i }) | ||
} | ||
|
||
getLocales(): Locator { | ||
return this.page.getByRole('menubar', { name: /language navigation/i }) | ||
} | ||
} |