Skip to content

Commit 6499543

Browse files
authored
test(fullstack): more e2e (#1173)
1 parent 5f1011a commit 6499543

File tree

2 files changed

+62
-13
lines changed

2 files changed

+62
-13
lines changed

packages/fullstack/e2e/basic.test.ts

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,6 @@ function defineTest(f: Fixture) {
4343
expect(errors).toEqual([]);
4444
});
4545

46-
// TODO
47-
if (f.mode === "dev") {
48-
test("hmr js", async ({ page }) => {
49-
page;
50-
});
51-
52-
test("hmr css", async ({ page }) => {
53-
page;
54-
});
55-
}
56-
5746
test.describe(() => {
5847
test.use({ javaScriptEnabled: false });
5948

@@ -72,7 +61,67 @@ function defineTest(f: Fixture) {
7261
);
7362

7463
// modulepreload
75-
// TODO
64+
if (f.mode === "build") {
65+
await expect(page.locator("link[rel='modulepreload']")).toBeAttached();
66+
}
7667
});
7768
});
69+
70+
if (f.mode === "dev") {
71+
test("hmr react", async ({ page }) => {
72+
await page.goto(f.url());
73+
await using _ = await expectNoReload(page);
74+
75+
await expect(
76+
page.getByRole("button", { name: "count is 0" }),
77+
).toBeVisible();
78+
await page.getByRole("button", { name: "count is 0" }).click();
79+
await expect(
80+
page.getByRole("button", { name: "count is 1" }),
81+
).toBeVisible();
82+
83+
const jsFile = f.createEditor("src/App.tsx");
84+
jsFile.edit((s) => s.replace("count is", "count (edit) is"));
85+
86+
await expect(
87+
page.getByRole("button", { name: "count (edit) is 1" }),
88+
).toBeVisible();
89+
90+
jsFile.reset();
91+
await expect(
92+
page.getByRole("button", { name: "count is 1" }),
93+
).toBeVisible();
94+
});
95+
96+
test("hmr css", async ({ page }) => {
97+
await page.goto(f.url());
98+
await using _ = await expectNoReload(page);
99+
100+
await expect(
101+
page.getByRole("button", { name: "count is 0" }),
102+
).toBeVisible();
103+
await page.getByRole("button", { name: "count is 0" }).click();
104+
await expect(
105+
page.getByRole("button", { name: "count is 1" }),
106+
).toBeVisible();
107+
108+
const cssFile = f.createEditor("src/App.css");
109+
cssFile.edit((s) =>
110+
s.replace("color: rgb(136, 136, 136);", "color: rgb(36, 36, 36);"),
111+
);
112+
await expect(page.locator(".read-the-docs")).toHaveCSS(
113+
"color",
114+
"rgb(36, 36, 36)",
115+
);
116+
cssFile.reset();
117+
await expect(page.locator(".read-the-docs")).toHaveCSS(
118+
"color",
119+
"rgb(136, 136, 136)",
120+
);
121+
122+
await expect(
123+
page.getByRole("button", { name: "count is 1" }),
124+
).toBeVisible();
125+
});
126+
}
78127
}

packages/fullstack/examples/basic/src/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
}
3838

3939
.read-the-docs {
40-
color: #888;
40+
color: rgb(136, 136, 136);
4141
}

0 commit comments

Comments
 (0)