1
0
mirror of https://github.com/morris/vanilla-todo.git synced 2025-08-30 17:19:46 +02:00

add tests for custom lists

This commit is contained in:
Morris Brodersen
2023-11-24 17:39:35 +01:00
parent 7c9dc91663
commit 9e7915c296
2 changed files with 50 additions and 6 deletions

View File

@@ -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!');
});

View File

@@ -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!',
);
});