xpine 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tests/e2e/alpine.spec.ts +0 -14
- package/tests/e2e/app-build.spec.ts +0 -73
- package/tests/e2e/spa.spec.ts +0 -23
- package/tests/e2e/tests-examples/demo-todo-app.spec.ts +0 -437
- package/tests/eslint.config.mjs +0 -27
- package/tests/package-lock.json +0 -8941
- package/tests/package.json +0 -89
- package/tests/playwright.config.ts +0 -81
- package/tests/tsconfig.json +0 -46
- package/tests/xpine.config.mjs +0 -1
package/package.json
CHANGED
package/tests/e2e/alpine.spec.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { test, expect } from '@playwright/test';
|
|
2
|
-
import { url } from '../playwright.config';
|
|
3
|
-
|
|
4
|
-
test('pathD button changes color on button click', async ({ page }) => {
|
|
5
|
-
await page.goto(url + '/my-path-a2/my-path-b2/my-path-c2/2');
|
|
6
|
-
const button = page.getByTestId('path-d-button');
|
|
7
|
-
const initialStyle = await button.getAttribute('style');
|
|
8
|
-
expect(initialStyle).toEqual('background-color: red');
|
|
9
|
-
await test.step('click button', async () => {
|
|
10
|
-
await button.click();
|
|
11
|
-
const newStyle = await button.getAttribute('style');
|
|
12
|
-
expect(newStyle).toEqual('background-color: blue');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { test, expect } from '@playwright/test';
|
|
2
|
-
import { config } from 'xpine';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { url } from '../playwright.config';
|
|
6
|
-
|
|
7
|
-
test('app builds', async ({ page }) => {
|
|
8
|
-
await page.goto(url);
|
|
9
|
-
await expect(page.getByTestId('hello-world')).toHaveText('Hello world');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('home page uses same file wrapper', async ({ page }) => {
|
|
13
|
-
await page.goto(url);
|
|
14
|
-
await expect(page.getByTestId('home-page-wrapper')).toBeAttached();
|
|
15
|
-
expect(await page.getByTestId('base-config').count()).toEqual(0);
|
|
16
|
-
const title = await page.title();
|
|
17
|
-
expect(title).toEqual('Home page');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('same dir +config uses config', async ({ page }) => {
|
|
21
|
-
await page.goto(url + '/with-same-dir-wrapper');
|
|
22
|
-
await expect(page.getByTestId('base-config')).toBeAttached();
|
|
23
|
-
const title = await page.title();
|
|
24
|
-
expect(title).toEqual('Default title');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('dynamic paths with data in +config - path c', async ({ page }) => {
|
|
28
|
-
const result = await page.goto(url + '/my-path-a/my-path-b/1');
|
|
29
|
-
await expect(page.getByTestId('path-c-data')).toHaveText('sunt aut facere repellat provident occaecati excepturi optio reprehenderit');
|
|
30
|
-
await expect(page.getByTestId('path-c-patha')).toHaveText('my-path-a');
|
|
31
|
-
await expect(page.getByTestId('path-c-pathb')).toHaveText('my-path-b');
|
|
32
|
-
await expect(page.getByTestId('base-config')).toBeAttached();
|
|
33
|
-
const body = (await result.body()).toString();
|
|
34
|
-
expect(body).toContain('<!-- static -->');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('dynamic inner paths with config in the component - path d', async ({ page }) => {
|
|
38
|
-
const result = await page.goto(url + '/my-path-a2/my-path-b2/my-path-c2/2');
|
|
39
|
-
await expect(page.getByTestId('path-d-data')).toHaveText('qui est esse');
|
|
40
|
-
await expect(page.getByTestId('path-d-patha')).toHaveText('my-path-a2');
|
|
41
|
-
await expect(page.getByTestId('path-d-pathb')).toHaveText('my-path-b2');
|
|
42
|
-
await expect(page.getByTestId('path-d-pathc')).toHaveText('my-path-c2');
|
|
43
|
-
await expect(page.getByTestId('base-config')).toBeAttached();
|
|
44
|
-
const body = (await result.body()).toString();
|
|
45
|
-
expect(body).toContain('<!-- static -->');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('static paths exist for dynamic page', async () => {
|
|
49
|
-
expect(fs.existsSync(path.join(config.distDir, './pages/my-path-a2/my-path-b2/my-path-c2/2/index.html'))).toEqual(true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('boolean static path', async ({ page }) => {
|
|
53
|
-
const result = await page.goto(url + '/boolean-static-path');
|
|
54
|
-
const body = (await result.body()).toString();
|
|
55
|
-
expect(body).toContain('<!-- static -->');
|
|
56
|
-
|
|
57
|
-
expect(fs.existsSync(path.join(config.distDir, './pages/boolean-static-path/index.html'))).toEqual(true);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('inner static path override', async ({ page }) => {
|
|
61
|
-
expect(fs.existsSync(path.join(config.distDir, './pages/base-static-path/index.html'))).toEqual(true);
|
|
62
|
-
expect(fs.existsSync(path.join(config.distDir, './pages/base-static-path/non-static-path/index.html'))).toEqual(false);
|
|
63
|
-
|
|
64
|
-
const staticResult = await page.goto(url + '/base-static-path');
|
|
65
|
-
await expect(page.getByTestId('base-static-path')).toHaveText('My title');
|
|
66
|
-
const staticBody = (await staticResult.body()).toString();
|
|
67
|
-
expect(staticBody).toContain('<!-- static -->');
|
|
68
|
-
|
|
69
|
-
const nonStaticResult = await page.goto(url + '/base-static-path/non-static-path');
|
|
70
|
-
await expect(page.getByTestId('non-static-path')).toHaveText('My title');
|
|
71
|
-
const nonStaticBody = (await nonStaticResult.body()).toString();
|
|
72
|
-
expect(nonStaticBody).not.toContain('<!-- static -->');
|
|
73
|
-
});
|
package/tests/e2e/spa.spec.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { test, expect } from '@playwright/test';
|
|
2
|
-
import { url } from '../playwright.config';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
test('sticky nav creates request for page contents and does not reload page', async ({ page }) => {
|
|
6
|
-
await page.goto(url);
|
|
7
|
-
const link = page.getByTestId('navbar-boolean-static-path');
|
|
8
|
-
const navbarNow = await page.getByTestId('navbar-now').getAttribute('data-now');
|
|
9
|
-
await link.click();
|
|
10
|
-
await page.waitForURL('**/boolean-static-path');
|
|
11
|
-
const newNavbarNow = await page.getByTestId('navbar-now').getAttribute('data-now');
|
|
12
|
-
expect(navbarNow).toEqual(newNavbarNow);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('non-spa request for page contents reloads page', async ({ page }) => {
|
|
16
|
-
await page.goto(url);
|
|
17
|
-
const link = page.getByTestId('navbar-non-static-path-non-spa');
|
|
18
|
-
const navbarNow = await page.getByTestId('navbar-now').getAttribute('data-now');
|
|
19
|
-
await link.click();
|
|
20
|
-
await page.waitForURL('**/base-static-path/non-static-path');
|
|
21
|
-
const newNavbarNow = await page.getByTestId('navbar-now').getAttribute('data-now');
|
|
22
|
-
expect(navbarNow).not.toEqual(newNavbarNow);
|
|
23
|
-
});
|
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
// import { test, expect, type Page } from '@playwright/test';
|
|
2
|
-
|
|
3
|
-
// test.beforeEach(async ({ page }) => {
|
|
4
|
-
// await page.goto('https://demo.playwright.dev/todomvc');
|
|
5
|
-
// });
|
|
6
|
-
|
|
7
|
-
// const TODO_ITEMS = [
|
|
8
|
-
// 'buy some cheese',
|
|
9
|
-
// 'feed the cat',
|
|
10
|
-
// 'book a doctors appointment'
|
|
11
|
-
// ] as const;
|
|
12
|
-
|
|
13
|
-
// test.describe('New Todo', () => {
|
|
14
|
-
// test('should allow me to add todo items', async ({ page }) => {
|
|
15
|
-
// // create a new todo locator
|
|
16
|
-
// const newTodo = page.getByPlaceholder('What needs to be done?');
|
|
17
|
-
|
|
18
|
-
// // Create 1st todo.
|
|
19
|
-
// await newTodo.fill(TODO_ITEMS[0]);
|
|
20
|
-
// await newTodo.press('Enter');
|
|
21
|
-
|
|
22
|
-
// // Make sure the list only has one todo item.
|
|
23
|
-
// await expect(page.getByTestId('todo-title')).toHaveText([
|
|
24
|
-
// TODO_ITEMS[0]
|
|
25
|
-
// ]);
|
|
26
|
-
|
|
27
|
-
// // Create 2nd todo.
|
|
28
|
-
// await newTodo.fill(TODO_ITEMS[1]);
|
|
29
|
-
// await newTodo.press('Enter');
|
|
30
|
-
|
|
31
|
-
// // Make sure the list now has two todo items.
|
|
32
|
-
// await expect(page.getByTestId('todo-title')).toHaveText([
|
|
33
|
-
// TODO_ITEMS[0],
|
|
34
|
-
// TODO_ITEMS[1]
|
|
35
|
-
// ]);
|
|
36
|
-
|
|
37
|
-
// await checkNumberOfTodosInLocalStorage(page, 2);
|
|
38
|
-
// });
|
|
39
|
-
|
|
40
|
-
// test('should clear text input field when an item is added', async ({ page }) => {
|
|
41
|
-
// // create a new todo locator
|
|
42
|
-
// const newTodo = page.getByPlaceholder('What needs to be done?');
|
|
43
|
-
|
|
44
|
-
// // Create one todo item.
|
|
45
|
-
// await newTodo.fill(TODO_ITEMS[0]);
|
|
46
|
-
// await newTodo.press('Enter');
|
|
47
|
-
|
|
48
|
-
// // Check that input is empty.
|
|
49
|
-
// await expect(newTodo).toBeEmpty();
|
|
50
|
-
// await checkNumberOfTodosInLocalStorage(page, 1);
|
|
51
|
-
// });
|
|
52
|
-
|
|
53
|
-
// test('should append new items to the bottom of the list', async ({ page }) => {
|
|
54
|
-
// // Create 3 items.
|
|
55
|
-
// await createDefaultTodos(page);
|
|
56
|
-
|
|
57
|
-
// // create a todo count locator
|
|
58
|
-
// const todoCount = page.getByTestId('todo-count')
|
|
59
|
-
|
|
60
|
-
// // Check test using different methods.
|
|
61
|
-
// await expect(page.getByText('3 items left')).toBeVisible();
|
|
62
|
-
// await expect(todoCount).toHaveText('3 items left');
|
|
63
|
-
// await expect(todoCount).toContainText('3');
|
|
64
|
-
// await expect(todoCount).toHaveText(/3/);
|
|
65
|
-
|
|
66
|
-
// // Check all items in one call.
|
|
67
|
-
// await expect(page.getByTestId('todo-title')).toHaveText(TODO_ITEMS);
|
|
68
|
-
// await checkNumberOfTodosInLocalStorage(page, 3);
|
|
69
|
-
// });
|
|
70
|
-
// });
|
|
71
|
-
|
|
72
|
-
// test.describe('Mark all as completed', () => {
|
|
73
|
-
// test.beforeEach(async ({ page }) => {
|
|
74
|
-
// await createDefaultTodos(page);
|
|
75
|
-
// await checkNumberOfTodosInLocalStorage(page, 3);
|
|
76
|
-
// });
|
|
77
|
-
|
|
78
|
-
// test.afterEach(async ({ page }) => {
|
|
79
|
-
// await checkNumberOfTodosInLocalStorage(page, 3);
|
|
80
|
-
// });
|
|
81
|
-
|
|
82
|
-
// test('should allow me to mark all items as completed', async ({ page }) => {
|
|
83
|
-
// // Complete all todos.
|
|
84
|
-
// await page.getByLabel('Mark all as complete').check();
|
|
85
|
-
|
|
86
|
-
// // Ensure all todos have 'completed' class.
|
|
87
|
-
// await expect(page.getByTestId('todo-item')).toHaveClass(['completed', 'completed', 'completed']);
|
|
88
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 3);
|
|
89
|
-
// });
|
|
90
|
-
|
|
91
|
-
// test('should allow me to clear the complete state of all items', async ({ page }) => {
|
|
92
|
-
// const toggleAll = page.getByLabel('Mark all as complete');
|
|
93
|
-
// // Check and then immediately uncheck.
|
|
94
|
-
// await toggleAll.check();
|
|
95
|
-
// await toggleAll.uncheck();
|
|
96
|
-
|
|
97
|
-
// // Should be no completed classes.
|
|
98
|
-
// await expect(page.getByTestId('todo-item')).toHaveClass(['', '', '']);
|
|
99
|
-
// });
|
|
100
|
-
|
|
101
|
-
// test('complete all checkbox should update state when items are completed / cleared', async ({ page }) => {
|
|
102
|
-
// const toggleAll = page.getByLabel('Mark all as complete');
|
|
103
|
-
// await toggleAll.check();
|
|
104
|
-
// await expect(toggleAll).toBeChecked();
|
|
105
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 3);
|
|
106
|
-
|
|
107
|
-
// // Uncheck first todo.
|
|
108
|
-
// const firstTodo = page.getByTestId('todo-item').nth(0);
|
|
109
|
-
// await firstTodo.getByRole('checkbox').uncheck();
|
|
110
|
-
|
|
111
|
-
// // Reuse toggleAll locator and make sure its not checked.
|
|
112
|
-
// await expect(toggleAll).not.toBeChecked();
|
|
113
|
-
|
|
114
|
-
// await firstTodo.getByRole('checkbox').check();
|
|
115
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 3);
|
|
116
|
-
|
|
117
|
-
// // Assert the toggle all is checked again.
|
|
118
|
-
// await expect(toggleAll).toBeChecked();
|
|
119
|
-
// });
|
|
120
|
-
// });
|
|
121
|
-
|
|
122
|
-
// test.describe('Item', () => {
|
|
123
|
-
|
|
124
|
-
// test('should allow me to mark items as complete', async ({ page }) => {
|
|
125
|
-
// // create a new todo locator
|
|
126
|
-
// const newTodo = page.getByPlaceholder('What needs to be done?');
|
|
127
|
-
|
|
128
|
-
// // Create two items.
|
|
129
|
-
// for (const item of TODO_ITEMS.slice(0, 2)) {
|
|
130
|
-
// await newTodo.fill(item);
|
|
131
|
-
// await newTodo.press('Enter');
|
|
132
|
-
// }
|
|
133
|
-
|
|
134
|
-
// // Check first item.
|
|
135
|
-
// const firstTodo = page.getByTestId('todo-item').nth(0);
|
|
136
|
-
// await firstTodo.getByRole('checkbox').check();
|
|
137
|
-
// await expect(firstTodo).toHaveClass('completed');
|
|
138
|
-
|
|
139
|
-
// // Check second item.
|
|
140
|
-
// const secondTodo = page.getByTestId('todo-item').nth(1);
|
|
141
|
-
// await expect(secondTodo).not.toHaveClass('completed');
|
|
142
|
-
// await secondTodo.getByRole('checkbox').check();
|
|
143
|
-
|
|
144
|
-
// // Assert completed class.
|
|
145
|
-
// await expect(firstTodo).toHaveClass('completed');
|
|
146
|
-
// await expect(secondTodo).toHaveClass('completed');
|
|
147
|
-
// });
|
|
148
|
-
|
|
149
|
-
// test('should allow me to un-mark items as complete', async ({ page }) => {
|
|
150
|
-
// // create a new todo locator
|
|
151
|
-
// const newTodo = page.getByPlaceholder('What needs to be done?');
|
|
152
|
-
|
|
153
|
-
// // Create two items.
|
|
154
|
-
// for (const item of TODO_ITEMS.slice(0, 2)) {
|
|
155
|
-
// await newTodo.fill(item);
|
|
156
|
-
// await newTodo.press('Enter');
|
|
157
|
-
// }
|
|
158
|
-
|
|
159
|
-
// const firstTodo = page.getByTestId('todo-item').nth(0);
|
|
160
|
-
// const secondTodo = page.getByTestId('todo-item').nth(1);
|
|
161
|
-
// const firstTodoCheckbox = firstTodo.getByRole('checkbox');
|
|
162
|
-
|
|
163
|
-
// await firstTodoCheckbox.check();
|
|
164
|
-
// await expect(firstTodo).toHaveClass('completed');
|
|
165
|
-
// await expect(secondTodo).not.toHaveClass('completed');
|
|
166
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 1);
|
|
167
|
-
|
|
168
|
-
// await firstTodoCheckbox.uncheck();
|
|
169
|
-
// await expect(firstTodo).not.toHaveClass('completed');
|
|
170
|
-
// await expect(secondTodo).not.toHaveClass('completed');
|
|
171
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 0);
|
|
172
|
-
// });
|
|
173
|
-
|
|
174
|
-
// test('should allow me to edit an item', async ({ page }) => {
|
|
175
|
-
// await createDefaultTodos(page);
|
|
176
|
-
|
|
177
|
-
// const todoItems = page.getByTestId('todo-item');
|
|
178
|
-
// const secondTodo = todoItems.nth(1);
|
|
179
|
-
// await secondTodo.dblclick();
|
|
180
|
-
// await expect(secondTodo.getByRole('textbox', { name: 'Edit' })).toHaveValue(TODO_ITEMS[1]);
|
|
181
|
-
// await secondTodo.getByRole('textbox', { name: 'Edit' }).fill('buy some sausages');
|
|
182
|
-
// await secondTodo.getByRole('textbox', { name: 'Edit' }).press('Enter');
|
|
183
|
-
|
|
184
|
-
// // Explicitly assert the new text value.
|
|
185
|
-
// await expect(todoItems).toHaveText([
|
|
186
|
-
// TODO_ITEMS[0],
|
|
187
|
-
// 'buy some sausages',
|
|
188
|
-
// TODO_ITEMS[2]
|
|
189
|
-
// ]);
|
|
190
|
-
// await checkTodosInLocalStorage(page, 'buy some sausages');
|
|
191
|
-
// });
|
|
192
|
-
// });
|
|
193
|
-
|
|
194
|
-
// test.describe('Editing', () => {
|
|
195
|
-
// test.beforeEach(async ({ page }) => {
|
|
196
|
-
// await createDefaultTodos(page);
|
|
197
|
-
// await checkNumberOfTodosInLocalStorage(page, 3);
|
|
198
|
-
// });
|
|
199
|
-
|
|
200
|
-
// test('should hide other controls when editing', async ({ page }) => {
|
|
201
|
-
// const todoItem = page.getByTestId('todo-item').nth(1);
|
|
202
|
-
// await todoItem.dblclick();
|
|
203
|
-
// await expect(todoItem.getByRole('checkbox')).not.toBeVisible();
|
|
204
|
-
// await expect(todoItem.locator('label', {
|
|
205
|
-
// hasText: TODO_ITEMS[1],
|
|
206
|
-
// })).not.toBeVisible();
|
|
207
|
-
// await checkNumberOfTodosInLocalStorage(page, 3);
|
|
208
|
-
// });
|
|
209
|
-
|
|
210
|
-
// test('should save edits on blur', async ({ page }) => {
|
|
211
|
-
// const todoItems = page.getByTestId('todo-item');
|
|
212
|
-
// await todoItems.nth(1).dblclick();
|
|
213
|
-
// await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('buy some sausages');
|
|
214
|
-
// await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).dispatchEvent('blur');
|
|
215
|
-
|
|
216
|
-
// await expect(todoItems).toHaveText([
|
|
217
|
-
// TODO_ITEMS[0],
|
|
218
|
-
// 'buy some sausages',
|
|
219
|
-
// TODO_ITEMS[2],
|
|
220
|
-
// ]);
|
|
221
|
-
// await checkTodosInLocalStorage(page, 'buy some sausages');
|
|
222
|
-
// });
|
|
223
|
-
|
|
224
|
-
// test('should trim entered text', async ({ page }) => {
|
|
225
|
-
// const todoItems = page.getByTestId('todo-item');
|
|
226
|
-
// await todoItems.nth(1).dblclick();
|
|
227
|
-
// await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill(' buy some sausages ');
|
|
228
|
-
// await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Enter');
|
|
229
|
-
|
|
230
|
-
// await expect(todoItems).toHaveText([
|
|
231
|
-
// TODO_ITEMS[0],
|
|
232
|
-
// 'buy some sausages',
|
|
233
|
-
// TODO_ITEMS[2],
|
|
234
|
-
// ]);
|
|
235
|
-
// await checkTodosInLocalStorage(page, 'buy some sausages');
|
|
236
|
-
// });
|
|
237
|
-
|
|
238
|
-
// test('should remove the item if an empty text string was entered', async ({ page }) => {
|
|
239
|
-
// const todoItems = page.getByTestId('todo-item');
|
|
240
|
-
// await todoItems.nth(1).dblclick();
|
|
241
|
-
// await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('');
|
|
242
|
-
// await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Enter');
|
|
243
|
-
|
|
244
|
-
// await expect(todoItems).toHaveText([
|
|
245
|
-
// TODO_ITEMS[0],
|
|
246
|
-
// TODO_ITEMS[2],
|
|
247
|
-
// ]);
|
|
248
|
-
// });
|
|
249
|
-
|
|
250
|
-
// test('should cancel edits on escape', async ({ page }) => {
|
|
251
|
-
// const todoItems = page.getByTestId('todo-item');
|
|
252
|
-
// await todoItems.nth(1).dblclick();
|
|
253
|
-
// await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).fill('buy some sausages');
|
|
254
|
-
// await todoItems.nth(1).getByRole('textbox', { name: 'Edit' }).press('Escape');
|
|
255
|
-
// await expect(todoItems).toHaveText(TODO_ITEMS);
|
|
256
|
-
// });
|
|
257
|
-
// });
|
|
258
|
-
|
|
259
|
-
// test.describe('Counter', () => {
|
|
260
|
-
// test('should display the current number of todo items', async ({ page }) => {
|
|
261
|
-
// // create a new todo locator
|
|
262
|
-
// const newTodo = page.getByPlaceholder('What needs to be done?');
|
|
263
|
-
|
|
264
|
-
// // create a todo count locator
|
|
265
|
-
// const todoCount = page.getByTestId('todo-count')
|
|
266
|
-
|
|
267
|
-
// await newTodo.fill(TODO_ITEMS[0]);
|
|
268
|
-
// await newTodo.press('Enter');
|
|
269
|
-
|
|
270
|
-
// await expect(todoCount).toContainText('1');
|
|
271
|
-
|
|
272
|
-
// await newTodo.fill(TODO_ITEMS[1]);
|
|
273
|
-
// await newTodo.press('Enter');
|
|
274
|
-
// await expect(todoCount).toContainText('2');
|
|
275
|
-
|
|
276
|
-
// await checkNumberOfTodosInLocalStorage(page, 2);
|
|
277
|
-
// });
|
|
278
|
-
// });
|
|
279
|
-
|
|
280
|
-
// test.describe('Clear completed button', () => {
|
|
281
|
-
// test.beforeEach(async ({ page }) => {
|
|
282
|
-
// await createDefaultTodos(page);
|
|
283
|
-
// });
|
|
284
|
-
|
|
285
|
-
// test('should display the correct text', async ({ page }) => {
|
|
286
|
-
// await page.locator('.todo-list li .toggle').first().check();
|
|
287
|
-
// await expect(page.getByRole('button', { name: 'Clear completed' })).toBeVisible();
|
|
288
|
-
// });
|
|
289
|
-
|
|
290
|
-
// test('should remove completed items when clicked', async ({ page }) => {
|
|
291
|
-
// const todoItems = page.getByTestId('todo-item');
|
|
292
|
-
// await todoItems.nth(1).getByRole('checkbox').check();
|
|
293
|
-
// await page.getByRole('button', { name: 'Clear completed' }).click();
|
|
294
|
-
// await expect(todoItems).toHaveCount(2);
|
|
295
|
-
// await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]);
|
|
296
|
-
// });
|
|
297
|
-
|
|
298
|
-
// test('should be hidden when there are no items that are completed', async ({ page }) => {
|
|
299
|
-
// await page.locator('.todo-list li .toggle').first().check();
|
|
300
|
-
// await page.getByRole('button', { name: 'Clear completed' }).click();
|
|
301
|
-
// await expect(page.getByRole('button', { name: 'Clear completed' })).toBeHidden();
|
|
302
|
-
// });
|
|
303
|
-
// });
|
|
304
|
-
|
|
305
|
-
// test.describe('Persistence', () => {
|
|
306
|
-
// test('should persist its data', async ({ page }) => {
|
|
307
|
-
// // create a new todo locator
|
|
308
|
-
// const newTodo = page.getByPlaceholder('What needs to be done?');
|
|
309
|
-
|
|
310
|
-
// for (const item of TODO_ITEMS.slice(0, 2)) {
|
|
311
|
-
// await newTodo.fill(item);
|
|
312
|
-
// await newTodo.press('Enter');
|
|
313
|
-
// }
|
|
314
|
-
|
|
315
|
-
// const todoItems = page.getByTestId('todo-item');
|
|
316
|
-
// const firstTodoCheck = todoItems.nth(0).getByRole('checkbox');
|
|
317
|
-
// await firstTodoCheck.check();
|
|
318
|
-
// await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[1]]);
|
|
319
|
-
// await expect(firstTodoCheck).toBeChecked();
|
|
320
|
-
// await expect(todoItems).toHaveClass(['completed', '']);
|
|
321
|
-
|
|
322
|
-
// // Ensure there is 1 completed item.
|
|
323
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 1);
|
|
324
|
-
|
|
325
|
-
// // Now reload.
|
|
326
|
-
// await page.reload();
|
|
327
|
-
// await expect(todoItems).toHaveText([TODO_ITEMS[0], TODO_ITEMS[1]]);
|
|
328
|
-
// await expect(firstTodoCheck).toBeChecked();
|
|
329
|
-
// await expect(todoItems).toHaveClass(['completed', '']);
|
|
330
|
-
// });
|
|
331
|
-
// });
|
|
332
|
-
|
|
333
|
-
// test.describe('Routing', () => {
|
|
334
|
-
// test.beforeEach(async ({ page }) => {
|
|
335
|
-
// await createDefaultTodos(page);
|
|
336
|
-
// // make sure the app had a chance to save updated todos in storage
|
|
337
|
-
// // before navigating to a new view, otherwise the items can get lost :(
|
|
338
|
-
// // in some frameworks like Durandal
|
|
339
|
-
// await checkTodosInLocalStorage(page, TODO_ITEMS[0]);
|
|
340
|
-
// });
|
|
341
|
-
|
|
342
|
-
// test('should allow me to display active items', async ({ page }) => {
|
|
343
|
-
// const todoItem = page.getByTestId('todo-item');
|
|
344
|
-
// await page.getByTestId('todo-item').nth(1).getByRole('checkbox').check();
|
|
345
|
-
|
|
346
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 1);
|
|
347
|
-
// await page.getByRole('link', { name: 'Active' }).click();
|
|
348
|
-
// await expect(todoItem).toHaveCount(2);
|
|
349
|
-
// await expect(todoItem).toHaveText([TODO_ITEMS[0], TODO_ITEMS[2]]);
|
|
350
|
-
// });
|
|
351
|
-
|
|
352
|
-
// test('should respect the back button', async ({ page }) => {
|
|
353
|
-
// const todoItem = page.getByTestId('todo-item');
|
|
354
|
-
// await page.getByTestId('todo-item').nth(1).getByRole('checkbox').check();
|
|
355
|
-
|
|
356
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 1);
|
|
357
|
-
|
|
358
|
-
// await test.step('Showing all items', async () => {
|
|
359
|
-
// await page.getByRole('link', { name: 'All' }).click();
|
|
360
|
-
// await expect(todoItem).toHaveCount(3);
|
|
361
|
-
// });
|
|
362
|
-
|
|
363
|
-
// await test.step('Showing active items', async () => {
|
|
364
|
-
// await page.getByRole('link', { name: 'Active' }).click();
|
|
365
|
-
// });
|
|
366
|
-
|
|
367
|
-
// await test.step('Showing completed items', async () => {
|
|
368
|
-
// await page.getByRole('link', { name: 'Completed' }).click();
|
|
369
|
-
// });
|
|
370
|
-
|
|
371
|
-
// await expect(todoItem).toHaveCount(1);
|
|
372
|
-
// await page.goBack();
|
|
373
|
-
// await expect(todoItem).toHaveCount(2);
|
|
374
|
-
// await page.goBack();
|
|
375
|
-
// await expect(todoItem).toHaveCount(3);
|
|
376
|
-
// });
|
|
377
|
-
|
|
378
|
-
// test('should allow me to display completed items', async ({ page }) => {
|
|
379
|
-
// await page.getByTestId('todo-item').nth(1).getByRole('checkbox').check();
|
|
380
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 1);
|
|
381
|
-
// await page.getByRole('link', { name: 'Completed' }).click();
|
|
382
|
-
// await expect(page.getByTestId('todo-item')).toHaveCount(1);
|
|
383
|
-
// });
|
|
384
|
-
|
|
385
|
-
// test('should allow me to display all items', async ({ page }) => {
|
|
386
|
-
// await page.getByTestId('todo-item').nth(1).getByRole('checkbox').check();
|
|
387
|
-
// await checkNumberOfCompletedTodosInLocalStorage(page, 1);
|
|
388
|
-
// await page.getByRole('link', { name: 'Active' }).click();
|
|
389
|
-
// await page.getByRole('link', { name: 'Completed' }).click();
|
|
390
|
-
// await page.getByRole('link', { name: 'All' }).click();
|
|
391
|
-
// await expect(page.getByTestId('todo-item')).toHaveCount(3);
|
|
392
|
-
// });
|
|
393
|
-
|
|
394
|
-
// test('should highlight the currently applied filter', async ({ page }) => {
|
|
395
|
-
// await expect(page.getByRole('link', { name: 'All' })).toHaveClass('selected');
|
|
396
|
-
|
|
397
|
-
// //create locators for active and completed links
|
|
398
|
-
// const activeLink = page.getByRole('link', { name: 'Active' });
|
|
399
|
-
// const completedLink = page.getByRole('link', { name: 'Completed' });
|
|
400
|
-
// await activeLink.click();
|
|
401
|
-
|
|
402
|
-
// // Page change - active items.
|
|
403
|
-
// await expect(activeLink).toHaveClass('selected');
|
|
404
|
-
// await completedLink.click();
|
|
405
|
-
|
|
406
|
-
// // Page change - completed items.
|
|
407
|
-
// await expect(completedLink).toHaveClass('selected');
|
|
408
|
-
// });
|
|
409
|
-
// });
|
|
410
|
-
|
|
411
|
-
// async function createDefaultTodos(page: Page) {
|
|
412
|
-
// // create a new todo locator
|
|
413
|
-
// const newTodo = page.getByPlaceholder('What needs to be done?');
|
|
414
|
-
|
|
415
|
-
// for (const item of TODO_ITEMS) {
|
|
416
|
-
// await newTodo.fill(item);
|
|
417
|
-
// await newTodo.press('Enter');
|
|
418
|
-
// }
|
|
419
|
-
// }
|
|
420
|
-
|
|
421
|
-
// async function checkNumberOfTodosInLocalStorage(page: Page, expected: number) {
|
|
422
|
-
// return await page.waitForFunction(e => {
|
|
423
|
-
// return JSON.parse(localStorage['react-todos']).length === e;
|
|
424
|
-
// }, expected);
|
|
425
|
-
// }
|
|
426
|
-
|
|
427
|
-
// async function checkNumberOfCompletedTodosInLocalStorage(page: Page, expected: number) {
|
|
428
|
-
// return await page.waitForFunction(e => {
|
|
429
|
-
// return JSON.parse(localStorage['react-todos']).filter((todo: any) => todo.completed).length === e;
|
|
430
|
-
// }, expected);
|
|
431
|
-
// }
|
|
432
|
-
|
|
433
|
-
// async function checkTodosInLocalStorage(page: Page, title: string) {
|
|
434
|
-
// return await page.waitForFunction(t => {
|
|
435
|
-
// return JSON.parse(localStorage['react-todos']).map((todo: any) => todo.title).includes(t);
|
|
436
|
-
// }, title);
|
|
437
|
-
// }
|
package/tests/eslint.config.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import tseslint from 'typescript-eslint';
|
|
3
|
-
|
|
4
|
-
export default tseslint.config(
|
|
5
|
-
eslint.configs.recommended,
|
|
6
|
-
tseslint.configs.recommended,
|
|
7
|
-
{
|
|
8
|
-
rules: {
|
|
9
|
-
'eol-last': 2,
|
|
10
|
-
'quotes': ['error', 'single'],
|
|
11
|
-
'comma-dangle': ['error', {
|
|
12
|
-
'objects': 'always',
|
|
13
|
-
'arrays': 'never',
|
|
14
|
-
'imports': 'never',
|
|
15
|
-
'exports': 'never',
|
|
16
|
-
'functions': 'never',
|
|
17
|
-
}],
|
|
18
|
-
'semi': 'error',
|
|
19
|
-
'@typescript-eslint/ban-ts-comment': 'off',
|
|
20
|
-
'@typescript-eslint/no-require-imports': 'off',
|
|
21
|
-
},
|
|
22
|
-
files: ["src/**/*.{js,mjs,ts,tsx,jsx}", "cdk/**/*.{js,ts,mjs}"],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
ignores: ["dist/", "cdk.out/"]
|
|
26
|
-
}
|
|
27
|
-
)
|