8000 move test inside describe · opennextjs/opennextjs-aws@4d83b93 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d83b93

Browse files
committed
move test inside describe
1 parent eaaf1ae commit 4d83b93

File tree

1 file changed

+75
-73
lines changed

1 file changed

+75
-73
lines changed
Lines changed: 75 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,89 @@
11
import { expect, test } from "@playwright/test";
22

3-
test("cached component should work in ssr", async ({ page }) => {
4-
await page.goto("/use-cache/ssr");
5-
let fullyCachedElt = page.getByTestId("fullyCached");
6-
let isrElt = page.getByTestId("isr");
7-
await expect(fullyCachedElt).toBeVisible();
8-
await expect(isrElt).toBeVisible();
9-
10-
const initialFullyCachedText = await fullyCachedElt.textContent();
11-
const initialIsrText = await isrElt.textContent();
12-
13-
let isrText = initialIsrText;
14-
15-
do {
16-
await page.reload();
17-
fullyCachedElt = page.getByTestId("fullyCached");
18-
isrElt = page.getByTestId("isr");
3+
test.describe("Composable Cache", () => {
4+
test("cached component should work in ssr", async ({ page }) => {
5+
await page.goto("/use-cache/ssr");
6+
let fullyCachedElt = page.getByTestId("fullyCached");
7+
let isrElt = page.getByTestId("isr");
198
await expect(fullyCachedElt).toBeVisible();
209
await expect(isrElt).toBeVisible();
21-
isrText = await isrElt.textContent();
22-
await page.waitForTimeout(1000);
23-
} while (isrText === initialIsrText);
24-
const fullyCachedText = await fullyCachedElt.textContent();
25-
expect(fullyCachedText).toEqual(initialFullyCachedText);
26-
});
27-
28-
test("revalidateTag should work for fullyCached component", async ({
29-
8000 page,
30-
request,
31-
}) => {
32-
await page.goto("/use-cache/ssr");
33-
const fullyCachedElt = page.getByTestId("fullyCached");
34-
await expect(fullyCachedElt).toBeVisible();
35-
36-
const initialFullyCachedText = await fullyCachedElt.textContent();
37-
38-
const resp = await request.get("/api/revalidate");
39-
expect(resp.status()).toEqual(200);
40-
expect(await resp.text()).toEqual("DONE");
41-
42-
await page.reload();
43-
await expect(fullyCachedElt).toBeVisible();
44-
const newFullyCachedText = await fullyCachedElt.textContent();
45-
expect(newFullyCachedText).not.toEqual(initialFullyCachedText);
46-
});
4710

48-
test("cached component should work in isr", async ({ page }) => {
49-
await page.goto("/use-cache/isr");
50-
51-
let fullyCachedElt = page.getByTestId("fullyCached");
52-
let isrElt = page.getByTestId("isr");
53-
54-
await expect(fullyCachedElt).toBeVisible();
55-
await expect(isrElt).toBeVisible();
56-
57-
let initialFullyCachedText = await fullyCachedElt.textContent();
58-
let initialIsrText = await isrElt.textContent();
11+
const initialFullyCachedText = await fullyCachedElt.textContent();
12+
const initialIsrText = await isrElt.textContent();
13+
14+
let isrText = initialIsrText;
15+
16+
do {
17+
await page.reload();
18+
fullyCachedElt = page.getByTestId("fullyCached");
19+
isrElt = page.getByTestId("isr");
20+
await expect(fullyCachedElt).toBeVisible();
21+
await expect(isrElt).toBeVisible();
22+
isrText = await isrElt.textContent();
23+
await page.waitForTimeout(1000);
24+
} while (isrText === initialIsrText);
25+
const fullyCachedText = await fullyCachedElt.textContent();
26+
expect(fullyCachedText).toEqual(initialFullyCachedText);
27+
});
28+
29+
test("revalidateTag should work for fullyCached component", async ({
30+
page,
31+
request,
32+
}) => {
33+
await page.goto("/use-cache/ssr");
34+
const fullyCachedElt = page.getByTestId("fullyCached");
35+
await expect(fullyCachedElt).toBeVisible();
5936

60-
// We have to force reload until ISR has triggered at least once, otherwise the test will be flakey
37+
const initialFullyCachedText = await fullyCachedElt.textContent();
6138

62-
let isrText = initialIsrText;
39+
const resp = await request.get("/api/revalidate");
40+
expect(resp.status()).toEqual(200);
41+
expect(await resp.text()).toEqual("DONE");
6342

64-
while (isrText === initialIsrText) {
6543
await page.reload();
66-
isrElt = page.getByTestId("isr");
67-
fullyCachedElt = page.getByTestId("fullyCached");
68-
await expect(isrElt).toBeVisible();
69-
isrText = await isrElt.textContent();
7044
await expect(fullyCachedElt).toBeVisible();
71-
initialFullyCachedText = await fullyCachedElt.textContent();
72-
await page.waitForTimeout(1000);
73-
}
74-
initialIsrText = isrText;
45+
const newFullyCachedText = await fullyCachedElt.textContent();
46+
expect(newFullyCachedText).not.toEqual(initialFullyCachedText);
47+
});
48+
49+
test("cached component should work in isr", async ({ page }) => {
50+
await page.goto("/use-cache/isr");
51+
52+
let fullyCachedElt = page.getByTestId("fullyCached");
53+
let isrElt = page.getByTestId("isr");
7554

76-
do {
77-
await page.reload();
78-
fullyCachedElt = page.getByTestId("fullyCached");
79-
isrElt = page.getByTestId("isr");
8055
await expect(fullyCachedElt).toBeVisible();
8156
await expect(isrElt).toBeVisible();
82-
isrText = await isrElt.textContent();
83-
await page.waitForTimeout(1000);
84-
} while (isrText === initialIsrText);
85-
const fullyCachedText = await fullyCachedElt.textContent();
86-
expect(fullyCachedText).toEqual(initialFullyCachedText);
57+
58+
let initialFullyCachedText = await fullyCachedElt.textContent();
59+
let initialIsrText = await isrElt.textContent();
60+
61+
// We have to force reload until ISR has triggered at least once, otherwise the test will be flakey
62+
63+
let isrText = initialIsrText;
64+
65+
while (isrText === initialIsrText) {
66+
await page.reload();
67+
isrElt = page.getByTestId("isr");
68+
fullyCachedElt = page.getByTestId("fullyCached");
69+
await expect(isrElt).toBeVisible();
70+
isrText = await isrElt.textContent();
71+
await expect(fullyCachedElt).toBeVisible();
72+
initialFullyCachedText = await fullyCachedElt.textContent();
73+
await page.waitForTimeout(1000);
74+
}
75+
initialIsrText = isrText;
76+
77+
do {
78+
await page.reload();
79+
fullyCachedElt = page.getByTestId("fullyCached");
80+
isrElt = page.getByTestId("isr");
81+
await expect(fullyCachedElt).toBeVisible();
82+
await expect(isrElt).toBeVisible();
83+
isrText = await isrElt.textContent();
84+
await page.waitForTimeout(1000);
85+
} while (isrText === initialIsrText);
86+
const fullyCachedText = await fullyCachedElt.textContent();
87+
expect(fullyCachedText).toEqual(initialFullyCachedText);
88+
});
8789
});

0 commit comments

Comments
 (0)
0