-
Notifications
You must be signed in to change notification settings - Fork 588
/
Copy pathmain.spec.ts
149 lines (114 loc) · 4.78 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import { expect, Locator, test as playwrightTest } from '@playwright/test';
import { PackageName } from '../src/testConfig';
const test = playwrightTest.extend<{ packageName: PackageName | 'DEFAULT' }>({
// this is provided by `playwright.config.ts`
packageName: ['DEFAULT', { option: true }],
});
test.describe('e2e', () => {
test('default props', async ({ page, packageName }) => {
// TODO: Some targets don't support `defaultProps` :(
if (['e2e-qwik', 'e2e-solid'].includes(packageName)) {
test.skip();
}
await page.goto('/default-props/');
const text = await page.getByTestId('default-props').textContent();
expect(text?.includes('abc')).toBeTruthy();
expect(text?.includes('xyz')).toBeTruthy();
});
test('todo list add', async ({ page }) => {
await page.goto('/one-component/');
// await expect(page.locator('li')).toHaveCount(2);
await page.locator('input').click();
await page.locator('input').fill('Test Items One');
await page.locator('text=Add list item').click(); // Add button
// await expect(page.locator('li')).toHaveCount(3);
});
test('todo list add - multi component', async ({ page }) => {
await page.goto('/two-components/');
// await expect(page.locator('li')).toHaveCount(2);
await page.locator('input').click();
await page.locator('input').fill('Test Items One');
await page.locator('text=Add list item').click(); // Add button
// await expect(page.locator('li')).toHaveCount(3);
});
test('show-for component test', async ({ page, packageName }) => {
await page.goto('/show-for-component/');
let textLocator = 'text=number :';
if (['e2e-angular'].includes(packageName)) {
// angular adds extra whitespace
textLocator += ' ';
}
await expect(page.locator(`${textLocator}1`)).toBeVisible();
await expect(page.locator(`${textLocator}2`)).toBeVisible();
await expect(page.locator(`${textLocator}3`)).toBeVisible();
});
test.describe('special HTML tags', () => {
test('template tag', async ({ page, packageName }) => {
await page.goto('/special-tags/');
await expect(page.locator('template')).toBeDefined();
});
test('script tag', async ({ page, packageName }) => {
if (
['e2e-solid', 'e2e-react', 'e2e-angular', 'e2e-qwik', 'e2e-stencil', 'e2e-svelte'].includes(
packageName,
)
) {
test.skip();
}
const consoleMsg: string[] = [];
page.on('console', (msg) => consoleMsg.push(msg.text()));
await page.goto('/special-tags/');
await expect(consoleMsg.includes('hello from script tag.')).toBe(true);
});
test('style tag', async ({ page, packageName }) => {
if (['e2e-angular'].includes(packageName)) {
test.skip();
}
await page.goto('/special-tags/');
const div = page.locator('.wrap');
await expect(div).toHaveCSS('background-color', 'rgb(255, 0, 0)');
});
});
test('simple input disabled', async ({ page, packageName }) => {
await page.goto('/disabled-input/');
const disabled = page.getByTestId('simple-input-disabled');
await expect(disabled).toBeDisabled();
const enabled = page.getByTestId('simple-input-enabled');
if (['e2e-angular'].includes(packageName)) {
// this is the exception for angular it will generate [attr.disabled]
// which will be a string, so it is always true
await expect(disabled).toBeDisabled();
} else {
await expect(enabled).toBeEditable();
}
const nativeDisabled = page.getByTestId('native-input-disabled');
await expect(nativeDisabled).toBeDisabled();
const nativeEnabled = page.getByTestId('native-input-enabled');
await expect(nativeEnabled).toBeEditable();
});
test('on update', async ({ page, packageName }) => {
if (['e2e-angular', 'e2e-solid'].includes(packageName)) {
// Angular: We need to split onUpdate to ngOnChanges and for useRef into ngAfterContentChecked
test.skip();
}
await page.goto('/component-on-update/');
const container = page.getByTestId('container');
const button = page.getByTestId('button');
const labelBefore = await container.getAttribute('aria-label');
expect(labelBefore).toEqual('Label: 0');
await button.click();
const labelAfter = await container.getAttribute('aria-label');
expect(labelAfter).toEqual('Label: 1');
});
test('component with outside types', async ({ page, packageName }) => {
if (['e2e-qwik'].includes(packageName)) {
// Qwik: Events are not working as properties
test.skip();
}
await page.goto('/component-with-outside-types/');
const button: Locator = page.locator('button');
await expect(button).toContainText('Before');
await button.click();
await expect(button).toContainText('After');
});
});