diff --git a/ui/package.json b/ui/package.json index d9b12888..ccbb39df 100644 --- a/ui/package.json +++ b/ui/package.json @@ -12,10 +12,10 @@ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --check . && eslint .", "format": "prettier --write .", - "test:local-auth": "playwright test tests/local-auth.spec.ts --config=playwright.config.local-auth.ts", - "test:reconnect": "playwright test tests/reconnect.spec.ts --config=playwright.reconnect.config.ts", - "test:e2e": "playwright test", - "test:e2e-in-cluster": "playwright test --config=playwright.config.in-cluster.ts", + "test:local-auth": "TEST_CFG=localAuth playwright test tests/local-auth.spec.ts", + "test:reconnect": "TEST_CFG=reconnect playwright test", + "test:e2e": "TEST_CFG=default playwright test", + "test:e2e-in-cluster": "TEST_CFG=inCluster playwright test", "test:install": "playwright install", "test:unit": "vitest run" }, diff --git a/ui/playwright.config.in-cluster.ts b/ui/playwright.config.in-cluster.ts deleted file mode 100644 index d325d000..00000000 --- a/ui/playwright.config.in-cluster.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2024 Defense Unicorns -// SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial - -import { defineConfig } from '@playwright/test' - -const protocol = 'https' -const host = 'runtime.admin.uds.dev' - -export default defineConfig({ - globalSetup: './tests/global-setup', - timeout: 10 * 1000, - testDir: 'tests', - /* Run tests in files in parallel */ - fullyParallel: true, - retries: process.env.CI ? 2 : 1, - testMatch: /^(?!.*local-auth|.*reconnect)(.+\.)?(test|spec)\.[jt]s$/, - use: { - baseURL: `${protocol}://${host}/`, - storageState: './tests/state.json', - }, -}) diff --git a/ui/playwright.config.local-auth.ts b/ui/playwright.config.local-auth.ts deleted file mode 100644 index 663d378c..00000000 --- a/ui/playwright.config.local-auth.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2024 Defense Unicorns -// SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial - -import { defineConfig } from '@playwright/test' -import { loadEnv } from 'vite' - -const { VITE_PORT_ENV } = loadEnv('dev', process.cwd()) -const port = VITE_PORT_ENV ?? '8443' - -export default defineConfig({ - timeout: 60 * 1000, - testDir: 'tests', - fullyParallel: false, - retries: process.env.CI ? 2 : 1, - testMatch: /^(?!.*in-cluster|.*reconnect)(.+\.)?(test|spec)\.[jt]s$/, - use: { - baseURL: `https://runtime-local.uds.dev:${port}/`, - }, -}) - -export { port } diff --git a/ui/playwright.config.ts b/ui/playwright.config.ts index ec55a2c1..2e728ac5 100644 --- a/ui/playwright.config.ts +++ b/ui/playwright.config.ts @@ -5,6 +5,7 @@ import { defineConfig } from '@playwright/test' import { loadEnv } from 'vite' const { VITE_PORT_ENV } = loadEnv('dev', process.cwd()) +const TEST_CONFIG = process.env.TEST_CFG || 'default' // use port 8443 because by default we use TLS when running locally const port = VITE_PORT_ENV ?? '8443' @@ -73,6 +74,13 @@ const reconnect = { }, } -export default defineConfig({ projects: [defaultConfig, localAuth, inCluster, reconnect] }) +const configs = { + default: defaultConfig, + localAuth, + inCluster, + reconnect, +} + +export default defineConfig({ ...configs[TEST_CONFIG] }) export { port } diff --git a/ui/playwright.reconnect.config.ts b/ui/playwright.reconnect.config.ts deleted file mode 100644 index bd5ca976..00000000 --- a/ui/playwright.reconnect.config.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2024 Defense Unicorns -// SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial - -import { defineConfig } from '@playwright/test' -import { loadEnv } from 'vite' - -const { VITE_PORT_ENV } = loadEnv('dev', process.cwd()) - -// use port 8443 because by default we use TLS when running locally -const port = VITE_PORT_ENV ?? '8443' -const protocol = 'https' -const host = 'runtime-local.uds.dev' - -export default defineConfig({ - webServer: { - command: '../build/uds-runtime', - url: `${protocol}://${host}:${port}`, - reuseExistingServer: !process.env.CI, - env: { LOCAL_AUTH_ENABLED: 'false' }, - }, - timeout: 10 * 1000, - testDir: 'tests', - fullyParallel: false, - retries: process.env.CI ? 2 : 1, - testMatch: 'reconnect.spec.ts', - use: { - baseURL: `https://runtime-local.uds.dev:${port}/`, - }, -}) - -export { port }