Skip to content

Commit 792f6f2

Browse files
committed
[test] separate tracing error test from action test suite
1 parent a8ed882 commit 792f6f2

File tree

9 files changed

+65
-21
lines changed

9 files changed

+65
-21
lines changed

test/e2e/app-dir/actions/app-action.test.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import type { Request, Response } from 'playwright'
1111
import fs from 'fs-extra'
1212
import nodeFs from 'fs'
13-
import path, { join } from 'path'
13+
import { join } from 'path'
1414
import { outdent } from 'outdent'
1515

1616
const GENERIC_RSC_ERROR =
@@ -31,17 +31,6 @@ describe('app-dir action handling', () => {
3131
},
3232
})
3333

34-
if (isNextStart) {
35-
it('should trace server action imported by client correctly', async () => {
36-
const traceData = await next.readJSON(
37-
path.join('.next', 'server', 'app', 'client', 'page.js.nft.json')
38-
)
39-
expect(traceData.files.some((file) => file.includes('data.txt'))).toBe(
40-
true
41-
)
42-
})
43-
}
44-
4534
it('should handle action correctly with middleware rewrite', async () => {
4635
const browser = await next.browser('/rewrite-to-static-first')
4736
let actionRequestStatus: number | undefined
@@ -1923,7 +1912,7 @@ describe('app-dir action handling', () => {
19231912
})
19241913

19251914
describe('request body decoding', () => {
1926-
it.each(['node', 'edge'])(
1915+
it.each(['edge'])(
19271916
'should correctly decode multi-byte characters in the request body (%s)',
19281917
async (runtime) => {
19291918
const browser = await next.browser(`/decode-req-body/${runtime}`)

test/e2e/app-dir/actions/app/client/actions.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ import 'server-only'
55
import { redirect } from 'next/navigation'
66
import { headers, cookies } from 'next/headers'
77

8-
try {
9-
require('fs').readFileSync(
10-
require('path').join(process.cwd(), 'data.txt'),
11-
'utf8'
12-
)
13-
} catch {}
14-
158
export async function getHeaders() {
169
console.log('accept header:', (await headers()).get('accept'))
1710
;(await cookies()).set('test-cookie', Date.now())

test/e2e/app-dir/actions/data.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { nextTestSetup } from 'e2e-utils'
2+
import path from 'path'
3+
4+
describe('action-tracing', () => {
5+
const { next, skipped } = nextTestSetup({
6+
files: __dirname,
7+
skipDeployment: true,
8+
})
9+
if (skipped) return
10+
11+
it('should trace server action imported by client correctly', async () => {
12+
const traceData = (await next.readJSON(
13+
path.join('.next', 'server', 'app', 'page.js.nft.json')
14+
)) as {
15+
files: string[]
16+
}
17+
expect(traceData.files.some((file) => file.includes('data.txt'))).toBe(true)
18+
})
19+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use server'
2+
3+
try {
4+
if (process.env.NEXT_RUNTIME !== 'edge') {
5+
require('fs').readFileSync(
6+
require('path').join(process.cwd(), 'data.txt'),
7+
'utf8'
8+
)
9+
}
10+
} catch {}
11+
12+
export async function action() {
13+
return 'action'
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { ReactNode } from 'react'
2+
export default function Root({ children }: { children: ReactNode }) {
3+
return (
4+
<html>
5+
<body>{children}</body>
6+
</html>
7+
)
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use client'
2+
3+
import { action } from './action'
4+
5+
export default function Page() {
6+
return (
7+
<button
8+
onClick={() => {
9+
action()
10+
}}
11+
>
12+
click
13+
</button>
14+
)
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @type {import('next').NextConfig}
3+
*/
4+
const nextConfig = {}
5+
6+
module.exports = nextConfig

0 commit comments

Comments
 (0)