-
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 d6d7028
Showing
13 changed files
with
306 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,43 @@ | ||
name: E2e tests | ||
|
||
on: | ||
push: | ||
branches: [ main, master ] | ||
pull_request: | ||
branches: [ main, master ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
timeout-minutes: 60 | ||
|
||
steps: | ||
- name: Wait for HTTP Status Code 200 from the Vercel Preview Deploy | ||
uses: patrickedqvist/wait-for-vercel-preview@v1.3.2 | ||
id: waitForVercelPreviewDeploy | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
max_timeout: 300 | ||
|
||
- 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: ${{ steps.waitForVercelPreviewDeploy.outputs.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,43 @@ | ||
import path from 'node:path' | ||
|
||
import { defineConfig, devices } from '@playwright/test' | ||
import dotenv from 'dotenv' | ||
|
||
|
||
dotenv.config({ path: path.resolve(__dirname, '.env') }) | ||
|
||
const environment = process.env.NEXT_PUBLIC_NODE_ENV || 'development' | ||
|
||
export default defineConfig({ | ||
forbidOnly: environment !== 'development', | ||
fullyParallel: true, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
{ | ||
name: 'webkit', | ||
use: { ...devices['Desktop Safari'] }, | ||
}, | ||
{ | ||
name: 'Mobile Chrome', | ||
use: { ...devices['Pixel 5'] }, | ||
}, | ||
{ | ||
name: 'Mobile Safari', | ||
use: { ...devices['iPhone 12'] }, | ||
}, | ||
], | ||
reporter: 'html', | ||
retries: environment !== 'development' ? 2 : 0, | ||
testDir: './src/', | ||
testMatch: '**/*.e2e.ts', | ||
use: { | ||
baseURL: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:3000', | ||
screenshot: 'only-on-failure', | ||
trace: 'retain-on-failure', | ||
video: 'retain-on-failure', | ||
}, | ||
workers: environment !== 'development' ? 1 : undefined, | ||
}) |
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,32 @@ | ||
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('check header existance', async ({ appPage }) => { | ||
expect(appPage.header.getElement()).toBeDefined() | ||
expect(appPage.header.getElement()).toBeInViewport() | ||
|
||
expect(appPage.header.getLogo()).toBeDefined() | ||
expect(appPage.header.getLogo()).toBeInViewport() | ||
}) | ||
|
||
test('check navigation menu', async ({ appPage }) => { | ||
expect(appPage.navigation.getElement()).toBeInViewport() | ||
|
||
expect(appPage.navigation.getMenu('')).toBeDefined() | ||
expect(appPage.navigation.getMenu('places')).toBeDefined() | ||
}) | ||
|
||
test('check locales menu', async ({ appPage }) => { | ||
expect(appPage.locales.getElement()).toBeInViewport() | ||
|
||
expect(appPage.locales.getLanguage('en')).toBeDefined() | ||
expect(appPage.locales.getLanguage('it')).toBeDefined() | ||
}) | ||
}) |
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,53 @@ | ||
import type { Locator, Page } from 'playwright/test' | ||
|
||
|
||
export class BasePage { | ||
constructor( | ||
public readonly page: Page, | ||
public readonly header: Header = new Header(page), | ||
public readonly navigation: Navigation = new Navigation(page), | ||
public readonly locales: Locales = new Locales(page), | ||
) {} | ||
} | ||
|
||
class Header { | ||
constructor( | ||
private readonly page: Page, | ||
) {} | ||
|
||
getElement(): Locator { | ||
return this.page.locator('header') | ||
} | ||
|
||
getLogo(): Locator { | ||
return this.getElement().getByRole('navigation', { name: /main logo/i }) | ||
} | ||
} | ||
|
||
class Navigation { | ||
constructor( | ||
private readonly page: Page, | ||
) {} | ||
|
||
getElement(): Locator { | ||
return this.page.getByRole('menubar', { name: /menu/i }) | ||
} | ||
|
||
getMenu(href: string) { | ||
return this.getElement().locator(`a[href*="/${href}"]`) | ||
} | ||
} | ||
|
||
class Locales { | ||
constructor( | ||
private readonly page: Page, | ||
) {} | ||
|
||
getElement(): Locator { | ||
return this.page.getByRole('menubar', { name: /language navigation/i }) | ||
} | ||
|
||
getLanguage(language: string) { | ||
return this.getElement().locator(`a[href*="/${language}"]`) | ||
} | ||
} |