ToolJet/server/test/controllers/users.e2e-spec.ts
Akshay 5b30aa2007
Chore: Setup pipeline (#1539)
* github actions for PR and push to develop branch

* test workflow

* move to workflows folder

* add setup node action

* modify build

* specify npm version

* config unit test

* specify host postgres

* specify container to run on

* add postgresql dependency

* add specify ws adapter for test

* add e2e test

* fix linting

* only log errors on tests

* update eslint config

* fix linting

* run e2e test in silent mode

* fix library app spec

* dont send email on test env

* fix org scope

* mock env vars

* remove reset modules

* force colors

* explicitly close db connection

* add eslint rule for floating promises

* update workflow

* fix floating promise

* fix lint

* update workflow

* run on all push and pulls

* update lint check files

* simplify workflow

* increase js heap size on env

* separate lint and build

Co-authored-by: arpitnath <arpitnath42@gmail.com>
2021-12-10 08:43:05 +05:30

44 lines
1.3 KiB
TypeScript

/* eslint-disable @typescript-eslint/no-unused-vars */
import * as request from 'supertest';
import { INestApplication } from '@nestjs/common';
import { authHeaderForUser, clearDB, createUser, createNestAppInstance } from '../test.helper';
import { getConnection } from 'typeorm';
describe('users controller', () => {
let app: INestApplication;
beforeEach(async () => {
await clearDB();
});
beforeAll(async () => {
app = await createNestAppInstance();
jest.setTimeout(10000);
});
describe('update user', () => {
it('should allow users to update their firstName, lastName and password', async () => {
const userData = await createUser(app, { email: 'admin@tooljet.io', role: 'admin' });
const { user } = userData;
const [firstName, lastName] = ['Daenerys', 'Targaryen', 'drogo666'];
const response = await request(app.getHttpServer())
.patch('/api/users/update')
.set('Authorization', authHeaderForUser(user))
.send({ firstName, lastName });
expect(response.statusCode).toBe(200);
await user.reload();
expect(user.firstName).toEqual(firstName);
expect(user.lastName).toEqual(lastName);
});
});
afterAll(async () => {
await getConnection().close();
await app.close();
});
});