mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor: migrate some e2e to medium (#17640)
This commit is contained in:
parent
f50e5d006c
commit
8cefa0b84b
20 changed files with 547 additions and 115 deletions
60
server/test/medium/specs/controllers/auth.controller.spec.ts
Normal file
60
server/test/medium/specs/controllers/auth.controller.spec.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { AuthController } from 'src/controllers/auth.controller';
|
||||
import { AuthService } from 'src/services/auth.service';
|
||||
import request from 'supertest';
|
||||
import { errorDto } from 'test/medium/responses';
|
||||
import { createControllerTestApp, TestControllerApp } from 'test/medium/utils';
|
||||
|
||||
describe(AuthController.name, () => {
|
||||
let app: TestControllerApp;
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await createControllerTestApp();
|
||||
});
|
||||
|
||||
describe('POST /auth/admin-sign-up', () => {
|
||||
const name = 'admin';
|
||||
const email = 'admin@immich.cloud';
|
||||
const password = 'password';
|
||||
|
||||
const invalid = [
|
||||
{
|
||||
should: 'require an email address',
|
||||
data: { name, password },
|
||||
},
|
||||
{
|
||||
should: 'require a password',
|
||||
data: { name, email },
|
||||
},
|
||||
{
|
||||
should: 'require a name',
|
||||
data: { email, password },
|
||||
},
|
||||
{
|
||||
should: 'require a valid email',
|
||||
data: { name, email: 'immich', password },
|
||||
},
|
||||
];
|
||||
|
||||
for (const { should, data } of invalid) {
|
||||
it(`should ${should}`, async () => {
|
||||
const { status, body } = await request(app.getHttpServer()).post('/auth/admin-sign-up').send(data);
|
||||
expect(status).toEqual(400);
|
||||
expect(body).toEqual(errorDto.badRequest());
|
||||
});
|
||||
}
|
||||
|
||||
it('should transform email to lower case', async () => {
|
||||
const { status } = await request(app.getHttpServer())
|
||||
.post('/auth/admin-sign-up')
|
||||
.send({ name: 'admin', password: 'password', email: 'aDmIn@IMMICH.cloud' });
|
||||
expect(status).toEqual(201);
|
||||
expect(app.getMockedService(AuthService).adminSignUp).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ email: 'admin@immich.cloud' }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue