Skip to content
Open
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
25 changes: 25 additions & 0 deletions src/commands/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5470,6 +5470,31 @@ describe('runUpdate', () => {
expect(called).toBe(0);
});

it('rejects a whitespace-only --name before sending (parity with test create)', async () => {
const { credentialsPath } = makeCreds();
let called = 0;
const fetchImpl = makeFetch(() => {
called += 1;
return { body: SAMPLE_RESPONSE };
});
await expect(
runUpdate(
{
profile: 'default',
output: 'json',
debug: false,
testId: 'test_alpha',
name: ' ',
},
{ credentialsPath, fetchImpl, stdout: () => undefined },
),
).rejects.toMatchObject({
code: 'VALIDATION_ERROR',
details: expect.objectContaining({ field: 'name' }),
});
expect(called).toBe(0);
});

it('renders text mode with one line per updated field', async () => {
const { credentialsPath } = makeCreds();
const fetchImpl = makeFetch(() => ({ body: SAMPLE_RESPONSE }));
Expand Down
3 changes: 3 additions & 0 deletions src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,9 @@ export async function runUpdate(
assertIdempotencyKey(opts.idempotencyKey);
requireNonEmpty('test-id', opts.testId);
// P1-3: client-side length checks matching server limits.
if (opts.name !== undefined && opts.name.trim().length === 0) {
throw localValidationError('name', 'must be a non-empty string (whitespace-only is not allowed)');
}
if (opts.name !== undefined && opts.name.length > 200) {
throw localValidationError('name', 'must be at most 200 characters');
}
Expand Down