test(server): auth e2e (#3492)

* test(server): auth controller e2e test

* test(server): user e2e test

* refactor(server): album e2e

* fix: linting
This commit is contained in:
Jason Rasmussen
2023-08-01 11:49:50 -04:00
committed by GitHub
parent 9e085c1071
commit e53625b067
19 changed files with 927 additions and 496 deletions

View File

@@ -1,5 +1,27 @@
import { AuthUserDto } from '@app/domain';
export const signupStub = {
firstName: 'Immich',
lastName: 'Admin',
email: 'admin@immich.app',
password: 'Password123',
};
export const signupResponseStub = {
id: expect.any(String),
email: 'admin@immich.app',
firstName: 'Immich',
lastName: 'Admin',
createdAt: expect.any(String),
};
export const loginStub = {
admin: {
email: 'admin@immich.app',
password: 'Password123',
},
};
export const authStub = {
admin: Object.freeze<AuthUserDto>({
id: 'admin_id',
@@ -76,6 +98,18 @@ export const authStub = {
};
export const loginResponseStub = {
admin: {
response: {
accessToken: expect.any(String),
firstName: 'Immich',
isAdmin: true,
lastName: 'Admin',
profileImagePath: '',
shouldChangePassword: true,
userEmail: 'admin@immich.app',
userId: expect.any(String),
},
},
user1oauth: {
response: {
accessToken: 'cmFuZG9tLWJ5dGVz',

10
server/test/fixtures/device.stub.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
export const deviceStub = {
current: {
id: expect.any(String),
createdAt: expect.any(String),
updatedAt: expect.any(String),
current: true,
deviceOS: '',
deviceType: '',
},
};

32
server/test/fixtures/error.stub.ts vendored Normal file
View File

@@ -0,0 +1,32 @@
export const errorStub = {
unauthorized: {
error: 'Unauthorized',
statusCode: 401,
message: 'Authentication required',
},
wrongPassword: {
error: 'Bad Request',
statusCode: 400,
message: 'Wrong password',
},
invalidToken: {
error: 'Unauthorized',
statusCode: 401,
message: 'Invalid user token',
},
badRequest: {
error: 'Bad Request',
statusCode: 400,
message: expect.any(Array),
},
incorrectLogin: {
error: 'Unauthorized',
statusCode: 401,
message: 'Incorrect email or password',
},
alreadyHasAdmin: {
error: 'Bad Request',
statusCode: 400,
message: 'The server already has an admin',
},
};

View File

@@ -2,6 +2,8 @@ export * from './album.stub';
export * from './api-key.stub';
export * from './asset.stub';
export * from './auth.stub';
export * from './device.stub';
export * from './error.stub';
export * from './face.stub';
export * from './file.stub';
export * from './media.stub';
@@ -13,3 +15,4 @@ export * from './system-config.stub';
export * from './tag.stub';
export * from './user-token.stub';
export * from './user.stub';
export * from './uuid.stub';

4
server/test/fixtures/uuid.stub.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
export const uuidStub = {
invalid: 'invalid-uuid',
notFound: '00000000-0000-0000-0000-000000000000',
};