-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpom.spec.ts
69 lines (62 loc) · 2.7 KB
/
pom.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import {test, expect} from '@playwright/test';
import {TodoPage} from './todoPage.pom';
test.describe('ToDo App', () => {
test('should display zero initial items', async ({page}) => {
const todoPage = new TodoPage(page);
await todoPage.goto();
await expect(todoPage.listItems).toHaveCount(0);
});
test('should be able to add new items', async ({page}) => {
const todoPage = new TodoPage(page);
await todoPage.goto();
await todoPage.addItem('Example #1');
await todoPage.addItem('Example #2');
await expect(todoPage.listItems).toHaveText(['Example #1', 'Example #2']);
});
test('should be able to mark items as completed', async ({page}) => {
const todoPage = new TodoPage(page);
await todoPage.goto();
await todoPage.addItem('Example #1');
const firstListItem = todoPage.listItems.first();
await expect(firstListItem).not.toHaveClass('completed');
await firstListItem.locator('.toggle').check();
await expect(firstListItem).toHaveClass('completed');
});
test('should still show the items after a page reload', async ({page}) => {
const todoPage = new TodoPage(page);
await todoPage.goto();
await todoPage.addItem('Example #1');
await expect(todoPage.listItems).toHaveText(['Example #1']);
await page.reload();
await expect(todoPage.listItems).toHaveText(['Example #1']);
});
test('should be able to filter by uncompleted items', async ({page}) => {
const todoPage = new TodoPage(page);
await todoPage.goto();
await todoPage.addItem('Example #1');
await todoPage.addItem('Example #2');
await todoPage.addItem('Example #3');
await todoPage.listItems.last().locator('.toggle').check();
await todoPage.filterByActiveItemsButton.click();
await expect(todoPage.listItems).toHaveText(['Example #1', 'Example #2']);
});
test('should be able to filter by completed items', async ({page}) => {
const todoPage = new TodoPage(page);
await todoPage.goto();
await todoPage.addItem('Example #1');
await todoPage.addItem('Example #2');
await todoPage.addItem('Example #3');
await todoPage.listItems.last().locator('.toggle').check();
await todoPage.filterByCompletedItemsButton.click();
await expect(todoPage.listItems).toHaveText(['Example #3']);
});
test('should be able to delete completed items', async ({page}) => {
const todoPage = new TodoPage(page);
await todoPage.goto();
await todoPage.addItem('Example #1');
await todoPage.listItems.last().locator('.toggle').check();
await expect(todoPage.listItems).toHaveText(['Example #1']);
await todoPage.listItems.first().locator('button.destroy').click();
await expect(todoPage.listItems).toHaveText([]);
});
});