Skip to content

[test] separate tracing error test from action test suite #80324

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 1 commit into from
Jun 9, 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
13 changes: 1 addition & 12 deletions test/e2e/app-dir/actions/app-action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import type { Request, Response } from 'playwright'
import fs from 'fs-extra'
import nodeFs from 'fs'
import path, { join } from 'path'
import { join } from 'path'
import { outdent } from 'outdent'

const GENERIC_RSC_ERROR =
Expand All @@ -31,17 +31,6 @@ describe('app-dir action handling', () => {
},
})

if (isNextStart) {
it('should trace server action imported by client correctly', async () => {
const traceData = await next.readJSON(
path.join('.next', 'server', 'app', 'client', 'page.js.nft.json')
)
expect(traceData.files.some((file) => file.includes('data.txt'))).toBe(
true
)
})
}

it('should handle action correctly with middleware rewrite', async () => {
const browser = await next.browser('/rewrite-to-static-first')
let actionRequestStatus: number | undefined
Expand Down
7 changes: 0 additions & 7 deletions test/e2e/app-dir/actions/app/client/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ import 'server-only'
import { redirect } from 'next/navigation'
import { headers, cookies } from 'next/headers'

try {
require('fs').readFileSync(
require('path').join(process.cwd(), 'data.txt'),
'utf8'
)
} catch {}

export async function getHeaders() {
console.log('accept header:', (await headers()).get('accept'))
;(await cookies()).set('test-cookie', Date.now())
Expand Down
1 change: 0 additions & 1 deletion test/e2e/app-dir/actions/data.txt

This file was deleted.

19 changes: 19 additions & 0 deletions test/production/app-dir/action-tracing/action-tracing.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { nextTestSetup } from 'e2e-utils'
import path from 'path'

describe('action-tracing', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) return

it('should trace server action imported by client correctly', async () => {
const traceData = (await next.readJSON(
path.join('.next', 'server', 'app', 'page.js.nft.json')
)) as {
files: string[]
}
expect(traceData.files.some((file) => file.includes('data.txt'))).toBe(true)
})
})
14 changes: 14 additions & 0 deletions test/production/app-dir/action-tracing/app/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use server'

try {
if (process.env.NEXT_RUNTIME !== 'edge') {
require('fs').readFileSync(
require('path').join(process.cwd(), 'data.txt'),
'utf8'
)
}
} catch {}

export async function action() {
return 'action'
}
8 changes: 8 additions & 0 deletions test/production/app-dir/action-tracing/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
15 changes: 15 additions & 0 deletions test/production/app-dir/action-tracing/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use client'

import { action } from './action'

export default function Page() {
return (
<button
onClick={() => {
action()
}}
>
click
</button>
)
}
1 change: 1 addition & 0 deletions test/production/app-dir/action-tracing/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data
6 changes: 6 additions & 0 deletions test/production/app-dir/action-tracing/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}

module.exports = nextConfig
Loading