Skip to content

Commit 3145c41

Browse files
Copilotggazzo
andauthored
test: Add API test for users.register with authenticated credentials (#38864)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ggazzo <guilherme@gazzo.xyz>
1 parent 27448fe commit 3145c41

File tree

1 file changed

+19
-0
lines changed
  • apps/meteor/tests/end-to-end/api

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,25 @@ describe('[Users]', () => {
886886
})
887887
.end(done);
888888
});
889+
890+
it('should return an error when logged in user tries to register', (done) => {
891+
void request
892+
.post(api('users.register'))
893+
.set(credentials)
894+
.send({
895+
email: `newuser${Date.now()}@email.com`,
896+
name: 'New User',
897+
username: `newuser${Date.now()}`,
898+
pass: 'P@ssw0rd1234.!',
899+
})
900+
.expect('Content-Type', 'application/json')
901+
.expect(400)
902+
.expect((res) => {
903+
expect(res.body).to.have.property('success', false);
904+
expect(res.body).to.have.property('error').and.to.be.equal('Logged in users can not register again.');
905+
})
906+
.end(done);
907+
});
889908
});
890909

891910
describe('[/users.info]', () => {

0 commit comments

Comments
 (0)