Files
Hendrik LiebauandGitHub 006c22f1c8 Omit unused arguments for server actions (#89651)
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`.
2026-02-07 14:04:16 -08:00

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)')
})
})
})