2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* eslint-disable notice/notice */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-09 18:49:18 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { test, expect } from '@playwright/test';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import type { Page } from '@playwright/test';
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-14 20:29:56 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								test.describe.configure({ mode: 'parallel' });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.beforeEach(async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await page.goto('https://demo.playwright.dev/todomvc');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								const TODO_ITEMS = [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  'buy some cheese',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  'feed the cat',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  'book a doctors appointment'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.describe('New Todo', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to add todo items', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // create a new todo locator
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const newTodo = page.getByPlaceholder('What needs to be done?');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Create 1st todo.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await newTodo.fill(TODO_ITEMS[0]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Make sure the list only has one todo item.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-title')).toHaveText([
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[0]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Create 2nd todo.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await newTodo.fill(TODO_ITEMS[1]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Make sure the list now has two todo items.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-title')).toHaveText([
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[0],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[1]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 2);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should clear text input field when an item is added', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // create a new todo locator
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const newTodo = page.getByPlaceholder('What needs to be done?');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Create one todo item.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await newTodo.fill(TODO_ITEMS[0]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Check that input is empty.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(newTodo).toBeEmpty();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should append new items to the bottom of the list', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Create 3 items.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await createDefaultTodos(page);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Check test using different methods.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByText('3 items left')).toBeVisible();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-count')).toHaveText('3 items left');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-count')).toContainText('3');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-count')).toHaveText(/3/);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Check all items in one call.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-title')).toHaveText(TODO_ITEMS);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 3);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should show #main and #footer when items added', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // create a new todo locator
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const newTodo = page.getByPlaceholder('What needs to be done?');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.fill(TODO_ITEMS[0]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.locator('.main')).toBeVisible();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.locator('.footer')).toBeVisible();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.describe('Mark all as completed', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test.beforeEach(async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await createDefaultTodos(page);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 3);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test.afterEach(async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 3);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to mark all items as completed', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Complete all todos.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await page.getByLabel('Mark all as complete').check();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Ensure all todos have 'completed' class.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveClass(['completed', 'completed', 'completed']);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 3);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to clear the complete state of all items', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const toggleAll = page.getByLabel('Mark all as complete');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Check and then immediately uncheck.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await toggleAll.check();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await toggleAll.uncheck();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Should be no completed classes.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveClass(['', '', '']);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('complete all checkbox should update state when items are completed / cleared', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const toggleAll = page.getByLabel('Mark all as complete');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await toggleAll.check();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(toggleAll).toBeChecked();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 3);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Uncheck first todo.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const firstTodo = page.getByTestId('todo-item').nth(0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await firstTodo.getByRole('checkbox').uncheck();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Reuse toggleAll locator and make sure its not checked.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(toggleAll).not.toBeChecked();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await firstTodo.getByRole('checkbox').check();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 3);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Assert the toggle all is checked again.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(toggleAll).toBeChecked();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.describe('Item', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to mark items as complete', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // create a new todo locator
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const newTodo = page.getByPlaceholder('What needs to be done?');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Create two items.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (const item of TODO_ITEMS.slice(0, 2)) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await newTodo.fill(item);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await newTodo.press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Check first item.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const firstTodo = page.getByTestId('todo-item').nth(0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await firstTodo.getByRole('checkbox').check();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(firstTodo).toHaveClass('completed');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Check second item.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const secondTodo = page.getByTestId('todo-item').nth(1);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(secondTodo).not.toHaveClass('completed');
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await secondTodo.getByRole('checkbox').check();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Assert completed class.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(firstTodo).toHaveClass('completed');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(secondTodo).toHaveClass('completed');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to un-mark items as complete', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // create a new todo locator
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const newTodo = page.getByPlaceholder('What needs to be done?');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Create two items.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (const item of TODO_ITEMS.slice(0, 2)) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await newTodo.fill(item);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await newTodo.press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const firstTodo = page.getByTestId('todo-item').nth(0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const secondTodo = page.getByTestId('todo-item').nth(1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await firstTodo.getByRole('checkbox').check();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(firstTodo).toHaveClass('completed');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(secondTodo).not.toHaveClass('completed');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await firstTodo.getByRole('checkbox').uncheck();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(firstTodo).not.toHaveClass('completed');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(secondTodo).not.toHaveClass('completed');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 0);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to edit an item', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await createDefaultTodos(page);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const todoItems = page.getByTestId('todo-item');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const secondTodo = todoItems.nth(1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await secondTodo.dblclick();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(secondTodo.getByRole('textbox', { name: 'Edit' })).toHaveValue(TODO_ITEMS[1]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await secondTodo.getByRole('textbox', { name: 'Edit' }).fill('buy some sausages');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await secondTodo.getByRole('textbox', { name: 'Edit' }).press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Explicitly assert the new text value.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveText([
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[0],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      'buy some sausages',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[2]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkTodosInLocalStorage(page, 'buy some sausages');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.describe('Editing', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test.beforeEach(async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await createDefaultTodos(page);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 3);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should hide other controls when editing', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const todoItem = page.getByTestId('todo-item').nth(1);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItem.dblclick();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItem.getByRole('checkbox')).not.toBeVisible();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItem.locator('label', {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      hasText: TODO_ITEMS[1],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    })).not.toBeVisible();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 3);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should save edits on blur', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const todoItems = page.getByTestId('todo-item');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).dblclick();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('buy some sausages');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).dispatchEvent('blur');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveText([
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[0],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      'buy some sausages',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[2],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkTodosInLocalStorage(page, 'buy some sausages');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should trim entered text', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const todoItems = page.getByTestId('todo-item');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).dblclick();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('    buy some sausages    ');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveText([
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[0],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      'buy some sausages',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[2],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkTodosInLocalStorage(page, 'buy some sausages');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should remove the item if an empty text string was entered', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const todoItems = page.getByTestId('todo-item');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).dblclick();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveText([
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[0],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      TODO_ITEMS[2],
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should cancel edits on escape', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const todoItems = page.getByTestId('todo-item');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).dblclick();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('buy some sausages');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Escape');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveText(TODO_ITEMS);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.describe('Counter', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should display the current number of todo items', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // create a new todo locator
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const newTodo = page.getByPlaceholder('What needs to be done?');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await newTodo.fill(TODO_ITEMS[0]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.press('Enter');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-count')).toContainText('1');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.fill(TODO_ITEMS[1]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.press('Enter');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-count')).toContainText('2');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfTodosInLocalStorage(page, 2);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.describe('Clear completed button', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test.beforeEach(async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await createDefaultTodos(page);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should display the correct text', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.locator('.todo-list li .toggle').first().check();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByRole('button', { name: 'Clear completed' })).toBeVisible();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should remove completed items when clicked', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const todoItems = page.getByTestId('todo-item');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(1).getByRole('checkbox').check();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('button', { name: 'Clear completed' }).click();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveCount(2);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should be hidden when there are no items that are completed', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.locator('.todo-list li .toggle').first().check();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('button', { name: 'Clear completed' }).click();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByRole('button', { name: 'Clear completed' })).toBeHidden();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.describe('Persistence', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should persist its data', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    // create a new todo locator
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    const newTodo = page.getByPlaceholder('What needs to be done?');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    for (const item of TODO_ITEMS.slice(0, 2)) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await newTodo.fill(item);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await newTodo.press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    const todoItems = page.getByTestId('todo-item');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await todoItems.nth(0).getByRole('checkbox').check();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[1]]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveClass(['completed', '']);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Ensure there is 1 completed item.
							 | 
						
					
						
							
								
									
										
										
										
											2022-10-05 13:40:46 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 1);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Now reload.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.reload();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[1]]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(todoItems).toHaveClass(['completed', '']);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								test.describe('Routing', () => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test.beforeEach(async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await createDefaultTodos(page);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // make sure the app had a chance to save updated todos in storage
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // before navigating to a new view, otherwise the items can get lost :(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // in some frameworks like Durandal
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkTodosInLocalStorage(page, TODO_ITEMS[0]);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to display active items', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.locator('.todo-list li .toggle').nth(1).check();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 1);
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('link', { name: 'Active' }).click();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveCount(2);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should respect the back button', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.locator('.todo-list li .toggle').nth(1).check();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 1);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await test.step('Showing all items', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await page.getByRole('link', { name: 'All' }).click();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await expect(page.getByTestId('todo-item')).toHaveCount(3);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await test.step('Showing active items', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await page.getByRole('link', { name: 'Active' }).click();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await test.step('Showing completed items', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await page.getByRole('link', { name: 'Completed' }).click();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveCount(1);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.goBack();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveCount(2);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.goBack();
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveCount(3);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to display completed items', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.locator('.todo-list li .toggle').nth(1).check();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 1);
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('link', { name: 'Completed' }).click();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveCount(1);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should allow me to display all items', async ({ page }) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.locator('.todo-list li .toggle').nth(1).check();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await checkNumberOfCompletedTodosInLocalStorage(page, 1);
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('link', { name: 'Active' }).click();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('link', { name: 'Completed' }).click();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('link', { name: 'All' }).click();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByTestId('todo-item')).toHaveCount(3);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  test('should highlight the currently applied filter', async ({ page }) => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByRole('link', { name: 'All' })).toHaveClass('selected');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('link', { name: 'Active' }).click();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Page change - active items.
							 | 
						
					
						
							
								
									
										
										
										
											2023-01-09 18:49:18 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByRole('link', { name: 'Active' })).toHaveClass('selected');
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await page.getByRole('link', { name: 'Completed' }).click();
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    // Page change - completed items.
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await expect(page.getByRole('link', { name: 'Completed' })).toHaveClass('selected');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								async function createDefaultTodos(page) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  // create a new todo locator
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const newTodo = page.getByPlaceholder('What needs to be done?');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  for (const item of TODO_ITEMS) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    await newTodo.fill(item);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    await newTodo.press('Enter');
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								async function checkNumberOfTodosInLocalStorage(page: Page, expected: number) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return await page.waitForFunction(e => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return JSON.parse(localStorage['react-todos']).length === e;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }, expected);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								async function checkNumberOfCompletedTodosInLocalStorage(page: Page, expected: number) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return await page.waitForFunction(e => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return JSON.parse(localStorage['react-todos']).filter((todo: any) => todo.completed).length === e;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }, expected);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								async function checkTodosInLocalStorage(page: Page, title: string) {
							 | 
						
					
						
							
								
									
										
										
										
											2022-11-16 22:46:03 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  return await page.waitForFunction(t => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    return JSON.parse(localStorage['react-todos']).map((todo: any) => todo.title).includes(t);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }, title);
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-07 12:35:38 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |