@@ -68,15 +68,15 @@ describe("simple-list integration test", () => {
6868
6969 // Wait for charm to load and verify ct-list exists
7070 await sleep ( 5000 ) ;
71- const ctList = await page . $ ( "pierce/ ct-list" ) ;
71+ const ctList = await page . $ ( "ct-list" , { strategy : "pierce" } ) ;
7272 assert ( ctList , "Should find ct-list component" ) ;
7373 } ) ;
7474
7575 it ( "should add items to the list" , async ( ) => {
7676 const { page } = shell . get ( ) ;
7777
7878 // Find the add item input in ct-list
79- const addInput = await page . $ ( "pierce/ .add-item-input" ) ;
79+ const addInput = await page . $ ( ".add-item-input" , { strategy : "pierce" } ) ;
8080 assert ( addInput , "Should find add item input" ) ;
8181
8282 // Add first item
@@ -96,26 +96,29 @@ describe("simple-list integration test", () => {
9696 await sleep ( 500 ) ;
9797
9898 // Verify items were added
99- const listItems = await page . $$ ( "pierce/ .list-item" ) ;
99+ const listItems = await page . $$ ( ".list-item" , { strategy : "pierce" } ) ;
100100 assertEquals ( listItems . length , 3 , "Should have 3 items in the list" ) ;
101101
102102 // Debug: Log the structure of list items
103103 console . log ( "List item structure:" ) ;
104104 for ( let i = 0 ; i < listItems . length ; i ++ ) {
105- const itemInfo = await listItems [ i ] . evaluate ( ( el : HTMLElement , idx : number ) => {
106- const buttons = el . querySelectorAll ( 'button' ) ;
107- return {
108- index : idx ,
109- className : el . className ,
110- innerText : el . innerText ,
111- buttonCount : buttons . length ,
112- buttons : Array . from ( buttons ) . map ( b => ( {
113- className : b . className ,
114- title : b . title || 'no title' ,
115- innerText : b . innerText
116- } ) )
117- } ;
118- } , { args : [ i ] } as any ) ;
105+ const itemInfo = await listItems [ i ] . evaluate (
106+ ( el : HTMLElement , idx : number ) => {
107+ const buttons = el . querySelectorAll ( "button" ) ;
108+ return {
109+ index : idx ,
110+ className : el . className ,
111+ innerText : el . innerText ,
112+ buttonCount : buttons . length ,
113+ buttons : Array . from ( buttons ) . map ( ( b ) => ( {
114+ className : b . className ,
115+ title : b . title || "no title" ,
116+ innerText : b . innerText ,
117+ } ) ) ,
118+ } ;
119+ } ,
120+ { args : [ i ] } as any ,
121+ ) ;
119122 console . log ( `Item ${ i } :` , itemInfo ) ;
120123 }
121124
@@ -124,19 +127,22 @@ describe("simple-list integration test", () => {
124127
125128 // Verify item content
126129 const firstItemText = await listItems [ 0 ] . evaluate ( ( el : HTMLElement ) => {
127- const content = el . querySelector ( '.item-content' ) || el . querySelector ( 'div.item-content' ) ;
130+ const content = el . querySelector ( ".item-content" ) ||
131+ el . querySelector ( "div.item-content" ) ;
128132 return content ?. textContent || el . textContent ;
129133 } ) ;
130134 assertEquals ( firstItemText ?. trim ( ) , "First item" ) ;
131135
132136 const secondItemText = await listItems [ 1 ] . evaluate ( ( el : HTMLElement ) => {
133- const content = el . querySelector ( '.item-content' ) || el . querySelector ( 'div.item-content' ) ;
137+ const content = el . querySelector ( ".item-content" ) ||
138+ el . querySelector ( "div.item-content" ) ;
134139 return content ?. textContent || el . textContent ;
135140 } ) ;
136141 assertEquals ( secondItemText ?. trim ( ) , "Second item" ) ;
137142
138143 const thirdItemText = await listItems [ 2 ] . evaluate ( ( el : HTMLElement ) => {
139- const content = el . querySelector ( '.item-content' ) || el . querySelector ( 'div.item-content' ) ;
144+ const content = el . querySelector ( ".item-content" ) ||
145+ el . querySelector ( "div.item-content" ) ;
140146 return content ?. textContent || el . textContent ;
141147 } ) ;
142148 assertEquals ( thirdItemText ?. trim ( ) , "Third item" ) ;
@@ -146,7 +152,9 @@ describe("simple-list integration test", () => {
146152 const { page } = shell . get ( ) ;
147153
148154 // Find the title input
149- const titleInput = await page . $ ( "pierce/input[placeholder='List title']" ) ;
155+ const titleInput = await page . $ ( "input[placeholder='List title']" , {
156+ strategy : "pierce" ,
157+ } ) ;
150158 assert ( titleInput , "Should find title input" ) ;
151159
152160 // Clear the existing text first
@@ -158,14 +166,16 @@ describe("simple-list integration test", () => {
158166 await sleep ( 500 ) ;
159167
160168 // Verify title was updated
161- const titleValue = await titleInput . evaluate ( ( el : HTMLInputElement ) => el . value ) ;
169+ const titleValue = await titleInput . evaluate ( ( el : HTMLInputElement ) =>
170+ el . value
171+ ) ;
162172 assertEquals ( titleValue , "My Shopping List" ) ;
163173 } ) ;
164174
165175 // TODO(#CT-703): Fix this test - there's a bug where programmatic clicks on the remove button
166176 // remove ALL items instead of just one. Manual clicking works correctly.
167177 // This appears to be an issue with how ct-list handles synthetic click events
168- // versus real user clicks.
178+ // versus real user clicks.
169179 it . skip ( "should remove items from the list" , async ( ) => {
170180 const { page } = shell . get ( ) ;
171181
@@ -174,13 +184,15 @@ describe("simple-list integration test", () => {
174184 await sleep ( 2000 ) ;
175185
176186 // Get initial count
177- const initialItems = await page . $$ ( "pierce/ .list-item" ) ;
187+ const initialItems = await page . $$ ( ".list-item" , { strategy : "pierce" } ) ;
178188 const initialCount = initialItems . length ;
179189 console . log ( `Initial item count: ${ initialCount } ` ) ;
180190 assert ( initialCount > 0 , "Should have items to remove" ) ;
181191
182192 // Find and click the first remove button
183- const removeButtons = await page . $$ ( "pierce/button.item-action.remove" ) ;
193+ const removeButtons = await page . $$ ( "button.item-action.remove" , {
194+ strategy : "pierce" ,
195+ } ) ;
184196 console . log ( `Found ${ removeButtons . length } remove buttons` ) ;
185197 assert ( removeButtons . length > 0 , "Should find remove buttons" ) ;
186198
@@ -190,55 +202,72 @@ describe("simple-list integration test", () => {
190202 className : el . className ,
191203 title : el . title ,
192204 innerText : el . innerText ,
193- parentText : el . parentElement ?. innerText || ' no parent'
205+ parentText : el . parentElement ?. innerText || " no parent" ,
194206 } ;
195207 } ) ;
196208 console . log ( "About to click button:" , buttonText ) ;
197209
198210 // Try clicking more carefully
199211 console . log ( "Waiting before click..." ) ;
200212 await sleep ( 500 ) ;
201-
213+
202214 // Alternative approach: dispatch click event
203215 await removeButtons [ 0 ] . evaluate ( ( button : HTMLElement ) => {
204216 console . log ( "About to dispatch click event on button:" , button ) ;
205- button . dispatchEvent ( new MouseEvent ( 'click' , {
206- bubbles : true ,
207- cancelable : true ,
208- view : window
209- } ) ) ;
217+ button . dispatchEvent (
218+ new MouseEvent ( "click" , {
219+ bubbles : true ,
220+ cancelable : true ,
221+ view : window ,
222+ } ) ,
223+ ) ;
210224 } ) ;
211225 console . log ( "Dispatched click event on first remove button" ) ;
212226
213227 // Check immediately after click
214228 await sleep ( 100 ) ;
215- const immediateItems = await page . $$ ( "pierce/.list-item" ) ;
216- console . log ( `Immediately after click, found ${ immediateItems . length } items` ) ;
229+ const immediateItems = await page . $$ ( ".list-item" , { strategy : "pierce" } ) ;
230+ console . log (
231+ `Immediately after click, found ${ immediateItems . length } items` ,
232+ ) ;
217233
218234 // Wait longer for the DOM to update after removal
219235 await sleep ( 2000 ) ;
220236
221237 // Verify item was removed - try multiple times
222- let remainingItems = await page . $$ ( "pierce/ .list-item" ) ;
238+ let remainingItems = await page . $$ ( ".list-item" , { strategy : "pierce" } ) ;
223239 console . log ( `After removal, found ${ remainingItems . length } items` ) ;
224240
225241 // If still showing same count, wait a bit more and try again
226242 if ( remainingItems . length === initialCount ) {
227243 console . log ( "DOM not updated yet, waiting more..." ) ;
228244 await sleep ( 2000 ) ;
229- remainingItems = await page . $$ ( "pierce/.list-item" ) ;
230- console . log ( `After additional wait, found ${ remainingItems . length } items` ) ;
245+ remainingItems = await page . $$ ( ".list-item" , { strategy : "pierce" } ) ;
246+ console . log (
247+ `After additional wait, found ${ remainingItems . length } items` ,
248+ ) ;
231249 }
232250
233- assertEquals ( remainingItems . length , initialCount - 1 , "Should have one less item after removal" ) ;
251+ assertEquals (
252+ remainingItems . length ,
253+ initialCount - 1 ,
254+ "Should have one less item after removal" ,
255+ ) ;
234256
235257 // Verify the first item is now what was the second item
236258 if ( remainingItems . length > 0 ) {
237- const firstRemainingText = await remainingItems [ 0 ] . evaluate ( ( el : HTMLElement ) => {
238- const content = el . querySelector ( '.item-content' ) || el . querySelector ( 'div.item-content' ) ;
239- return content ?. textContent || el . textContent ;
240- } ) ;
241- assertEquals ( firstRemainingText ?. trim ( ) , "Second item" , "First item should now be the second item" ) ;
259+ const firstRemainingText = await remainingItems [ 0 ] . evaluate (
260+ ( el : HTMLElement ) => {
261+ const content = el . querySelector ( ".item-content" ) ||
262+ el . querySelector ( "div.item-content" ) ;
263+ return content ?. textContent || el . textContent ;
264+ } ,
265+ ) ;
266+ assertEquals (
267+ firstRemainingText ?. trim ( ) ,
268+ "Second item" ,
269+ "First item should now be the second item" ,
270+ ) ;
242271 }
243272 } ) ;
244273
@@ -253,5 +282,4 @@ describe("simple-list integration test", () => {
253282 // Similar to the delete test, this appears to be a limitation of
254283 // programmatic interaction with the ct-list component
255284 } ) ;
256-
257285} ) ;
0 commit comments