From 44e599bbf092508aae1dd58b28bacd23167bd85f Mon Sep 17 00:00:00 2001 From: Sergei Garin Date: Wed, 13 Nov 2024 20:06:30 +0300 Subject: [PATCH] Improve tests --- app/gui/e2e/dashboard/auth.setup.ts | 19 ++++++++++++++----- app/gui/playwright.config.ts | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/gui/e2e/dashboard/auth.setup.ts b/app/gui/e2e/dashboard/auth.setup.ts index cdd55f33e152..78734db23d52 100644 --- a/app/gui/e2e/dashboard/auth.setup.ts +++ b/app/gui/e2e/dashboard/auth.setup.ts @@ -1,15 +1,24 @@ import { test as setup } from '@playwright/test' -import path from 'path' +import { existsSync } from 'node:fs' +import path from 'node:path' import * as actions from './actions' const __dirname = path.dirname(new URL(import.meta.url).pathname) const authFile = path.join(__dirname, '../../playwright/.auth/user.json') -setup('authenticate', ({ page }) => - actions +const isFileExists = () => { + return existsSync(authFile) +} + +setup('authenticate', ({ page }) => { + if (isFileExists()) { + return setup.skip() + } + + return actions .mockAll({ page }) .login() .do(async () => { await page.context().storageState({ path: authFile }) - }), -) + }) +}) diff --git a/app/gui/playwright.config.ts b/app/gui/playwright.config.ts index cf3fc4c0d19d..2be25fcb4a34 100644 --- a/app/gui/playwright.config.ts +++ b/app/gui/playwright.config.ts @@ -57,6 +57,7 @@ process.env.PLAYWRIGHT_PORT_PV = `${ports.projectView}` export default defineConfig({ fullyParallel: true, + workers: 2, forbidOnly: !!process.env.CI, repeatEach: process.env.CI ? 3 : 1, reporter: 'html',