-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Expand file tree
/
Copy pathlayout-route-test.ts
More file actions
66 lines (57 loc) · 2.28 KB
/
Copy pathlayout-route-test.ts
File metadata and controls
66 lines (57 loc) · 2.28 KB
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
import { test } from "@playwright/test";
import {
createAppFixture,
createFixture,
js,
} from "./helpers/create-fixture.js";
import type { AppFixture } from "./helpers/create-fixture.js";
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";
test.describe("pathless layout routes", () => {
let appFixture: AppFixture;
test.beforeAll(async () => {
appFixture = await createAppFixture(
await createFixture({
files: {
"app/routes/_layout.tsx": js`
import { Outlet } from "react-router";
export default () => <div data-testid="layout-route"><Outlet /></div>;
`,
"app/routes/_layout._index.tsx": js`
export default () => <div data-testid="layout-index">Layout index</div>;
`,
"app/routes/_layout.subroute.tsx": js`
export default () => <div data-testid="layout-subroute">Layout subroute</div>;
`,
"app/routes/sandwiches._pathless.tsx": js`
import { Outlet } from "react-router";
export default () => <div data-testid="sandwiches-pathless-route"><Outlet /></div>;
`,
"app/routes/sandwiches._pathless._index.tsx": js`
export default () => <div data-testid="sandwiches-pathless-index">Sandwiches pathless index</div>;
`,
},
}),
);
});
test.afterAll(() => {
appFixture.close();
});
test("should render pathless index route", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/");
await page.waitForSelector("[data-testid='layout-route']");
await page.waitForSelector("[data-testid='layout-index']");
});
test("should render pathless sub route", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/subroute");
await page.waitForSelector("[data-testid='layout-route']");
await page.waitForSelector("[data-testid='layout-subroute']");
});
test("should render pathless index as a sub route", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/sandwiches");
await page.waitForSelector("[data-testid='sandwiches-pathless-route']");
await page.waitForSelector("[data-testid='sandwiches-pathless-index']");
});
});