mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Previously, unused argument omission was only applied to `"use cache"` functions called from the client (#72506). This enables it for server actions as well, and optimizes `omitUnusedArgs` to trim trailing unused arguments from the sparse array, so that nothing is sent to the server for those instead of `undefined`.
32 lines
945 B
TypeScript
32 lines
945 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { retry } from '../../../lib/next-test-utils'
|
|
|
|
describe('actions-unused-args', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
// No access to runtime logs when deployed.
|
|
skipDeployment: true,
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
it('should not call server actions with unused arguments', async () => {
|
|
const browser = await next.browser('/')
|
|
const cliOutputLength = next.cliOutput.length
|
|
await browser.elementById('action-button').click()
|
|
|
|
await retry(async () => {
|
|
const actionLog = next.cliOutput
|
|
.slice(cliOutputLength)
|
|
.split('\n')
|
|
.find((line) => line.includes('Action called'))
|
|
|
|
// We expect only 1 argument because the click event from the onClick
|
|
// handler should be omitted as an unused argument.
|
|
expect(actionLog).toBe('Action called with value: 42 (total args: 1)')
|
|
})
|
|
})
|
|
})
|