Skip to content

Commit 1788bca

Browse files
committed
fix(test): reject whitespace-only --name in test update (parity with test create)
1 parent 18f6e6e commit 1788bca

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/commands/test.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5470,6 +5470,31 @@ describe('runUpdate', () => {
54705470
expect(called).toBe(0);
54715471
});
54725472

5473+
it('rejects a whitespace-only --name before sending (parity with test create)', async () => {
5474+
const { credentialsPath } = makeCreds();
5475+
let called = 0;
5476+
const fetchImpl = makeFetch(() => {
5477+
called += 1;
5478+
return { body: SAMPLE_RESPONSE };
5479+
});
5480+
await expect(
5481+
runUpdate(
5482+
{
5483+
profile: 'default',
5484+
output: 'json',
5485+
debug: false,
5486+
testId: 'test_alpha',
5487+
name: ' ',
5488+
},
5489+
{ credentialsPath, fetchImpl, stdout: () => undefined },
5490+
),
5491+
).rejects.toMatchObject({
5492+
code: 'VALIDATION_ERROR',
5493+
details: expect.objectContaining({ field: 'name' }),
5494+
});
5495+
expect(called).toBe(0);
5496+
});
5497+
54735498
it('renders text mode with one line per updated field', async () => {
54745499
const { credentialsPath } = makeCreds();
54755500
const fetchImpl = makeFetch(() => ({ body: SAMPLE_RESPONSE }));

src/commands/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,9 @@ export async function runUpdate(
12101210
assertIdempotencyKey(opts.idempotencyKey);
12111211
requireNonEmpty('test-id', opts.testId);
12121212
// P1-3: client-side length checks matching server limits.
1213+
if (opts.name !== undefined && opts.name.trim().length === 0) {
1214+
throw localValidationError('name', 'must be a non-empty string (whitespace-only is not allowed)');
1215+
}
12131216
if (opts.name !== undefined && opts.name.length > 200) {
12141217
throw localValidationError('name', 'must be at most 200 characters');
12151218
}

0 commit comments

Comments
 (0)