@@ -162,21 +162,19 @@ test.describe('Git Stash Commands', () => {
162
162
// Show the stash entries and hover on the stash entry
163
163
await page . getByText ( 'Stash(2)' ) . click ( ) ;
164
164
await page
165
- . locator ( 'span' )
166
- . filter ( { hasText : 'stashy stash (on master)' } )
165
+ . locator ( 'div' ) . filter ( { hasText : / ^ s t a s h y s t a s h \( o n m a s t e r \) $ / } ) . last ( )
167
166
. hover ( ) ;
168
167
169
- const applyStashBtn = await page
170
- . locator ( 'span' )
171
- . filter ( { hasText : 'stashy stash (on master)' } )
168
+ const applyStashBtn = page
169
+ . locator ( 'div' ) . filter ( { hasText : / ^ s t a s h y s t a s h \( o n m a s t e r \) $ / } ) . last ( )
172
170
. getByRole ( 'button' , { name : 'Apply stash entry' } ) ;
173
171
174
172
await applyStashBtn . click ( ) ;
175
173
176
174
// Check that the stash applies
177
175
await expect
178
- . soft ( await page . getByText ( 'console.log("dirty changes");' ) )
179
- . toBeTruthy ( ) ;
176
+ . soft ( page . getByText ( 'console.log("dirty changes");' ) )
177
+ . toHaveCount ( 1 ) ;
180
178
181
179
// open the second file has changes applied
182
180
await page . getByRole ( 'tab' , { name : 'File Browser' } ) . click ( ) ;
@@ -187,12 +185,12 @@ test.describe('Git Stash Commands', () => {
187
185
. dblclick ( ) ;
188
186
189
187
await expect
190
- . soft ( await page . getByText ( 'This is some dirty changes' ) )
191
- . toBeTruthy ( ) ;
188
+ . soft ( page . getByText ( 'This is some dirty changes' ) )
189
+ . toHaveCount ( 1 ) ;
192
190
193
191
// See if the nStashes remains the same
194
- const numberOfStashes = await page . locator ( '[data-test-id="num-stashes"]' ) ;
195
- await expect ( await numberOfStashes . innerText ( ) ) . toBe ( '(2)' ) ;
192
+ const numberOfStashes = page . locator ( '[data-test-id="num-stashes"]' ) ;
193
+ await expect ( numberOfStashes ) . toHaveText ( '(2)' ) ;
196
194
} ) ;
197
195
198
196
test ( 'should pop a stash entry when the `stash pop` button is clicked (apply stash then remove from list)' , async ( {
@@ -219,16 +217,12 @@ test.describe('Git Stash Commands', () => {
219
217
await page . getByText ( 'Stash' , { exact : true } ) . click ( ) ;
220
218
221
219
await page
222
- . locator ( 'span' )
223
- . filter ( { hasText : 'stashy stash (on master)' } )
220
+ . locator ( 'div' ) . filter ( { hasText : / ^ s t a s h y s t a s h \( o n m a s t e r \) $ / } ) . last ( )
224
221
. hover ( ) ;
225
222
226
- const popStashBtn = await page
227
- . locator ( 'span' )
228
- . filter ( { hasText : 'stashy stash (on master)' } )
229
- . getByRole ( 'button' , { name : 'Pop stash entry' } ) ;
230
-
231
- await popStashBtn . click ( ) ;
223
+ await page
224
+ . locator ( 'div' ) . filter ( { hasText : / ^ s t a s h y s t a s h \( o n m a s t e r \) $ / } ) . last ( )
225
+ . getByRole ( 'button' , { name : 'Pop stash entry' } ) . click ( ) ;
232
226
233
227
// Wait for the number of stashes to change
234
228
await page . waitForFunction ( ( ) => {
@@ -237,11 +231,9 @@ test.describe('Git Stash Commands', () => {
237
231
} ) ;
238
232
await page . waitForTimeout ( 100 ) ;
239
233
// Check that the stash applies
240
- const firstStashFileText = await page
241
- . locator ( 'pre' )
242
- . filter ( { hasText : 'console.log("dirty changes");' } ) ;
234
+ const firstStashFileText = page . getByText ( 'console.log("dirty changes");' ) ;
243
235
244
- await expect . soft ( await firstStashFileText . count ( ) ) . toBe ( 1 ) ;
236
+ await expect . soft ( firstStashFileText ) . toHaveCount ( 1 ) ;
245
237
246
238
// open the second file has changes applied
247
239
await page . getByRole ( 'tab' , { name : 'File Browser' } ) . click ( ) ;
@@ -254,11 +246,9 @@ test.describe('Git Stash Commands', () => {
254
246
// Wait for revertFile to finish
255
247
await page . waitForTimeout ( 100 ) ;
256
248
257
- const secondStashFileText = await page
258
- . locator ( 'pre' )
259
- . filter ( { hasText : 'This is some dirty changes' } ) ;
249
+ const secondStashFileText = page . getByText ( 'This is some dirty changes' ) ;
260
250
261
- await expect . soft ( await secondStashFileText . count ( ) ) . toBe ( 1 ) ;
251
+ await expect . soft ( secondStashFileText ) . toHaveCount ( 1 ) ;
262
252
263
253
// See if the nStashes remains the same
264
254
@@ -267,7 +257,7 @@ test.describe('Git Stash Commands', () => {
267
257
return element && ! ( element . textContent ?? '' ) . includes ( '(2)' ) ;
268
258
} ) ;
269
259
270
- const numberOfStashes = await page . locator ( '[data-test-id="num-stashes"]' ) ;
271
- await expect ( await numberOfStashes . innerText ( ) ) . toBe ( '(1)' ) ;
260
+ const numberOfStashes = page . locator ( '[data-test-id="num-stashes"]' ) ;
261
+ await expect ( numberOfStashes ) . toHaveText ( '(1)' ) ;
272
262
} ) ;
273
263
} ) ;
0 commit comments