mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-06 06:48:21 +00:00
* feat: add user avatar * update: @nest/platform-express from 8.0.0 to 8.4.4 * add avatar_id in login response * add user avatar upload in frontend * align cross divider with layout icons' * generate nest model - extensions * cleanup * fix tests * reduce the avatar size on homepage * fix review comments * import Express * add blob to csp
33 lines
1,011 B
TypeScript
33 lines
1,011 B
TypeScript
import * as request from 'supertest';
|
|
import { INestApplication } from '@nestjs/common';
|
|
import { authHeaderForUser, createFile, clearDB, createUser, createNestAppInstance } from '../test.helper';
|
|
|
|
describe('files controller', () => {
|
|
let app: INestApplication;
|
|
|
|
beforeEach(async () => {
|
|
await clearDB();
|
|
});
|
|
|
|
beforeAll(async () => {
|
|
app = await createNestAppInstance();
|
|
});
|
|
|
|
it('should not allow un-authenticated users to fetch a file', async () => {
|
|
await request(app.getHttpServer()).get('/api/files/2540333b-f6fe-42b7-857c-736f24f9b644').expect(401);
|
|
});
|
|
|
|
it('should allow only authenticated users to fetch a file', async () => {
|
|
const userData = await createUser(app, { email: 'admin@tooljet.io' });
|
|
|
|
const { user } = userData;
|
|
|
|
const file = await createFile(app);
|
|
|
|
const response = await request(app.getHttpServer())
|
|
.get(`/api/files/${file.id}`)
|
|
.set('Authorization', authHeaderForUser(user));
|
|
|
|
expect(response.statusCode).toBe(200);
|
|
});
|
|
});
|