// @ts-check import { test, expect } from '@playwright/test'; import { loadTestUser } from '../utils/testUser.js'; test.describe('@p0 Support modal — open/close', () => { test.setTimeout(15000); test('header Support opens modal and can be closed', async ({ page }) => { const user = loadTestUser(); // Sign in await page.context().clearCookies(); await page.goto('/signin', { waitUntil: 'networkidle' }); await page.getByPlaceholder('Username', { exact: true }).fill(user.username); await page.getByPlaceholder('Password', { exact: true }).fill(user.password); await page.getByRole('button', { name: /^Sign In$/ }).click(); await page.waitForURL('**/signin-landing**', { timeout: 15000 }); // Click Support in header const supportBtn = page.getByRole('button', { name: /^Support$/i }).or(page.getByText(/^Support$/i)); await expect(supportBtn).toBeVisible({ timeout: 5000 }); await supportBtn.click(); // Modal/overlay appears (be tolerant re: structure) // Modal/overlay appears (be tolerant re: structure) const overlay = page.locator('div.fixed.inset-0').first(); await expect(overlay).toBeVisible({ timeout: 5000 }); // Try multiple closing strategies in order const dlg = overlay.locator('div[role="dialog"], div.bg-white').first(); const closeByText = dlg.getByRole('button', { name: /(Close|Done|OK|Cancel|Dismiss)/i }).first(); const closeByAria = dlg.locator('[aria-label="Close"], [aria-label="close"]').first(); const headerSupport = page.getByRole('button', { name: /^Support$/i }).or(page.getByText(/^Support$/i)); if (await closeByText.isVisible({ timeout: 500 }).catch(() => false)) { await closeByText.click(); } else if (await closeByAria.isVisible({ timeout: 200 }).catch(() => false)) { await closeByAria.click(); } else { // Fallbacks: ESC, then toggle Support again await page.keyboard.press('Escape'); if (await overlay.isVisible({ timeout: 800 }).catch(() => false)) { if (await headerSupport.isVisible().catch(() => false)) await headerSupport.click(); } } await expect(overlay).toBeHidden({ timeout: 8000 }); }); });