Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/e2e/experimental/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { configurePlaywright } from "../../../common/config-e2e";

// We need to disable parallel execution for the experimental app, otherwise it breaks the SSR test
export default configurePlaywright("experimental", { parallel: false });
export default configurePlaywright("experimental");
13 changes: 7 additions & 6 deletions examples/e2e/experimental/e2e/use-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect, test } from "@playwright/test";
test.describe("Composable Cache", () => {
test("cached component should work in ssr", async ({ page }) => {
await page.goto("/use-cache/ssr");
let fullyCachedElt = page.getByTestId("fullyCached");
let fullyCachedElt = page.getByTestId("fully-cached");
let isrElt = page.getByTestId("isr");
await expect(fullyCachedElt).toBeVisible();
await expect(isrElt).toBeVisible();
Expand All @@ -12,9 +12,10 @@ test.describe("Composable Cache", () => {
const initialIsrText = await isrElt.textContent();

let isrText = initialIsrText;

do {
await page.reload();
fullyCachedElt = page.getByTestId("fullyCached");
fullyCachedElt = page.getByTestId("fully-cached");
isrElt = page.getByTestId("isr");
await expect(fullyCachedElt).toBeVisible();
await expect(isrElt).toBeVisible();
Expand All @@ -27,7 +28,7 @@ test.describe("Composable Cache", () => {

test("revalidateTag should work for fullyCached component", async ({ page, request }) => {
await page.goto("/use-cache/ssr");
const fullyCachedElt = page.getByTestId("fullyCached");
const fullyCachedElt = page.getByTestId("fully-cached-with-tag");
await expect(fullyCachedElt).toBeVisible();

const initialFullyCachedText = await fullyCachedElt.textContent();
Expand All @@ -45,7 +46,7 @@ test.describe("Composable Cache", () => {
test("cached component should work in isr", async ({ page }) => {
await page.goto("/use-cache/isr");

let fullyCachedElt = page.getByTestId("fullyCached");
let fullyCachedElt = page.getByTestId("fully-cached");
let isrElt = page.getByTestId("isr");

await expect(fullyCachedElt).toBeVisible();
Expand All @@ -61,7 +62,7 @@ test.describe("Composable Cache", () => {
while (isrText === initialIsrText) {
await page.reload();
isrElt = page.getByTestId("isr");
fullyCachedElt = page.getByTestId("fullyCached");
fullyCachedElt = page.getByTestId("fully-cached");
await expect(isrElt).toBeVisible();
isrText = await isrElt.textContent();
await expect(fullyCachedElt).toBeVisible();
Expand All @@ -72,7 +73,7 @@ test.describe("Composable Cache", () => {

do {
await page.reload();
fullyCachedElt = page.getByTestId("fullyCached");
fullyCachedElt = page.getByTestId("fully-cached");
isrElt = page.getByTestId("isr");
await expect(fullyCachedElt).toBeVisible();
await expect(isrElt).toBeVisible();
Expand Down
5 changes: 4 additions & 1 deletion examples/e2e/experimental/src/app/use-cache/ssr/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FullyCachedComponent, ISRComponent } from "@/components/cached";
import { FullyCachedComponent, FullyCachedComponentWithTag, ISRComponent } from "@/components/cached";
import { headers } from "next/headers";
import { Suspense } from "react";

Expand All @@ -12,6 +12,9 @@ export default async function Page() {
<Suspense fallback={<p>Loading...</p>}>
<FullyCachedComponent />
</Suspense>
<Suspense fallback={<p>Loading...</p>}>
<FullyCachedComponentWithTag />
</Suspense>
<Suspense fallback={<p>Loading...</p>}>
<ISRComponent />
</Suspense>
Expand Down
11 changes: 10 additions & 1 deletion examples/e2e/experimental/src/components/cached.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { unstable_cacheLife, unstable_cacheTag } from "next/cache";

export async function FullyCachedComponent() {
"use cache";
return (
<div>
<p data-testid="fully-cached">{Date.now()}</p>
</div>
);
}

export async function FullyCachedComponentWithTag() {
"use cache";
unstable_cacheTag("fullyTagged");
return (
<div>
<p data-testid="fullyCached">{Date.now()}</p>
<p data-testid="fully-cached-with-tag">{Date.now()}</p>
</div>
);
}
Expand Down