diff --git a/test/e2e/addCustomList.test.mjs b/test/e2e/addCustomList.test.mjs new file mode 100644 index 0000000..b2a1141 --- /dev/null +++ b/test/e2e/addCustomList.test.mjs @@ -0,0 +1,31 @@ +import { expect, test } from '@playwright/test'; + +test('Add custom to-do list', async ({ page }) => { + await page.goto('http://localhost:8080'); + + const add = page.locator('.todo-frame.-custom .add'); + await add.click(); + + const title = page.locator('.todo-custom-list > .header > .title'); + await expect(title).toHaveText('...'); +}); + +test('Edit custom to-do list title (Enter)', async ({ page }) => { + await page.goto('http://localhost:8080'); + + const add = page.locator('.todo-frame.-custom .add'); + await add.click(); + + const title = page.locator('.todo-custom-list > .header > .title'); + await title.click(); + + const input = page.locator('.todo-custom-list > .header > .form > .input'); + + await expect(input).toBeVisible(); + await expect(input).toBeFocused(); + + await input.fill('Hello, world!'); + await page.keyboard.press('Enter'); + + await expect(title).toHaveText('Hello, world!'); +}); diff --git a/test/e2e/addItem.test.mjs b/test/e2e/addItem.test.mjs index 99f5141..8b723b8 100644 --- a/test/e2e/addItem.test.mjs +++ b/test/e2e/addItem.test.mjs @@ -1,11 +1,11 @@ import { expect, test } from '@playwright/test'; -test("Add item to today's todo list (Enter)", async ({ page }) => { +test("Add item to today's to-do list (Enter)", async ({ page }) => { await page.goto('http://localhost:8080'); - const input = page.locator('.-today .todo-item-input > input').filter(); + const input = page.locator('.-today .todo-item-input > input'); await input.focus(); - await input.type('Hello, world!'); + await input.fill('Hello, world!'); await page.keyboard.press('Enter'); await expect(page.locator('.-today .todo-item > .label')).toHaveText( @@ -13,15 +13,28 @@ test("Add item to today's todo list (Enter)", async ({ page }) => { ); }); -test("Add item to today's todo list (click)", async ({ page }) => { +test("Add item to today's to-do list (click)", async ({ page }) => { await page.goto('http://localhost:8080'); - const input = page.locator('.-today .todo-item-input > input').filter(); + const input = page.locator('.-today .todo-item-input > input'); await input.focus(); - await input.type('Hello, world!'); + await input.fill('Hello, world!'); await page.locator('.-today .todo-item-input > .save').click(); await expect(page.locator('.-today .todo-item > .label')).toHaveText( 'Hello, world!', ); }); + +test("Add item to today's to-do list (blur)", async ({ page }) => { + await page.goto('http://localhost:8080'); + + const input = page.locator('.-today .todo-item-input > input'); + await input.focus(); + await input.fill('Hello, world!'); + await page.locator('.-today').click(); + + await expect(page.locator('.-today .todo-item > .label')).toHaveText( + 'Hello, world!', + ); +});