diff --git a/playwright.config.ts b/playwright.config.ts index 60707b0..4ef3c0f 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,10 +1,14 @@ import { defineConfig, devices } from '@playwright/test'; const isCI = !!process.env.CI; -const testTier = process.env.TEST_TIER || 'standard'; +const testTier = (process.env.TEST_TIER || 'standard') as 'fast' | 'standard' | 'deep'; const baseURL = process.env.BASE_URL || (isCI ? 'http://localhost:3000' : 'https://novalon.cn'); -const tierConfig = { +const tierConfig: Record<'fast' | 'standard' | 'deep', { + timeout: number; + retries: number; + workers: number | undefined; +}> = { fast: { timeout: 15000, retries: 0, @@ -22,7 +26,7 @@ const tierConfig = { }, }; -const config = tierConfig[testTier] || tierConfig.standard; +const config = tierConfig[testTier]; export default defineConfig({ testDir: './e2e', diff --git a/src/test-utils/test-data-cleaner.ts b/src/test-utils/test-data-cleaner.ts index 09bab85..7be2eaa 100644 --- a/src/test-utils/test-data-cleaner.ts +++ b/src/test-utils/test-data-cleaner.ts @@ -71,8 +71,11 @@ export class TestDataCleaner { static clearCookies(): void { if (typeof document !== 'undefined' && document.cookie) { document.cookie.split(';').forEach(cookie => { - const name = cookie.split('=')[0].trim(); - document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`; + const parts = cookie.split('='); + const name = parts[0]?.trim(); + if (name) { + document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`; + } }); } }