Skip to content

Commit 996f9ad

Browse files
committed
✅(frontend) add e2e test to check focus behavior with F2 shortcut
ensures F2 correctly focuses the expected UI element Signed-off-by: Cyril <[email protected]>
1 parent 80aead7 commit 996f9ad

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/frontend/apps/e2e/__tests__/app-impress/doc-tree.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,40 @@ test.describe('Doc Tree', () => {
303303
await expect(docTree.getByText(docChild)).toBeVisible();
304304
});
305305

306+
test('keyboard navigation with F2 focuses root actions button', async ({
307+
page,
308+
browserName,
309+
}) => {
310+
// Create a parent document to initialize the tree
311+
const [docParent] = await createDoc(
312+
page,
313+
'doc-tree-keyboard-f2-root',
314+
browserName,
315+
1,
316+
);
317+
await verifyDocName(page, docParent);
318+
319+
const docTree = page.getByTestId('doc-tree');
320+
await expect(docTree).toBeVisible();
321+
322+
const rootItem = page.getByTestId('doc-tree-root-item');
323+
await expect(rootItem).toBeVisible();
324+
325+
// Focus the root item
326+
await rootItem.focus();
327+
await expect(rootItem).toBeFocused();
328+
329+
// Press F2 → focus should move to the root actions \"More options\" button
330+
await page.keyboard.press('F2');
331+
332+
const rootActions = rootItem.locator('.doc-tree-root-item-actions');
333+
const rootMoreOptionsButton = rootActions.getByRole('button', {
334+
name: /more options/i,
335+
});
336+
337+
await expect(rootMoreOptionsButton).toBeFocused();
338+
});
339+
306340
test('it updates the child icon from the tree', async ({
307341
page,
308342
browserName,

0 commit comments

Comments
 (0)