import { test, expect } from '@playwright/test'; import { createEmptyDocument } from './helpers/upload-empty-document.js'; test.describe('Help chip — Read/Edit panel header', () => { let docId: string; test.beforeAll(async ({ request }) => { docId = await createEmptyDocument(request); }); test('opens popover on click, closes on Esc, returns focus to chip', async ({ page }) => { await page.goto(`/documents/${docId}`); await page.getByRole('button', { name: 'Transkribieren' }).click(); // Find and click the (?) help chip const helpBtn = page.locator('button[aria-expanded]'); await expect(helpBtn).toBeVisible({ timeout: 5000 }); await helpBtn.click(); // Popover should open await expect(page.locator('[role="tooltip"]')).toBeVisible(); // Press Esc await page.keyboard.press('Escape'); await expect(page.locator('[role="tooltip"]')).not.toBeVisible(); // Focus should have returned to the chip await expect(helpBtn).toBeFocused(); }); });