Skip to content

Commit 0524e16

Browse files
committed
test(e2e): add DataTable tests
Made-with: Cursor
1 parent b67a6cf commit 0524e16

5 files changed

Lines changed: 62 additions & 0 deletions

File tree

e2e/data-table.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { expect, test } from "@playwright/test";
2+
3+
test.describe("DataTable", () => {
4+
test.beforeEach(async ({ page }) => {
5+
await page.goto("/data-table.html");
6+
});
7+
8+
test("renders table with headers", async ({ page }) => {
9+
await expect(
10+
page.getByRole("columnheader", { name: "Name" }),
11+
).toBeVisible();
12+
await expect(
13+
page.getByRole("columnheader", { name: "Value" }),
14+
).toBeVisible();
15+
});
16+
17+
test("renders rows with data", async ({ page }) => {
18+
const table = page.locator(".bx--data-table");
19+
await expect(table).toBeVisible();
20+
await expect(
21+
page.getByRole("cell", { name: "Row 0", exact: true }),
22+
).toBeVisible();
23+
await expect(
24+
page.getByRole("cell", { name: "Row 1", exact: true }),
25+
).toBeVisible();
26+
});
27+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<script>
2+
import { DataTable } from "carbon-components-svelte";
3+
4+
const headers = [
5+
{ key: "name", value: "Name" },
6+
{ key: "value", value: "Value" },
7+
];
8+
9+
const rows = Array.from({ length: 20 }, (_, i) => ({
10+
id: i,
11+
name: `Row ${i}`,
12+
value: `Value ${i}`,
13+
}));
14+
</script>
15+
16+
<div data-testid="data-table-virtual">
17+
<DataTable {headers} {rows} />
18+
</div>

e2e/fixtures/data-table.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>DataTable Fixture</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="./data-table.ts"></script>
11+
</body>
12+
</html>

e2e/fixtures/data-table.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import DataTableFixture from "./DataTableFixture.svelte";
2+
import { mount } from "./mount";
3+
4+
mount(DataTableFixture);

e2e/fixtures/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<a href="/context-menu.html">ContextMenu</a>
2020
<a href="/composed-modal.html">ComposedModal</a>
2121
<a href="/code-snippet.html">CodeSnippet</a>
22+
<a href="/data-table.html">DataTable</a>
2223
</nav>
2324
</body>
2425
</html>

0 commit comments

Comments
 (0)