ToolJet/server/test/controllers/comment.e2e-spec.ts
Midhun G S 0545528504
Support for multiple workspaces 🚀 (#2778)
* multi org changes

* Initial changes

* changes

* manage sso page

* Multi-organization changes

* Multi organization changes

* multi-org changes

* multi-org changes

* multi-org changes

* multi-org fixes

* env variables app.json changes

* multi-org-fix

* user invitation token fix

* multi-org group permission fix

* multi-org app privilege

* google oauth fix

* Remove enable signup for form login

* Multi organization fixes

* multi-org user invite flow changes

* multi-org sign up fix

* rebase and multi-org fixes

* revert testing logs

* test logs revert

* migration changes

* migration file fix

* error message changes

* git login for private email fix

* dropdown fix

* test cases

* e2e test cases added

* test cases fix

* documentation changes

* testcases fix

* testcases added

* replace findOne with findOneOrFail

* accept invite testcases

* login page fixes

* added encrypted tag

* review comments

* migration fixes

* improvements

* manage sso loading fix

* review comments

* migration file changes

* new organization creation bug fix

* added e2e testcases

* added testcases

* Update data_sources.controller.ts
2022-05-05 12:38:42 +05:30

55 lines
1.4 KiB
TypeScript

import * as request from 'supertest';
import { INestApplication } from '@nestjs/common';
import {
authHeaderForUser,
createThread,
clearDB,
createApplication,
createUser,
createNestAppInstance,
createApplicationVersion,
} from '../test.helper';
describe('comment controller', () => {
let app: INestApplication;
beforeEach(async () => {
await clearDB();
});
beforeAll(async () => {
app = await createNestAppInstance();
});
it('should allow only authenticated users to list comments', async () => {
await request(app.getHttpServer()).get('/api/comments/1234/all').expect(401);
});
it('should list all comments in a thread', async () => {
const userData = await createUser(app, { email: 'admin@tooljet.io' });
const { user } = userData;
const application = await createApplication(app, {
name: 'App to clone',
user,
});
const version = await createApplicationVersion(app, application);
const thread = await createThread(app, {
appId: application.id,
x: 100,
y: 200,
userId: userData.user.id,
organizationId: user.organizationId,
appVersionsId: version.id,
});
const response = await request(app.getHttpServer())
.get(`/api/comments/${thread.id}/all`)
.set('Authorization', authHeaderForUser(user));
expect(response.statusCode).toBe(200);
});
});