@@ -62,4 +62,122 @@ test.describe("Stamp Tool Tests", () => {
6262 }
6363 assertNoConsoleErrors ( consoleErrors , "tool persistence" ) ;
6464 } ) ;
65+
66+ test ( "navigation buttons exist with correct labels" , async ( { page } ) => {
67+ const consoleErrors = setupConsoleErrorMonitoring ( page ) ;
68+ await selectTool ( page , TOOL_ID ) ;
69+ const subtoolButtons = await getSubtools ( page ) ;
70+ const subtoolCount = await subtoolButtons . count ( ) ;
71+
72+ // Navigation buttons should be at the end (last 4 buttons)
73+ // Order: prev row, next row, prev stamp pack, next stamp pack
74+ const prevRowBtn = subtoolButtons . nth ( subtoolCount - 4 ) ;
75+ const nextRowBtn = subtoolButtons . nth ( subtoolCount - 3 ) ;
76+ const prevPackBtn = subtoolButtons . nth ( subtoolCount - 2 ) ;
77+ const nextPackBtn = subtoolButtons . nth ( subtoolCount - 1 ) ;
78+
79+ // Verify buttons exist and have correct titles
80+ await expect ( prevRowBtn ) . toHaveAttribute ( "title" , "prev row" ) ;
81+ await expect ( nextRowBtn ) . toHaveAttribute ( "title" , "next row" ) ;
82+ await expect ( prevPackBtn ) . toHaveAttribute ( "title" , "prev stamp pack" ) ;
83+ await expect ( nextPackBtn ) . toHaveAttribute ( "title" , "next stamp pack" ) ;
84+
85+ assertNoConsoleErrors ( consoleErrors , "navigation buttons" ) ;
86+ } ) ;
87+
88+ test ( "next row navigation works" , async ( { page } ) => {
89+ const consoleErrors = setupConsoleErrorMonitoring ( page ) ;
90+ await selectTool ( page , TOOL_ID ) ;
91+
92+ // Get initial row from KiddoPaint.Sprite.page
93+ const initialRow = await page . evaluate ( ( ) => window . KiddoPaint . Sprite . page ) ;
94+
95+ // Click next row button
96+ const subtoolButtons = await getSubtools ( page ) ;
97+ const subtoolCount = await subtoolButtons . count ( ) ;
98+ const nextRowBtn = subtoolButtons . nth ( subtoolCount - 3 ) ;
99+ await nextRowBtn . click ( ) ;
100+
101+ // Verify row changed
102+ const newRow = await page . evaluate ( ( ) => window . KiddoPaint . Sprite . page ) ;
103+ expect ( newRow ) . toBe ( ( initialRow + 1 ) % 8 ) ; // 8 rows total (0-7)
104+
105+ assertNoConsoleErrors ( consoleErrors , "next row navigation" ) ;
106+ } ) ;
107+
108+ test ( "prev row navigation works" , async ( { page } ) => {
109+ const consoleErrors = setupConsoleErrorMonitoring ( page ) ;
110+ await selectTool ( page , TOOL_ID ) ;
111+
112+ // Get initial row from KiddoPaint.Sprite.page
113+ const initialRow = await page . evaluate ( ( ) => window . KiddoPaint . Sprite . page ) ;
114+
115+ // Click prev row button
116+ const subtoolButtons = await getSubtools ( page ) ;
117+ const subtoolCount = await subtoolButtons . count ( ) ;
118+ const prevRowBtn = subtoolButtons . nth ( subtoolCount - 4 ) ;
119+ await prevRowBtn . click ( ) ;
120+
121+ // Verify row changed
122+ const newRow = await page . evaluate ( ( ) => window . KiddoPaint . Sprite . page ) ;
123+ const expectedRow = initialRow === 0 ? 7 : initialRow - 1 ;
124+ expect ( newRow ) . toBe ( expectedRow ) ;
125+
126+ assertNoConsoleErrors ( consoleErrors , "prev row navigation" ) ;
127+ } ) ;
128+
129+ test ( "next stamp pack navigation works" , async ( { page } ) => {
130+ const consoleErrors = setupConsoleErrorMonitoring ( page ) ;
131+ await selectTool ( page , TOOL_ID ) ;
132+
133+ // Get initial sheet from KiddoPaint.Sprite.sheetPage
134+ const initialSheet = await page . evaluate (
135+ ( ) => window . KiddoPaint . Sprite . sheetPage ,
136+ ) ;
137+
138+ // Click next stamp pack button
139+ const subtoolButtons = await getSubtools ( page ) ;
140+ const subtoolCount = await subtoolButtons . count ( ) ;
141+ const nextPackBtn = subtoolButtons . nth ( subtoolCount - 1 ) ;
142+ await nextPackBtn . click ( ) ;
143+
144+ // Verify sheet changed
145+ const newSheet = await page . evaluate (
146+ ( ) => window . KiddoPaint . Sprite . sheetPage ,
147+ ) ;
148+ const sheetsLength = await page . evaluate (
149+ ( ) => window . KiddoPaint . Sprite . sheets . length ,
150+ ) ;
151+ expect ( newSheet ) . toBe ( ( initialSheet + 1 ) % sheetsLength ) ;
152+
153+ assertNoConsoleErrors ( consoleErrors , "next stamp pack navigation" ) ;
154+ } ) ;
155+
156+ test ( "prev stamp pack navigation works" , async ( { page } ) => {
157+ const consoleErrors = setupConsoleErrorMonitoring ( page ) ;
158+ await selectTool ( page , TOOL_ID ) ;
159+
160+ // Get initial sheet from KiddoPaint.Sprite.sheetPage
161+ const initialSheet = await page . evaluate (
162+ ( ) => window . KiddoPaint . Sprite . sheetPage ,
163+ ) ;
164+
165+ // Click prev stamp pack button
166+ const subtoolButtons = await getSubtools ( page ) ;
167+ const subtoolCount = await subtoolButtons . count ( ) ;
168+ const prevPackBtn = subtoolButtons . nth ( subtoolCount - 2 ) ;
169+ await prevPackBtn . click ( ) ;
170+
171+ // Verify sheet changed
172+ const newSheet = await page . evaluate (
173+ ( ) => window . KiddoPaint . Sprite . sheetPage ,
174+ ) ;
175+ const sheetsLength = await page . evaluate (
176+ ( ) => window . KiddoPaint . Sprite . sheets . length ,
177+ ) ;
178+ const expectedSheet = initialSheet === 0 ? sheetsLength - 1 : initialSheet - 1 ;
179+ expect ( newSheet ) . toBe ( expectedSheet ) ;
180+
181+ assertNoConsoleErrors ( consoleErrors , "prev stamp pack navigation" ) ;
182+ } ) ;
65183} ) ;
0 commit comments