Skip to content

Commit 4c4ca07

Browse files
committed
added first tests
Signed-off-by: Maximilian Inckmann <[email protected]>
1 parent a364b7d commit 4c4ca07

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ hydrate/
22
dist/
33
www/
44
loader/
5+
test-results/
56

67
*~
78
*.sw[mnpcod]
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Playwright
33
node_modules/
4-
/test-results/
5-
/playwright-report/
6-
/blob-report/
7-
/playwright/.cache/
4+
test-results/
5+
playwright-report/
6+
blob-report/
7+
playwright/.cache/

packages/stencil-library/playwright.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { defineConfig, devices } from '@playwright/test';
1212
* See https://playwright.dev/docs/test-configuration.
1313
*/
1414
export default defineConfig({
15-
testDir: './src',
15+
testDir: './test',
1616

17-
testMatch: '**/*.spec.ts',
17+
// testMatch: '**/*.spec.ts',
1818

1919
/* Run tests in files in parallel */
2020
fullyParallel: true,
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('test', async ({ page }) => {
4+
await page.goto('http://localhost:6006/iframe.html?globals=&args=&id=pid-component--default&viewMode=story');
5+
await expect(page.locator('body')).toMatchAriaSnapshot(`
6+
- text: /This component displays information about the identifier \\d+\\.\\d+\\/B88E78D4-E1EE-40F7-96CE-EC1AFCFF6343\\. It can be expanded to show more details\\./
7+
- group:
8+
- text: /\\d+\\.\\d+ \\/ B88E78D4-E1EE-40F7-96CE-EC1AFCFF6343/
9+
- button "Copy content to clipboard"
10+
`);
11+
await expect(page.locator('body')).toBeVisible();
12+
await page.locator('summary svg').click();
13+
await expect(page.locator('.flex-grow').first()).toBeVisible();
14+
await page.locator('.flex.items-center.justify-between.gap-2.p-2').click();
15+
await page.getByRole('navigation', { name: 'Pagination controls and' }).click();
16+
await expect(page.getByLabel('Pagination controls for 21.11152/B88E78D4-E1EE-40F7-96CE-EC1AFCFF6343 data').getByLabel('Pagination controls and')).toMatchAriaSnapshot(`
17+
- navigation "Pagination controls and display settings":
18+
- group "Items per page options":
19+
- toolbar "Items per page:":
20+
- button "Show 5 items per page"
21+
- button /Show \\d+ items per page/ [pressed]
22+
- button /Show \\d+ items per page/
23+
- button /Show \\d+ items per page/
24+
- button /Show \\d+ items per page/
25+
- status: /Showing 1-\\d+ of \\d+/
26+
- navigation "Pagination":
27+
- button "Previous page" [disabled]
28+
- button "Page 1"
29+
- button "Page 2"
30+
- button "Next page"
31+
`);
32+
await page.locator('.flex.items-center.justify-between.gap-2.p-2').click();
33+
await page.getByLabel('Collapsible section for [').locator('summary svg').click();
34+
await expect(page.getByLabel('Collapsible section for [').locator('div').filter({ hasText: 'Could not display JSON data.' }).first()).toBeVisible();
35+
await expect(page.getByLabel('Collapsible section for [').locator('details')).toMatchAriaSnapshot(`
36+
- group:
37+
- text: "Object { 2 items }"
38+
- region "JSON Viewer":
39+
- text: JSON Viewer (1 property)
40+
- button "Switch to code view"
41+
- group "JSON data in tree view":
42+
- button "Copy JSON to clipboard"
43+
- 'treeitem "sha160sum: \\"sha160 6f1f5d3c9540b85f47ae08c7a5b9aa151b818a97\\" (string)"'
44+
`);
45+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
test('test', async ({ page }) => {
4+
test.setTimeout(30_000); // Increase timeout for the test
5+
await page.goto('http://localhost:6006/iframe.html?globals=&args=&id=pid-component--handle-without-subcomponent&viewMode=story');
6+
await expect(page.locator('body')).toBeVisible();
7+
await expect(page.locator('html')).toBeVisible();
8+
await page.getByRole('button', { name: 'Copy content to clipboard' }).click();
9+
await expect(page.locator('#storybook-root')).toBeVisible();
10+
await page.getByRole('button', { name: 'Copy content to clipboard' }).click();
11+
await expect(page.locator('body')).toMatchAriaSnapshot(`
12+
- text: /This component displays information about the identifier \\d+\\.\\d+\\/B88E78D4-E1EE-40F7-96CE-EC1AFCFF6343\\. It can be expanded to show more details\\./
13+
- button /Identifier preview for \\d+\\.\\d+\\/B88E78D4-E1EE-40F7-96CE-EC1AFCFF6343/:
14+
- button "Copy content to clipboard"
15+
`);
16+
await page.getByRole('button', { name: 'Identifier preview for 21.' }).click();
17+
await page.locator('body').click();
18+
await page.getByRole('button', { name: 'Copy content to clipboard' }).click();
19+
await expect(page.getByLabel('Copy content to clipboard')).toMatchAriaSnapshot(`- button "Copy content to clipboard"`);
20+
});

0 commit comments

Comments
 (0)