diff --git a/src/controller/project/createProject.spec.ts b/src/controller/project/createProject.spec.ts index bfff782..bb894b9 100644 --- a/src/controller/project/createProject.spec.ts +++ b/src/controller/project/createProject.spec.ts @@ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' import request from 'supertest' import { app } from '../../app' import { randomUUID } from 'crypto' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' let userAuth: { token: string @@ -50,6 +50,7 @@ describe('createProject E2E', () => { const response = await request(app.server) .post(`/user/${userId}/project`) .send(createProjectBody) + .set('Authorization', `Bearer ${userAuth.token}`) expect(response.body.message).toContain('User was not Found !') diff --git a/src/controller/project/deleteProjectById.spec.ts b/src/controller/project/deleteProjectById.spec.ts index 1f94550..e142b01 100644 --- a/src/controller/project/deleteProjectById.spec.ts +++ b/src/controller/project/deleteProjectById.spec.ts @@ -4,7 +4,7 @@ import { ProjectRepository } from '../../repositories/project-repository' import { PrismaProjectRepository } from '../../repositories/prisma/prisma-project-repository' import { app } from '../../app' import { randomUUID } from 'crypto' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' let projectRepository: ProjectRepository diff --git a/src/controller/project/editProject.spec.ts b/src/controller/project/editProject.spec.ts index 20d0832..a7f6c12 100644 --- a/src/controller/project/editProject.spec.ts +++ b/src/controller/project/editProject.spec.ts @@ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' import request from 'supertest' import { app } from '../../app' import { randomUUID } from 'crypto' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' let userAuth: { token: string diff --git a/src/controller/project/getProjectById.spec.ts b/src/controller/project/getProjectById.spec.ts index e8a28e5..a33697b 100644 --- a/src/controller/project/getProjectById.spec.ts +++ b/src/controller/project/getProjectById.spec.ts @@ -5,7 +5,7 @@ import { ProjectRepository } from '../../repositories/project-repository' import { PrismaProjectRepository } from '../../repositories/prisma/prisma-project-repository' import { randomUUID } from 'crypto' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' let projectRepository: ProjectRepository diff --git a/src/controller/project/getProjectsByTags.spec.ts b/src/controller/project/getProjectsByTags.spec.ts index fb7c689..21a952c 100644 --- a/src/controller/project/getProjectsByTags.spec.ts +++ b/src/controller/project/getProjectsByTags.spec.ts @@ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' import request from 'supertest' import { app } from '../../app' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' let userAuth: { token: string userId: string diff --git a/src/controller/project/getProjectsByUserId.spec.ts b/src/controller/project/getProjectsByUserId.spec.ts index 22243cf..c74852f 100644 --- a/src/controller/project/getProjectsByUserId.spec.ts +++ b/src/controller/project/getProjectsByUserId.spec.ts @@ -4,7 +4,7 @@ import { app } from '../../app' import { ProjectRepository } from '../../repositories/project-repository' import { PrismaProjectRepository } from '../../repositories/prisma/prisma-project-repository' import { randomUUID } from 'crypto' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' let projectRepository: ProjectRepository diff --git a/src/controller/user/editUserById.spec.ts b/src/controller/user/editUserById.spec.ts index f070b97..8469036 100644 --- a/src/controller/user/editUserById.spec.ts +++ b/src/controller/user/editUserById.spec.ts @@ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' import request from 'supertest' import { app } from '../../app' import { randomUUID } from 'crypto' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' let userAuth: { token: string diff --git a/src/controller/user/getUserByEmail.spec.ts b/src/controller/user/getUserByEmail.spec.ts index 956627c..c369ad4 100644 --- a/src/controller/user/getUserByEmail.spec.ts +++ b/src/controller/user/getUserByEmail.spec.ts @@ -1,7 +1,7 @@ import { afterAll, beforeAll, describe, expect, test } from 'vitest' import request from 'supertest' import { app } from '../../app' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' let userAuth: { token: string diff --git a/src/controller/user/getUserById.spec.ts b/src/controller/user/getUserById.spec.ts index f552486..7ba71b8 100644 --- a/src/controller/user/getUserById.spec.ts +++ b/src/controller/user/getUserById.spec.ts @@ -1,7 +1,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' import request from 'supertest' import { app } from '../../app' -import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user' +import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user' import { randomUUID } from 'crypto' let userAuth: { diff --git a/src/use-cases/project/getProjectsByIdUseCase.spec.ts b/src/use-cases/project/getProjectsByIdUseCase.spec.ts index 2cdd923..cc7619c 100644 --- a/src/use-cases/project/getProjectsByIdUseCase.spec.ts +++ b/src/use-cases/project/getProjectsByIdUseCase.spec.ts @@ -3,6 +3,7 @@ import { expect, describe, it, beforeEach } from 'vitest' import { InMemoryProjectRepository } from '../../repositories/in-memory-db/inMemoryProjectRepository' import { ResourceNotFoundError } from '../errors/ResourceNotFoundError' import { GetProjectsByIdUseCase } from './getProjectsByIdUseCase' +import { defaultUserAvatarUrl } from '../../utils/tests/defaultUserAvatarUrl' let projectRepository: InMemoryProjectRepository let getProjectByIdUseCase: GetProjectsByIdUseCase @@ -37,7 +38,11 @@ describe('Get Project By Id Use Case', () => { title: 'React Typescript 1', id: newProject.id, tags: ['react', 'node'], - user: { name: 'John', surname: 'Doe', avatar_url: null }, + user: { + name: 'John', + surname: 'Doe', + avatar_url: defaultUserAvatarUrl, + }, }), ) }) diff --git a/src/use-cases/project/getProjetsByTagsUseCase.spec.ts b/src/use-cases/project/getProjetsByTagsUseCase.spec.ts index 95396b6..0080d61 100644 --- a/src/use-cases/project/getProjetsByTagsUseCase.spec.ts +++ b/src/use-cases/project/getProjetsByTagsUseCase.spec.ts @@ -4,6 +4,7 @@ import { InMemoryProjectRepository } from '../../repositories/in-memory-db/inMem import { GetProjectsByTagsUseCase } from './getProjetsByTagsUseCase' import { User } from '@prisma/client' +import { defaultUserAvatarUrl } from '../../utils/tests/defaultUserAvatarUrl' let projectRepository: InMemoryProjectRepository let getProjectsByTagsUseCase: GetProjectsByTagsUseCase @@ -49,7 +50,7 @@ describe('Get Project By Tags', () => { user: { name: newUser.name, surname: newUser.surname, - avatar_url: null, + avatar_url: defaultUserAvatarUrl, }, tags: ['react', 'node', 'typescript'], }), @@ -92,7 +93,7 @@ describe('Get Project By Tags', () => { user: { name: newUser.name, surname: newUser.surname, - avatar_url: null, + avatar_url: defaultUserAvatarUrl, }, }), ) @@ -103,7 +104,7 @@ describe('Get Project By Tags', () => { user: { name: newUser.name, surname: newUser.surname, - avatar_url: null, + avatar_url: defaultUserAvatarUrl, }, }), ) @@ -114,7 +115,7 @@ describe('Get Project By Tags', () => { user: { name: newUser.name, surname: newUser.surname, - avatar_url: null, + avatar_url: defaultUserAvatarUrl, }, }), ) @@ -156,7 +157,7 @@ describe('Get Project By Tags', () => { user: { name: newUser.name, surname: newUser.surname, - avatar_url: null, + avatar_url: defaultUserAvatarUrl, }, }), ) @@ -167,7 +168,7 @@ describe('Get Project By Tags', () => { user: { name: newUser.name, surname: newUser.surname, - avatar_url: null, + avatar_url: defaultUserAvatarUrl, }, }), ) @@ -178,7 +179,7 @@ describe('Get Project By Tags', () => { user: { name: newUser.name, surname: newUser.surname, - avatar_url: null, + avatar_url: defaultUserAvatarUrl, }, }), ) diff --git a/src/utils/create-and-authenticate-user.ts b/src/utils/tests/create-and-authenticate-user.ts similarity index 100% rename from src/utils/create-and-authenticate-user.ts rename to src/utils/tests/create-and-authenticate-user.ts diff --git a/src/utils/tests/defaultUserAvatarUrl.ts b/src/utils/tests/defaultUserAvatarUrl.ts new file mode 100644 index 0000000..b5a1f78 --- /dev/null +++ b/src/utils/tests/defaultUserAvatarUrl.ts @@ -0,0 +1,2 @@ +export const defaultUserAvatarUrl = + 'https://orangeapp-contents-prod.s3.amazonaws.com/avatar1.png' diff --git a/tsup.config.ts b/tsup.config.ts index c2f0343..74177ce 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,9 +1,5 @@ import { defineConfig } from 'tsup' export default defineConfig({ - entry: [ - 'src', - '!src/**/*.spec.*', - '!src/utils/create-and-authenticate-user.ts', - ], + entry: ['src', '!src/**/*.spec.*', '!src/utils/tests/**'], })