From ecf9bee3595e1e3e67f7514d2af16e87753feeba Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 25 Oct 2022 10:50:12 +0530 Subject: [PATCH] test(api): add tests for invite only signup Signed-off-by: Pranav C --- .../nocodb/tests/unit/rest/tests/org.test.ts | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/tests/unit/rest/tests/org.test.ts b/packages/nocodb/tests/unit/rest/tests/org.test.ts index fb45b20bf9..a57eb80d38 100644 --- a/packages/nocodb/tests/unit/rest/tests/org.test.ts +++ b/packages/nocodb/tests/unit/rest/tests/org.test.ts @@ -135,7 +135,7 @@ function authTests() { }) - it.only('Delete token', async () => { + it('Delete token', async () => { const r = await request(context.app) .post('/api/v1/tokens') .set('xc-auth', context.token) @@ -166,6 +166,48 @@ function authTests() { }) + it('Disable/Enable signup', async () => { + const args = { + email: 'dummyuser@example.com', + password: 'A1234abh2@dsad', + }; + + const failedRes = await request(context.app) + .post('/api/v1/auth/user/signup') + .send(args) + .expect(400) + + expect(failedRes.body).to.be.an('object') + .to.have.property('msg') + .to.be.equal('Not allowed to signup, contact super admin.') + + await request(context.app) + .post('/api/v1/app-settings') + .set('xc-auth', context.token) + .send({ enable_user_signup: true }) + .expect(200) + + + const successRes = await request(context.app) + .post('/api/v1/auth/user/signup') + .send(args) + .expect(200) + + expect(successRes.body).to.be.an('object') + .to.have.property('token') + .to.be.a('string') + + + const userMeRes = await request(context.app) + .get('/api/v1/auth/user/me') + .set('xc-auth', successRes.body.token) + .expect(200) + + expect(userMeRes.body).to.be.an('object') + .to.have.property('email') + .to.be.eq(args.email) + }) + } export default function() {