import { assertPublicHost, waitForUrlHost } from '@levkin/playkit'; import { test, expect } from '../fixtures'; /** * Idle logout must redirect to the public host (same class as #57). * Uses ?e2e_idle_ms= to shorten the IdleLogoutHandler timeout. */ test.describe('auth idle @smoke', () => { test('idle logout stays on public host', async ({ page, playkitConfig, loginPage, e2eCredentials, timings, }) => { test.skip(!e2eCredentials, 'E2E_ADMIN_EMAIL/PASSWORD required'); assertPublicHost(playkitConfig.baseUrl); await timings.measure('login', async () => { await loginPage.openLogin(); await loginPage.signIn(e2eCredentials!.email, e2eCredentials!.password); await page.waitForURL((url) => !url.pathname.includes('/login'), { timeout: 30_000 }); await page.getByLabel('Account menu').waitFor({ state: 'visible', timeout: 30_000 }); }); // Short idle window — requires IdleLogoutHandler e2e_idle_ms support on DEV await page.goto(`${playkitConfig.baseUrl}/?e2e_idle_ms=2500`); await waitForUrlHost(page, playkitConfig.expectedHost); await expect(page.getByLabel('Account menu')).toBeVisible(); // Stop activity; wait for idle sign-out await page.waitForTimeout(4_000); await expect(page.getByRole('button', { name: /Sign in/i })).toBeVisible({ timeout: 20_000, }); await waitForUrlHost(page, playkitConfig.expectedHost); expect(page.url()).not.toMatch(/10\.\d+\.\d+\.\d+/); }); });