Skip to content

Commit 606cbcc

Browse files
ggazzoclaude
andcommitted
refactor(tests): update test assertions for OpenAPI migration
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8c2f2e0 commit 606cbcc

3 files changed

Lines changed: 39 additions & 43 deletions

File tree

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

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,22 +124,24 @@ 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
});
131+
131132
it('should return an error when call the endpoint with the param "params" and it is not a string', (done) => {
132133
void request
133134
.post(api('commands.run'))
134135
.set(credentials)
135136
.send({
136137
command: 'help',
138+
roomId: 'GENERAL',
137139
params: true,
138140
})
139141
.expect(400)
140142
.expect((res) => {
141143
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.');
144+
expect(res.body.error).to.include('must be string');
143145
})
144146
.end(done);
145147
});
@@ -154,7 +156,7 @@ describe('[Commands]', () => {
154156
.expect(400)
155157
.expect((res) => {
156158
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.");
159+
expect(res.body.error).to.be.equal("must have required property 'roomId'");
158160
})
159161
.end(done);
160162
});
@@ -171,7 +173,7 @@ describe('[Commands]', () => {
171173
.expect(400)
172174
.expect((res) => {
173175
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.');
176+
expect(res.body.error).to.include('must be string');
175177
})
176178
.end(done);
177179
});
@@ -437,11 +439,6 @@ describe('[Commands]', () => {
437439
roomId: channel._id,
438440
command: 'invite-all-from',
439441
params: `#${group.name}`,
440-
msg: {
441-
_id: Random.id(),
442-
rid: channel._id,
443-
msg: `invite-all-from #${group.name}`,
444-
},
445442
triggerId: Random.id(),
446443
})
447444
.expect(200)
@@ -468,16 +465,11 @@ describe('[Commands]', () => {
468465
roomId: group1._id,
469466
command: 'invite-all-from',
470467
params: `#${group.name}`,
471-
msg: {
472-
_id: Random.id(),
473-
rid: group1._id,
474-
msg: `invite-all-from #${group.name}`,
475-
},
476468
triggerId: Random.id(),
477469
})
478470
.expect(403)
479471
.expect((res) => {
480-
expect(res.body).to.have.a.property('error', 'unauthorized');
472+
expect(res.body).to.have.a.property('error', 'Not allowed');
481473
});
482474
});
483475

@@ -498,11 +490,6 @@ describe('[Commands]', () => {
498490
roomId: channel._id,
499491
command: 'invite-all-from',
500492
params: `#${group.name}`,
501-
msg: {
502-
_id: Random.id(),
503-
rid: channel._id,
504-
msg: `invite-all-from #${group.name}`,
505-
},
506493
triggerId: Random.id(),
507494
})
508495
.expect(200)

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

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,30 +2358,39 @@ describe('[Rooms]', () => {
23582358
});
23592359
});
23602360

2361-
it('should update group name if user changes name', async () => {
2362-
await updateSetting('UI_Use_Real_Name', true);
2363-
await request
2364-
.post(api('users.update'))
2365-
.set(credentials)
2366-
.send({
2367-
userId: testUser._id,
2368-
data: {
2369-
name: `changed.name.${testUser.username}`,
2370-
},
2371-
});
2361+
describe('use real name', () => {
2362+
before(async () => {
2363+
await updateSetting('UI_Use_Real_Name', true);
2364+
});
23722365

2373-
// need to wait for the name update finish
2374-
await sleep(300);
2366+
after(async () => {
2367+
await updateSetting('UI_Use_Real_Name', false);
2368+
});
23752369

2376-
await request
2377-
.get(api('subscriptions.getOne'))
2378-
.set(credentials)
2379-
.query({ roomId })
2380-
.send()
2381-
.expect((res) => {
2382-
const { subscription } = res.body;
2383-
expect(subscription.fname).to.equal(`changed.name.${testUser.username}, ${testUser2.name}`);
2384-
});
2370+
it('should update group name if user changes name', async () => {
2371+
await request
2372+
.post(api('users.update'))
2373+
.set(credentials)
2374+
.send({
2375+
userId: testUser._id,
2376+
data: {
2377+
name: `changed.name.${testUser.username}`,
2378+
},
2379+
});
2380+
2381+
// need to wait for the name update finish
2382+
await sleep(300);
2383+
2384+
await request
2385+
.get(api('subscriptions.getOne'))
2386+
.set(credentials)
2387+
.query({ roomId })
2388+
.send()
2389+
.expect((res) => {
2390+
const { subscription } = res.body;
2391+
expect(subscription.fname).to.equal(`changed.name.${testUser.username}, ${testUser2.name}`);
2392+
});
2393+
});
23852394
});
23862395
});
23872396

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)