11import { expect , test } from "@playwright/test" ;
22import { Group , Panel , Separator } from "react-resizable-panels" ;
3+ import { assertLayoutChangeCounts } from "../src/utils/assertLayoutChangeCounts" ;
34import { getSeparatorAriaAttributes } from "../src/utils/getSeparatorAriaAttributes" ;
45import { goToUrl } from "../src/utils/goToUrl" ;
56
@@ -21,7 +22,7 @@ test.describe("keyboard interactions: window splitter api", () => {
2122 { usePopUpWindow }
2223 ) ;
2324
24- await expect ( mainPage . getByText ( '"onLayoutCount": 1' ) ) . toBeVisible ( ) ;
25+ await assertLayoutChangeCounts ( mainPage , 1 ) ;
2526 await expect ( mainPage . getByText ( '"left": 30' ) ) . toBeVisible ( ) ;
2627
2728 await expect ( await getSeparatorAriaAttributes ( page ) ) . toEqual ( {
@@ -36,7 +37,7 @@ test.describe("keyboard interactions: window splitter api", () => {
3637 await separator . focus ( ) ;
3738 await page . keyboard . press ( "ArrowLeft" ) ;
3839
39- await expect ( mainPage . getByText ( '"onLayoutCount": 2' ) ) . toBeVisible ( ) ;
40+ await assertLayoutChangeCounts ( mainPage , 2 ) ;
4041 await expect ( mainPage . getByText ( '"left": 25' ) ) . toBeVisible ( ) ;
4142
4243 await expect ( await getSeparatorAriaAttributes ( page ) ) . toEqual ( {
@@ -48,7 +49,7 @@ test.describe("keyboard interactions: window splitter api", () => {
4849
4950 await page . keyboard . press ( "ArrowRight" ) ;
5051
51- await expect ( mainPage . getByText ( '"onLayoutCount": 3' ) ) . toBeVisible ( ) ;
52+ await assertLayoutChangeCounts ( mainPage , 3 ) ;
5253 await expect ( mainPage . getByText ( '"left": 30' ) ) . toBeVisible ( ) ;
5354
5455 await expect ( await getSeparatorAriaAttributes ( page ) ) . toEqual ( {
@@ -61,7 +62,7 @@ test.describe("keyboard interactions: window splitter api", () => {
6162 // Up/down are no-ops
6263 await page . keyboard . press ( "ArrowUp" ) ;
6364 await page . keyboard . press ( "ArrowDown" ) ;
64- await expect ( mainPage . getByText ( '"onLayoutCount": 3' ) ) . toBeVisible ( ) ;
65+ await assertLayoutChangeCounts ( mainPage , 3 ) ;
6566 } ) ;
6667
6768 test ( "vertical: arrow keys" , async ( { page : mainPage } ) => {
@@ -75,7 +76,7 @@ test.describe("keyboard interactions: window splitter api", () => {
7576 { usePopUpWindow }
7677 ) ;
7778
78- await expect ( mainPage . getByText ( '"onLayoutCount": 1' ) ) . toBeVisible ( ) ;
79+ await assertLayoutChangeCounts ( mainPage , 1 ) ;
7980 await expect ( mainPage . getByText ( '"top": 30' ) ) . toBeVisible ( ) ;
8081
8182 await expect ( await getSeparatorAriaAttributes ( page ) ) . toEqual ( {
@@ -90,7 +91,7 @@ test.describe("keyboard interactions: window splitter api", () => {
9091 await separator . focus ( ) ;
9192 await page . keyboard . press ( "ArrowDown" ) ;
9293
93- await expect ( mainPage . getByText ( '"onLayoutCount": 2' ) ) . toBeVisible ( ) ;
94+ await assertLayoutChangeCounts ( mainPage , 2 ) ;
9495 await expect ( mainPage . getByText ( '"top": 35' ) ) . toBeVisible ( ) ;
9596
9697 await expect ( await getSeparatorAriaAttributes ( page ) ) . toEqual ( {
@@ -102,7 +103,7 @@ test.describe("keyboard interactions: window splitter api", () => {
102103
103104 await page . keyboard . press ( "ArrowUp" ) ;
104105
105- await expect ( mainPage . getByText ( '"onLayoutCount": 3' ) ) . toBeVisible ( ) ;
106+ await assertLayoutChangeCounts ( mainPage , 3 ) ;
106107 await expect ( mainPage . getByText ( '"top": 30' ) ) . toBeVisible ( ) ;
107108
108109 await expect ( await getSeparatorAriaAttributes ( page ) ) . toEqual ( {
@@ -115,7 +116,7 @@ test.describe("keyboard interactions: window splitter api", () => {
115116 // Left/right are no-ops
116117 await page . keyboard . press ( "ArrowLeft" ) ;
117118 await page . keyboard . press ( "ArrowRight" ) ;
118- await expect ( mainPage . getByText ( '"onLayoutCount": 3' ) ) . toBeVisible ( ) ;
119+ await assertLayoutChangeCounts ( mainPage , 3 ) ;
119120 } ) ;
120121
121122 test ( "enter key and collapsible panel" , async ( { page : mainPage } ) => {
@@ -129,7 +130,7 @@ test.describe("keyboard interactions: window splitter api", () => {
129130 { usePopUpWindow }
130131 ) ;
131132
132- await expect ( mainPage . getByText ( '"onLayoutCount": 1' ) ) . toBeVisible ( ) ;
133+ await assertLayoutChangeCounts ( mainPage , 1 ) ;
133134 await expect ( mainPage . getByText ( '"left": 50' ) ) . toBeVisible ( ) ;
134135 await expect ( mainPage . getByText ( '"right": 50' ) ) . toBeVisible ( ) ;
135136
@@ -144,7 +145,7 @@ test.describe("keyboard interactions: window splitter api", () => {
144145 await separator . focus ( ) ;
145146 await page . keyboard . press ( "Enter" ) ;
146147
147- await expect ( mainPage . getByText ( '"onLayoutCount": 2' ) ) . toBeVisible ( ) ;
148+ await assertLayoutChangeCounts ( mainPage , 2 ) ;
148149 await expect ( mainPage . getByText ( '"left": 5' ) ) . toBeVisible ( ) ;
149150 await expect ( mainPage . getByText ( '"right": 95' ) ) . toBeVisible ( ) ;
150151
@@ -157,7 +158,7 @@ test.describe("keyboard interactions: window splitter api", () => {
157158
158159 await page . keyboard . press ( "Enter" ) ;
159160
160- await expect ( mainPage . getByText ( '"onLayoutCount": 3' ) ) . toBeVisible ( ) ;
161+ await assertLayoutChangeCounts ( mainPage , 3 ) ;
161162 await expect ( mainPage . getByText ( '"left": 50' ) ) . toBeVisible ( ) ;
162163 await expect ( mainPage . getByText ( '"right": 50' ) ) . toBeVisible ( ) ;
163164
@@ -170,7 +171,7 @@ test.describe("keyboard interactions: window splitter api", () => {
170171
171172 await page . keyboard . press ( "ArrowLeft" ) ;
172173
173- await expect ( mainPage . getByText ( '"onLayoutCount": 4' ) ) . toBeVisible ( ) ;
174+ await assertLayoutChangeCounts ( mainPage , 4 ) ;
174175 await expect ( mainPage . getByText ( '"left": 45' ) ) . toBeVisible ( ) ;
175176 await expect ( mainPage . getByText ( '"right": 55' ) ) . toBeVisible ( ) ;
176177
@@ -183,7 +184,7 @@ test.describe("keyboard interactions: window splitter api", () => {
183184
184185 await page . keyboard . press ( "Enter" ) ;
185186
186- await expect ( mainPage . getByText ( '"onLayoutCount": 5' ) ) . toBeVisible ( ) ;
187+ await assertLayoutChangeCounts ( mainPage , 5 ) ;
187188 await expect ( mainPage . getByText ( '"left": 5' ) ) . toBeVisible ( ) ;
188189 await expect ( mainPage . getByText ( '"right": 95' ) ) . toBeVisible ( ) ;
189190
@@ -196,7 +197,7 @@ test.describe("keyboard interactions: window splitter api", () => {
196197
197198 await page . keyboard . press ( "Enter" ) ;
198199
199- await expect ( mainPage . getByText ( '"onLayoutCount": 6' ) ) . toBeVisible ( ) ;
200+ await assertLayoutChangeCounts ( mainPage , 6 ) ;
200201 await expect ( mainPage . getByText ( '"left": 45' ) ) . toBeVisible ( ) ;
201202 await expect ( mainPage . getByText ( '"right": 55' ) ) . toBeVisible ( ) ;
202203
@@ -221,15 +222,15 @@ test.describe("keyboard interactions: window splitter api", () => {
221222 { usePopUpWindow }
222223 ) ;
223224
224- await expect ( mainPage . getByText ( '"onLayoutCount": 1' ) ) . toBeVisible ( ) ;
225+ await assertLayoutChangeCounts ( mainPage , 1 ) ;
225226 await expect ( mainPage . getByText ( '"left": 50' ) ) . toBeVisible ( ) ;
226227 await expect ( mainPage . getByText ( '"right": 50' ) ) . toBeVisible ( ) ;
227228
228229 const separator = page . getByRole ( "separator" ) ;
229230 await separator . focus ( ) ;
230231 await page . keyboard . press ( "Enter" ) ;
231232
232- await expect ( mainPage . getByText ( '"onLayoutCount": 1' ) ) . toBeVisible ( ) ;
233+ await assertLayoutChangeCounts ( mainPage , 1 ) ;
233234 } ) ;
234235
235236 test ( "home and end keys" , async ( { page : mainPage } ) => {
@@ -243,7 +244,7 @@ test.describe("keyboard interactions: window splitter api", () => {
243244 { usePopUpWindow }
244245 ) ;
245246
246- await expect ( mainPage . getByText ( '"onLayoutCount": 1' ) ) . toBeVisible ( ) ;
247+ await assertLayoutChangeCounts ( mainPage , 1 ) ;
247248 await expect ( mainPage . getByText ( '"left": 50' ) ) . toBeVisible ( ) ;
248249 await expect ( mainPage . getByText ( '"right": 50' ) ) . toBeVisible ( ) ;
249250
@@ -252,13 +253,13 @@ test.describe("keyboard interactions: window splitter api", () => {
252253 await separator . focus ( ) ;
253254 await page . keyboard . press ( "Home" ) ;
254255
255- await expect ( mainPage . getByText ( '"onLayoutCount": 2' ) ) . toBeVisible ( ) ;
256+ await assertLayoutChangeCounts ( mainPage , 2 ) ;
256257 await expect ( mainPage . getByText ( '"left": 20' ) ) . toBeVisible ( ) ;
257258 await expect ( mainPage . getByText ( '"right": 80' ) ) . toBeVisible ( ) ;
258259
259260 await page . keyboard . press ( "End" ) ;
260261
261- await expect ( mainPage . getByText ( '"onLayoutCount": 3' ) ) . toBeVisible ( ) ;
262+ await assertLayoutChangeCounts ( mainPage , 3 ) ;
262263 await expect ( mainPage . getByText ( '"left": 95' ) ) . toBeVisible ( ) ;
263264 await expect ( mainPage . getByText ( '"right": 5' ) ) . toBeVisible ( ) ;
264265 } ) ;
@@ -307,7 +308,7 @@ test.describe("keyboard interactions: window splitter api", () => {
307308 { usePopUpWindow }
308309 ) ;
309310
310- await expect ( mainPage . getByText ( '"onLayoutCount": 1' ) ) . toBeVisible ( ) ;
311+ await assertLayoutChangeCounts ( mainPage , 1 ) ;
311312 await expect ( mainPage . getByText ( '"left": 30' ) ) . toBeVisible ( ) ;
312313
313314 const separator = page . getByRole ( "separator" ) ;
@@ -320,7 +321,7 @@ test.describe("keyboard interactions: window splitter api", () => {
320321 await page . keyboard . press ( "Enter" ) ;
321322 await page . keyboard . press ( "Home" ) ;
322323
323- await expect ( mainPage . getByText ( '"onLayoutCount": 1' ) ) . toBeVisible ( ) ;
324+ await assertLayoutChangeCounts ( mainPage , 1 ) ;
324325 await expect ( mainPage . getByText ( '"left": 30' ) ) . toBeVisible ( ) ;
325326 } ) ;
326327 } ) ;
0 commit comments