mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
chore(server): improve e2e test speed (#5026)
* feat: improve shared link (41s to 8s) * feat: improve activity (18s to 8s) * feat: improve partner (20s to 10s) * feat: improve server-info (10s to 6s) * feat: improve system-config * fix: e2e * chore: linting
This commit is contained in:
parent
6214d510d6
commit
6127fd4c5c
12 changed files with 307 additions and 226 deletions
|
|
@ -6,24 +6,31 @@ import { errorStub } from '@test/fixtures';
|
|||
import { testApp } from '@test/test-utils';
|
||||
import request from 'supertest';
|
||||
|
||||
const user1Dto = {
|
||||
email: 'user1@immich.app',
|
||||
password: 'Password123',
|
||||
name: 'User 1',
|
||||
};
|
||||
|
||||
describe(`${SystemConfigController.name} (e2e)`, () => {
|
||||
let server: any;
|
||||
let admin: LoginResponseDto;
|
||||
let nonAdmin: LoginResponseDto;
|
||||
|
||||
beforeAll(async () => {
|
||||
[server] = await testApp.create();
|
||||
|
||||
await db.reset();
|
||||
await api.authApi.adminSignUp(server);
|
||||
admin = await api.authApi.adminLogin(server);
|
||||
await api.userApi.create(server, admin.accessToken, user1Dto);
|
||||
nonAdmin = await api.authApi.login(server, user1Dto);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await testApp.teardown();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await db.reset();
|
||||
await api.authApi.adminSignUp(server);
|
||||
admin = await api.authApi.adminLogin(server);
|
||||
});
|
||||
|
||||
describe('GET /system-config/map/style.json', () => {
|
||||
it('should require authentication', async () => {
|
||||
const { status, body } = await request(server).get('/system-config/map/style.json');
|
||||
|
|
@ -61,16 +68,10 @@ describe(`${SystemConfigController.name} (e2e)`, () => {
|
|||
});
|
||||
|
||||
it('should not require admin authentication', async () => {
|
||||
const credentials = { email: 'user1@immich.app', password: 'Password123' };
|
||||
await api.userApi.create(server, admin.accessToken, {
|
||||
...credentials,
|
||||
name: 'User 1',
|
||||
});
|
||||
const { accessToken } = await api.authApi.login(server, credentials);
|
||||
const { status, body } = await request(server)
|
||||
.get('/system-config/map/style.json')
|
||||
.query({ theme: 'dark' })
|
||||
.set('Authorization', `Bearer ${accessToken}`);
|
||||
.set('Authorization', `Bearer ${nonAdmin.accessToken}`);
|
||||
expect(status).toBe(200);
|
||||
expect(body).toEqual(expect.objectContaining({ id: 'immich-map-dark' }));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue