File size: 3,443 Bytes
94786da | 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | diff --git a/test/e2e/app-dir/actions/app-action-progressive-enhancement.test.ts b/test/e2e/app-dir/actions/app-action-progressive-enhancement.test.ts
index 4a5993c3..d8d9f804 100644
--- a/test/e2e/app-dir/actions/app-action-progressive-enhancement.test.ts
+++ b/test/e2e/app-dir/actions/app-action-progressive-enhancement.test.ts
@@ -1,25 +1,28 @@
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
+import type { Response } from 'playwright'
describe('app-dir action progressive enhancement', () => {
const { next } = nextTestSetup({
files: __dirname,
dependencies: {
nanoid: '4.0.1',
- 'server-only': 'latest',
+ 'server-only': '0.0.1',
},
})
it('should support formData and redirect without JS', async () => {
- let responseCode: number | undefined
+ let actionResponse: Response | undefined
const browser = await next.browser('/server', {
disableJavaScript: true,
beforePageLoad(page) {
page.on('response', (response) => {
const url = new URL(response.url())
- const status = response.status()
- if (url.pathname.includes('/server')) {
- responseCode = status
+ if (
+ url.pathname === '/server' &&
+ response.request().method() === 'POST'
+ ) {
+ actionResponse = response
}
})
},
@@ -34,7 +37,10 @@ describe('app-dir action progressive enhancement', () => {
)
})
- expect(responseCode).toBe(303)
+ expect(actionResponse).toBeDefined()
+ expect(actionResponse!.status()).toBe(303)
+ const headers = await actionResponse!.allHeaders()
+ expect(headers.location).toBe('/header?name=test&hidden-info=hi')
})
it('should support actions from client without JS', async () => {
diff --git a/test/e2e/app-dir/app-basepath/index.test.ts b/test/e2e/app-dir/app-basepath/index.test.ts
index 736b6688..466a1865 100644
--- a/test/e2e/app-dir/app-basepath/index.test.ts
+++ b/test/e2e/app-dir/app-basepath/index.test.ts
@@ -6,7 +6,7 @@ describe('app dir - basepath', () => {
const { next, isNextDev } = nextTestSetup({
files: __dirname,
dependencies: {
- sass: 'latest',
+ sass: '1.54.0',
},
})
@@ -156,7 +156,12 @@ describe('app dir - basepath', () => {
expect(request.url()).toEqual(`${next.url}${initialPagePath}`)
expect(request.method()).toEqual('POST')
- expect(response.status()).toEqual(303)
+ expect(response.status()).toEqual(200)
+
+ const headers = await response.allHeaders()
+ expect(headers['x-action-redirect']).toBeDefined()
+ expect(headers.location).toBeUndefined()
+ expect(headers['content-type']).toContain('text/x-component')
}
)
@@ -204,7 +209,10 @@ describe('app dir - basepath', () => {
expect(secondRequest.url()).toEqual(`${next.url}${destinationPagePath}`)
expect(secondRequest.method()).toEqual('GET')
- expect(firstResponse.status()).toEqual(303)
+ expect(firstResponse.status()).toEqual(200)
+ const headers = await firstResponse.allHeaders()
+ expect(headers['x-action-redirect']).toBeDefined()
+ expect(headers.location).toBeUndefined()
// Since this is an external request to a resource outside of NextJS
// we expect to see a separate request resolving the external URL.
expect(secondResponse.status()).toEqual(200)
|