aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Corentin THOMASSET <corentin.thomasset74@gmail.com> 2023-06-29 18:48:51 +0200
committerGravatar GitHub <noreply@github.com> 2023-06-29 18:48:51 +0200
commitcf382b5a1040530a898c4f5079c294a69c8d163e (patch)
tree3c20f6235f8f3e53c43e5f34fca5fde01ef05961
parent01525838e032a50b9641c404178e15812da8a821 (diff)
downloadit-tools-cf382b5a1040530a898c4f5079c294a69c8d163e.tar.gz
it-tools-cf382b5a1040530a898c4f5079c294a69c8d163e.tar.zst
it-tools-cf382b5a1040530a898c4f5079c294a69c8d163e.zip
chore(e2e): execute e2e against built app (#511)
-rw-r--r--.github/workflows/e2e-tests.yml21
-rw-r--r--.gitignore2
-rw-r--r--playwright.config.ts6
-rw-r--r--src/tools/otp-code-generator-and-validator/otp-code-generator.e2e.spec.ts7
4 files changed, 29 insertions, 7 deletions
diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml
index ba50567..d55e778 100644
--- a/.github/workflows/e2e-tests.yml
+++ b/.github/workflows/e2e-tests.yml
@@ -13,14 +13,35 @@ jobs:
shard: [1/3, 2/3, 3/3]
steps:
- uses: actions/checkout@v3
+
- run: corepack enable
+
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'
+
+ - name: Get Playwright version
+ id: playwright-version
+ run: echo "PLAYWRIGHT_VERSION=$(jq -r .dependencies.playwright package.json)" >> "$GITHUB_OUTPUT"
+
- name: Install dependencies
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
run: pnpm exec playwright install --with-deps
+
- name: Run Playwright tests
run: pnpm run test:e2e --shard=${{ matrix.shard }}
diff --git a/.gitignore b/.gitignore
index 2cfe718..a3bbd94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,5 @@ coverage
/test-results/
/playwright-report/
/playwright/.cache/
+# Webkit with playwright creates a salt file
+salt \ No newline at end of file
diff --git a/playwright.config.ts b/playwright.config.ts
index a445d2d..beb9dc6 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -25,7 +25,7 @@ export default defineConfig({
/* 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',
+ baseURL: 'http://127.0.0.1:5050',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
@@ -75,8 +75,8 @@ export default defineConfig({
/* Run your local dev server before starting the tests */
webServer: {
- command: 'npm run dev',
- url: 'http://127.0.0.1:3000',
+ command: 'npm run preview',
+ url: 'http://127.0.0.1:5050',
reuseExistingServer: !process.env.CI,
},
});
diff --git a/src/tools/otp-code-generator-and-validator/otp-code-generator.e2e.spec.ts b/src/tools/otp-code-generator-and-validator/otp-code-generator.e2e.spec.ts
index 40fb426..4f9933a 100644
--- a/src/tools/otp-code-generator-and-validator/otp-code-generator.e2e.spec.ts
+++ b/src/tools/otp-code-generator-and-validator/otp-code-generator.e2e.spec.ts
@@ -2,6 +2,9 @@ import { expect, test } from '@playwright/test';
test.describe('Tool - OTP code generator', () => {
test.beforeEach(async ({ page }) => {
+ await page.addInitScript(() => {
+ Date.now = () => 1609477200000; // Jan 1, 2021
+ });
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 }) => {
- page.evaluate(() => {
- Date.now = () => 1609477200000; // Jan 1, 2021
- });
-
await page.getByPlaceholder('Paste your TOTP secret...').fill('ITTOOLS');
const previousOtp = await page.getByTestId('previous-otp').innerText();