Thanks to visit codestin.com
Credit goes to github.com

Skip to content

enable e2e/app-router tests to run in CI #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 31, 2025
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
4 changes: 3 additions & 1 deletion examples/e2e/app-router/e2e/after.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect, test } from "@playwright/test";

test("Next after", async ({ request }) => {
// Cache is currently not supported: https://github.com/opennextjs/opennextjs-cloudflare/issues/105
// (Note: specifically this test relied on `unstable_cache`: https://github.com/opennextjs/opennextjs-cloudflare/issues/105#issuecomment-2627074820)
test.skip("Next after", async ({ request }) => {
const initialSSG = await request.get("/api/after/ssg");
expect(initialSSG.status()).toEqual(200);
const initialSSGJson = await initialSSG.json();
Expand Down
5 changes: 4 additions & 1 deletion examples/e2e/app-router/e2e/host.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { expect, test } from "@playwright/test";

/**
* Tests that the request.url is the deployed host and not localhost
*
* This test is skipped since e2e tests for the cloudflare adapter
* run only locally to the baseURL doesn't match
*/
test("Request.url is host", async ({ baseURL, page }) => {
test.skip("Request.url is host", async ({ baseURL, page }) => {
await page.goto("/api/host");

const el = page.getByText(`{"url":"${baseURL}/api/host"}`);
Expand Down
3 changes: 2 additions & 1 deletion examples/e2e/app-router/e2e/image-optimization.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from "@playwright/test";

test("Image Optimization", async ({ page }) => {
// Image Optimization is currently not supported: https://github.com/opennextjs/opennextjs-cloudflare/issues/106
test.skip("Image Optimization", async ({ page }) => {
await page.goto("/");

const imageResponsePromise = page.waitForResponse(/https%3A%2F%2Fopennext.js.org%2Farchitecture.png/);
Expand Down
3 changes: 2 additions & 1 deletion examples/e2e/app-router/e2e/isr.revalidate.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from "@playwright/test";

test("Test revalidate", async ({ request }) => {
// Cache (and revalidation) is currently not supported: https://github.com/opennextjs/opennextjs-cloudflare/issues/105
test.skip("Test revalidate", async ({ request }) => {
const result = await request.get("/api/isr");

expect(result.status()).toEqual(200);
Expand Down
6 changes: 4 additions & 2 deletions examples/e2e/app-router/e2e/isr.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from "@playwright/test";

test("Incremental Static Regeneration", async ({ page }) => {
// ISR is currently not supported: https://github.com/opennextjs/opennextjs-cloudflare/issues/105
test.skip("Incremental Static Regeneration", async ({ page }) => {
test.setTimeout(45000);
await page.goto("/");
await page.locator("[href='/isr']").click();
Expand Down Expand Up @@ -40,7 +41,8 @@ test("Incremental Static Regeneration", async ({ page }) => {
expect(newTime).not.toEqual(finalTime);
});

test("headers", async ({ page }) => {
// ISR is currently not supported: https://github.com/opennextjs/opennextjs-cloudflare/issues/105
test.skip("headers", async ({ page }) => {
let responsePromise = page.waitForResponse((response) => {
return response.status() === 200;
});
Expand Down
6 changes: 4 additions & 2 deletions examples/e2e/app-router/e2e/revalidateTag.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from "@playwright/test";

test("Revalidate tag", async ({ page, request }) => {
// Cache (and revalidateTag) is currently not supported: https://github.com/opennextjs/opennextjs-cloudflare/issues/105
test.skip("Revalidate tag", async ({ page, request }) => {
test.setTimeout(45000);
// We need to hit the page twice to make sure it's properly cached
// Turbo might cache next build result, resulting in the tag being newer than the page
Expand Down Expand Up @@ -68,7 +69,8 @@ test("Revalidate tag", async ({ page, request }) => {
expect(nextCacheHeaderNested).toEqual("HIT");
});

test("Revalidate path", async ({ page, request }) => {
// Cache (and revalidatePath) is currently not supported: https://github.com/opennextjs/opennextjs-cloudflare/issues/105
test.skip("Revalidate path", async ({ page, request }) => {
await page.goto("/revalidate-path");

let elLayout = page.getByText("RequestID:");
Expand Down
3 changes: 2 additions & 1 deletion examples/e2e/app-router/e2e/ssr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import { expect, test } from "@playwright/test";

// NOTE: We don't await page load b/c we want to see the Loading page
test("Server Side Render and loading.tsx", async ({ page }) => {
// loading.tsx doesn't currently work: https://github.com/opennextjs/opennextjs-cloudflare/issues/313
test.skip("Server Side Render and loading.tsx", async ({ page }) => {
test.setTimeout(600000);
await page.goto("/");
await page.getByRole("link", { name: "SSR" }).click();
Expand Down
6 changes: 4 additions & 2 deletions examples/e2e/app-router/e2e/trailing.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { expect, test } from "@playwright/test";

test("trailingSlash redirect", async ({ page }) => {
// trailingSlash redirecting doesn't work: https://github.com/opennextjs/opennextjs-cloudflare/issues/312
test.skip("trailingSlash redirect", async ({ page }) => {
const response = await page.goto("/ssr/");

expect(response?.request().redirectedFrom()?.url()).toMatch(/\/ssr\/$/);
expect(response?.request().url()).toMatch(/\/ssr$/);
});

test("trailingSlash redirect with search parameters", async ({ page }) => {
// trailingSlash redirecting doesn't work: https://github.com/opennextjs/opennextjs-cloudflare/issues/312
test.skip("trailingSlash redirect with search parameters", async ({ page }) => {
const response = await page.goto("/ssr/?happy=true");

expect(response?.request().redirectedFrom()?.url()).toMatch(/\/ssr\/\?happy=true$/);
Expand Down
4 changes: 2 additions & 2 deletions examples/e2e/app-router/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { OpenNextConfig } from "@opennextjs/aws/types/open-next.js";
import cache from "@opennextjs/cloudflare/kvCache";

const config: OpenNextConfig = {
default: {
override: {
wrapper: "cloudflare-node",
converter: "edge",
// Unused implementation
incrementalCache: "dummy",
incrementalCache: async () => cache,
tagCache: "dummy",
queue: "dummy",
},
Expand Down
2 changes: 1 addition & 1 deletion examples/e2e/app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build:worker": "pnpm opennextjs-cloudflare",
"dev:worker": "wrangler dev --port 8790 --inspector-port 9350",
"preview": "pnpm build:worker && pnpm dev:worker",
"e2e-fix": "playwright test -c e2e/playwright.config.ts"
"e2e": "playwright test -c e2e/playwright.config.ts"
},
"dependencies": {
"@opennextjs/cloudflare": "workspace:*",
Expand Down
8 changes: 7 additions & 1 deletion examples/e2e/app-router/wrangler.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
"assets": {
"directory": ".open-next/assets",
"binding": "ASSETS"
}
},
"kv_namespaces": [
{
"binding": "NEXT_CACHE_WORKERS_KV",
"id": "<BINDING_ID>"
}
]
}