Unverified Commit 3e0c228f authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

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

parent d6949670
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
import type { Request, Response } from 'playwright' import type { Request, Response } from 'playwright'
import fs from 'fs-extra' import fs from 'fs-extra'
import nodeFs from 'fs' import nodeFs from 'fs'
import path, { join } from 'path' import { join } from 'path'
import { outdent } from 'outdent' import { outdent } from 'outdent'
const GENERIC_RSC_ERROR = const GENERIC_RSC_ERROR =
...@@ -31,17 +31,6 @@ describe('app-dir action handling', () => { ...@@ -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 () => { it('should handle action correctly with middleware rewrite', async () => {
const browser = await next.browser('/rewrite-to-static-first') const browser = await next.browser('/rewrite-to-static-first')
let actionRequestStatus: number | undefined let actionRequestStatus: number | undefined
......
...@@ -5,13 +5,6 @@ import 'server-only' ...@@ -5,13 +5,6 @@ import 'server-only'
import { redirect } from 'next/navigation' import { redirect } from 'next/navigation'
import { headers, cookies } from 'next/headers' import { headers, cookies } from 'next/headers'
try {
require('fs').readFileSync(
require('path').join(process.cwd(), 'data.txt'),
'utf8'
)
} catch {}
export async function getHeaders() { export async function getHeaders() {
console.log('accept header:', (await headers()).get('accept')) console.log('accept header:', (await headers()).get('accept'))
;(await cookies()).set('test-cookie', Date.now()) ;(await cookies()).set('test-cookie', Date.now())
......
hello world
\ No newline at end of file
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)
})
})
'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'
}
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
'use client'
import { action } from './action'
export default function Page() {
return (
<button
onClick={() => {
action()
}}
>
click
</button>
)
}
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}
module.exports = nextConfig
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment