Skip to content

Commit ecdfd64

Browse files
test(link): ensure Enter activates focused links (#3183)
* fix(link): ensure Enter activates focused links * test(link): remove ineffective Enter coverage * test(link): cover native Enter activation --------- Co-authored-by: James <james@eli.cx>
1 parent 53c3f26 commit ecdfd64

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/e2e/app-router/navigation.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ test.describe("App Router Client-side Navigation", () => {
2929
expect(page.url()).toBe(`${BASE}/about`);
3030
});
3131

32+
test("Link activates with the Enter key without a full page reload", async ({ page }) => {
33+
await page.goto(`${BASE}/`);
34+
await expect(page.locator("h1")).toHaveText("Welcome to App Router");
35+
await waitForAppRouterHydration(page);
36+
37+
await page.evaluate(() => {
38+
(window as any).__NAV_MARKER__ = true;
39+
});
40+
41+
const aboutLink = page.locator('a[href="/about"]');
42+
await aboutLink.focus();
43+
await page.keyboard.press("Enter");
44+
45+
await expect(page.locator("h1")).toHaveText("About");
46+
await expect(page.locator("main > p")).toContainText("This is the about page.");
47+
await expect(page).toHaveURL(`${BASE}/about`);
48+
expect(await page.evaluate(() => (window as any).__NAV_MARKER__)).toBe(true);
49+
});
50+
3251
test("Link navigates back from about to home", async ({ page }) => {
3352
await page.goto(`${BASE}/about`);
3453
await expect(page.locator("h1")).toHaveText("About");

0 commit comments

Comments
 (0)