File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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" ) ;
You can’t perform that action at this time.
0 commit comments