@@ -1996,4 +1996,132 @@ describe("overlay", () => {
1996
1996
await server . stop ( ) ;
1997
1997
}
1998
1998
} ) ;
1999
+
2000
+ it ( "should navigate between multiple errors using buttons and keyboard shortcuts" , async ( ) => {
2001
+ const compiler = webpack ( config ) ;
2002
+
2003
+ // Create multiple distinct errors for navigation testing
2004
+ new ErrorPlugin ( "First error message" ) . apply ( compiler ) ;
2005
+ new ErrorPlugin ( "Second error message" ) . apply ( compiler ) ;
2006
+ new ErrorPlugin ( "Third error message" ) . apply ( compiler ) ;
2007
+
2008
+ const devServerOptions = {
2009
+ port,
2010
+ } ;
2011
+ const server = new Server ( devServerOptions , compiler ) ;
2012
+
2013
+ await server . start ( ) ;
2014
+
2015
+ const { page, browser } = await runBrowser ( ) ;
2016
+
2017
+ try {
2018
+ await page . goto ( `http://localhost:${ port } /` , {
2019
+ waitUntil : "networkidle0" ,
2020
+ } ) ;
2021
+
2022
+ // Delay for the overlay to appear
2023
+ await delay ( 1000 ) ;
2024
+
2025
+ // Get the overlay iframe and its content frame
2026
+ const overlayHandle = await page . $ ( "#webpack-dev-server-client-overlay" ) ;
2027
+ const overlayFrame = await overlayHandle . contentFrame ( ) ;
2028
+
2029
+ // Check initial error counter display
2030
+ let errorCounter = await overlayFrame . $eval (
2031
+ ".error-counter" ,
2032
+ ( el ) => el . textContent ,
2033
+ ) ;
2034
+ expect ( errorCounter ) . toBe ( "ERROR 1/3" ) ;
2035
+
2036
+ // Check initial error content
2037
+ let errorContent = await overlayFrame . $eval (
2038
+ ".error-message" ,
2039
+ ( el ) => el . textContent ,
2040
+ ) ;
2041
+ expect ( errorContent ) . toContain ( "First error message" ) ;
2042
+
2043
+ // Test navigation button - next
2044
+ const nextButton = await overlayFrame . $ ( "button:nth-of-type(2)" ) ;
2045
+ await nextButton . click ( ) ;
2046
+ await delay ( 100 ) ;
2047
+
2048
+ // Verify we moved to second error
2049
+ errorCounter = await overlayFrame . $eval (
2050
+ ".error-counter" ,
2051
+ ( el ) => el . textContent ,
2052
+ ) ;
2053
+ expect ( errorCounter ) . toBe ( "ERROR 2/3" ) ;
2054
+ errorContent = await overlayFrame . $eval (
2055
+ ".error-message" ,
2056
+ ( el ) => el . textContent ,
2057
+ ) ;
2058
+ expect ( errorContent ) . toContain ( "Second error message" ) ;
2059
+
2060
+ // Test navigation button - next (to third error)
2061
+ await nextButton . click ( ) ;
2062
+ await delay ( 100 ) ;
2063
+
2064
+ // Verify we moved to third error
2065
+ errorCounter = await overlayFrame . $eval (
2066
+ ".error-counter" ,
2067
+ ( el ) => el . textContent ,
2068
+ ) ;
2069
+ expect ( errorCounter ) . toBe ( "ERROR 3/3" ) ;
2070
+ errorContent = await overlayFrame . $eval (
2071
+ ".error-message" ,
2072
+ ( el ) => el . textContent ,
2073
+ ) ;
2074
+ expect ( errorContent ) . toContain ( "Third error message" ) ;
2075
+
2076
+ // Test navigation button - next (should cycle back to first error)
2077
+ await nextButton . click ( ) ;
2078
+ await delay ( 100 ) ;
2079
+
2080
+ // Verify we cycled back to first error
2081
+ errorCounter = await overlayFrame . $eval (
2082
+ ".error-counter" ,
2083
+ ( el ) => el . textContent ,
2084
+ ) ;
2085
+ expect ( errorCounter ) . toBe ( "ERROR 1/3" ) ;
2086
+
2087
+ // Test keyboard navigation - ⌘/Ctrl + →
2088
+ await page . keyboard . down (
2089
+ process . platform === "darwin" ? "Meta" : "Control" ,
2090
+ ) ;
2091
+ await page . keyboard . press ( "ArrowRight" ) ;
2092
+ await page . keyboard . up (
2093
+ process . platform === "darwin" ? "Meta" : "Control" ,
2094
+ ) ;
2095
+ await delay ( 100 ) ;
2096
+
2097
+ // Verify keyboard navigation worked
2098
+ errorCounter = await overlayFrame . $eval (
2099
+ ".error-counter" ,
2100
+ ( el ) => el . textContent ,
2101
+ ) ;
2102
+ expect ( errorCounter ) . toBe ( "ERROR 2/3" ) ;
2103
+
2104
+ // Test keyboard navigation - ⌘/Ctrl + ←
2105
+ await page . keyboard . down (
2106
+ process . platform === "darwin" ? "Meta" : "Control" ,
2107
+ ) ;
2108
+ await page . keyboard . press ( "ArrowLeft" ) ;
2109
+ await page . keyboard . up (
2110
+ process . platform === "darwin" ? "Meta" : "Control" ,
2111
+ ) ;
2112
+ await delay ( 100 ) ;
2113
+
2114
+ // Verify keyboard navigation worked
2115
+ errorCounter = await overlayFrame . $eval (
2116
+ ".error-counter" ,
2117
+ ( el ) => el . textContent ,
2118
+ ) ;
2119
+ expect ( errorCounter ) . toBe ( "ERROR 1/3" ) ;
2120
+ } catch ( error ) {
2121
+ throw error ;
2122
+ } finally {
2123
+ await browser . close ( ) ;
2124
+ await server . stop ( ) ;
2125
+ }
2126
+ } ) ;
1999
2127
} ) ;
0 commit comments