mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 06:55:06 -04:00
chore(e2e): execute e2e against built app (#511)
This commit is contained in:
parent
01525838e0
commit
cf382b5a10
4 changed files with 29 additions and 7 deletions
21
.github/workflows/e2e-tests.yml
vendored
21
.github/workflows/e2e-tests.yml
vendored
|
@ -13,14 +13,35 @@ jobs:
|
||||||
shard: [1/3, 2/3, 3/3]
|
shard: [1/3, 2/3, 3/3]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- run: corepack enable
|
- run: corepack enable
|
||||||
|
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 16
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
|
- name: Get Playwright version
|
||||||
|
id: playwright-version
|
||||||
|
run: echo "PLAYWRIGHT_VERSION=$(jq -r .dependencies.playwright package.json)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Build app
|
||||||
|
run: pnpm build
|
||||||
|
|
||||||
|
- name: Restore Playwright browsers from cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.cache/ms-playwright
|
||||||
|
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}-${{ hashFiles('**/playwright.config.ts') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}-
|
||||||
|
${{ runner.os }}-playwright-
|
||||||
|
|
||||||
- name: Install Playwright Browsers
|
- name: Install Playwright Browsers
|
||||||
run: pnpm exec playwright install --with-deps
|
run: pnpm exec playwright install --with-deps
|
||||||
|
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: pnpm run test:e2e --shard=${{ matrix.shard }}
|
run: pnpm run test:e2e --shard=${{ matrix.shard }}
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -31,3 +31,5 @@ coverage
|
||||||
/test-results/
|
/test-results/
|
||||||
/playwright-report/
|
/playwright-report/
|
||||||
/playwright/.cache/
|
/playwright/.cache/
|
||||||
|
# Webkit with playwright creates a salt file
|
||||||
|
salt
|
|
@ -25,7 +25,7 @@ export default defineConfig({
|
||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
use: {
|
use: {
|
||||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||||
baseURL: 'http://127.0.0.1:3000',
|
baseURL: 'http://127.0.0.1:5050',
|
||||||
|
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: 'on-first-retry',
|
trace: 'on-first-retry',
|
||||||
|
@ -75,8 +75,8 @@ export default defineConfig({
|
||||||
|
|
||||||
/* Run your local dev server before starting the tests */
|
/* Run your local dev server before starting the tests */
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'npm run dev',
|
command: 'npm run preview',
|
||||||
url: 'http://127.0.0.1:3000',
|
url: 'http://127.0.0.1:5050',
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,6 +2,9 @@ import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
test.describe('Tool - OTP code generator', () => {
|
test.describe('Tool - OTP code generator', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.addInitScript(() => {
|
||||||
|
Date.now = () => 1609477200000; // Jan 1, 2021
|
||||||
|
});
|
||||||
await page.goto('/otp-generator');
|
await page.goto('/otp-generator');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,10 +21,6 @@ test.describe('Tool - OTP code generator', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('OTP a generated from the provided secret', async ({ page }) => {
|
test('OTP a generated from the provided secret', async ({ page }) => {
|
||||||
page.evaluate(() => {
|
|
||||||
Date.now = () => 1609477200000; // Jan 1, 2021
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.getByPlaceholder('Paste your TOTP secret...').fill('ITTOOLS');
|
await page.getByPlaceholder('Paste your TOTP secret...').fill('ITTOOLS');
|
||||||
|
|
||||||
const previousOtp = await page.getByTestId('previous-otp').innerText();
|
const previousOtp = await page.getByTestId('previous-otp').innerText();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue