Skip to content

Commit 901177f

Browse files
ggazzoclaude
andcommitted
fix: Update commands.run tests for AJV body validation
Body validation is now handled by AJV schema instead of manual checks, so error messages change from custom strings to AJV validation messages. Also make triggerId optional in the schema to match actual usage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 53a840d commit 901177f

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

apps/meteor/app/api/server/v1/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,16 @@ API.v1.addRoute(
240240
},
241241
);
242242

243-
const isCommandsRunProps = ajv.compile<{ command: string; params?: string; roomId: string; tmid?: string; triggerId: string }>({
243+
const isCommandsRunProps = ajv.compile<{ command: string; params?: string; roomId: string; tmid?: string; triggerId?: string }>({
244244
type: 'object',
245245
properties: {
246246
command: { type: 'string' },
247247
params: { type: 'string', nullable: true },
248248
roomId: { type: 'string' },
249249
tmid: { type: 'string', nullable: true },
250-
triggerId: { type: 'string' },
250+
triggerId: { type: 'string', nullable: true },
251251
},
252-
required: ['command', 'roomId', 'triggerId'],
252+
required: ['command', 'roomId'],
253253
additionalProperties: false,
254254
});
255255

apps/meteor/tests/end-to-end/api/commands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('[Commands]', () => {
124124
.expect(400)
125125
.expect((res) => {
126126
expect(res.body).to.have.property('success', false);
127-
expect(res.body.error).to.be.equal('You must provide a command to run.');
127+
expect(res.body.error).to.be.equal("must have required property 'command'");
128128
})
129129
.end(done);
130130
});
@@ -139,7 +139,7 @@ describe('[Commands]', () => {
139139
.expect(400)
140140
.expect((res) => {
141141
expect(res.body).to.have.property('success', false);
142-
expect(res.body.error).to.be.equal('The parameters for the command must be a single string.');
142+
expect(res.body.error).to.include('must be string');
143143
})
144144
.end(done);
145145
});
@@ -154,7 +154,7 @@ describe('[Commands]', () => {
154154
.expect(400)
155155
.expect((res) => {
156156
expect(res.body).to.have.property('success', false);
157-
expect(res.body.error).to.be.equal("The room's id where to execute this command must be provided and be a string.");
157+
expect(res.body.error).to.be.equal("must have required property 'roomId'");
158158
})
159159
.end(done);
160160
});
@@ -171,7 +171,7 @@ describe('[Commands]', () => {
171171
.expect(400)
172172
.expect((res) => {
173173
expect(res.body).to.have.property('success', false);
174-
expect(res.body.error).to.be.equal('The tmid parameter when provided must be a string.');
174+
expect(res.body.error).to.include('must be string');
175175
})
176176
.end(done);
177177
});

apps/meteor/tests/end-to-end/apps/slash-command-test-simple.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { IS_EE } from '../../e2e/config/constants';
2727
.expect(400)
2828
.expect((res) => {
2929
expect(res.body).to.have.a.property('success', false);
30-
expect(res.body.error).to.be.equal('You must provide a command to run.');
30+
expect(res.body.error).to.include('must be string');
3131
})
3232
.end(done);
3333
});

0 commit comments

Comments
 (0)