@@ -159,12 +159,14 @@ test.describe('Item', () => {
159
159
160
160
const firstTodo = page . getByTestId ( 'todo-item' ) . nth ( 0 ) ;
161
161
const secondTodo = page . getByTestId ( 'todo-item' ) . nth ( 1 ) ;
162
- await firstTodo . getByRole ( 'checkbox' ) . check ( ) ;
162
+ const firstTodoCheckbox = firstTodo . getByRole ( 'checkbox' ) ;
163
+
164
+ await firstTodoCheckbox . check ( ) ;
163
165
await expect ( firstTodo ) . toHaveClass ( 'completed' ) ;
164
166
await expect ( secondTodo ) . not . toHaveClass ( 'completed' ) ;
165
167
await checkNumberOfCompletedTodosInLocalStorage ( page , 1 ) ;
166
168
167
- await firstTodo . getByRole ( 'checkbox' ) . uncheck ( ) ;
169
+ await firstTodoCheckbox . uncheck ( ) ;
168
170
await expect ( firstTodo ) . not . toHaveClass ( 'completed' ) ;
169
171
await expect ( secondTodo ) . not . toHaveClass ( 'completed' ) ;
170
172
await checkNumberOfCompletedTodosInLocalStorage ( page , 0 ) ;
@@ -311,8 +313,10 @@ test.describe('Persistence', () => {
311
313
}
312
314
313
315
const todoItems = page . getByTestId ( 'todo-item' ) ;
314
- await todoItems . nth ( 0 ) . getByRole ( 'checkbox' ) . check ( ) ;
316
+ const firstTodoCheck = todoItems . nth ( 0 ) . getByRole ( 'checkbox' ) ;
317
+ await firstTodoCheck . check ( ) ;
315
318
await expect ( todoItems ) . toHaveText ( [ TODO_ITEMS [ 0 ] , TODO_ITEMS [ 1 ] ] ) ;
319
+ await expect ( firstTodoCheck ) . toBeChecked ( ) ;
316
320
await expect ( todoItems ) . toHaveClass ( [ 'completed' , '' ] ) ;
317
321
318
322
// Ensure there is 1 completed item.
@@ -321,6 +325,7 @@ test.describe('Persistence', () => {
321
325
// Now reload.
322
326
await page . reload ( ) ;
323
327
await expect ( todoItems ) . toHaveText ( [ TODO_ITEMS [ 0 ] , TODO_ITEMS [ 1 ] ] ) ;
328
+ await expect ( firstTodoCheck ) . toBeChecked ( ) ;
324
329
await expect ( todoItems ) . toHaveClass ( [ 'completed' , '' ] ) ;
325
330
} ) ;
326
331
} ) ;
0 commit comments