Skip to content
Merged
9 changes: 5 additions & 4 deletions .github/workflows/e2e.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run E2E Tests

on:
pull_request:
branches: [ main ]
branches: [ master ]

jobs:
run-e2e-tests:
Expand All @@ -19,7 +19,7 @@ jobs:
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-cmd "pg_isready -U docker -d apisolid"
--health-interval 10s
--health-timeout 5s
--health-retries 5
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Node.js
- name: Setup Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
Expand All @@ -43,4 +43,5 @@ jobs:
- name: Run E2E Tests
env:
DATABASE_URL: "postgresql://docker:docker@localhost:5432/apisolid?schema=public"
run: npm run test:e2e
JWT_SECRET: "qualquer-segredo-para-testes"
run: npm run test:e2e
3 changes: 1 addition & 2 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ jobs:
- name: Setup Node.js v20
uses: actions/setup-node@v4
with:
# Mantendo a consistência com seu Dockerfile
node-version: 20
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Run Unit Tests
run: npm run test
run: npm run test
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
4 changes: 2 additions & 2 deletions src/http/controllers/check-ins/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export async function create(request: FastifyRequest, reply: FastifyReply) {

const checkInUseCase = makeCheckInUseCase()

await checkInUseCase.execute({
const { checkIn } = await checkInUseCase.execute({
gymId,
userId: request.user.sub, // Assuming the user ID is stored in the request object after JWT verification
userLatitude: latitude,
userLongitude: longitude,
})

return reply.status(201).send()
return reply.status(201).send({ checkIn })
}
2 changes: 1 addition & 1 deletion src/http/controllers/check-ins/validate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Validate Check-in Controller', () => {
.set('Authorization', `Bearer ${token}`)
.send()

expect(response.statusCode).toEqual(204)
expect(response.statusCode).toEqual(200)

checkIn = await prisma.checkIn.findUniqueOrThrow({
where: {
Expand Down
4 changes: 3 additions & 1 deletion src/http/controllers/check-ins/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ export async function validate(request: FastifyRequest, reply: FastifyReply) {
checkInId,
})

return reply.status(204).send()
return reply.status(200).send({
message: 'Check-in validated successfully',
})
}
4 changes: 3 additions & 1 deletion src/http/controllers/gyms/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ export async function create(request: FastifyRequest, reply: FastifyReply) {

const makeCreateGymUseCase = makeCreateGymsUseCase()

await makeCreateGymUseCase.execute({
const { gym } = await makeCreateGymUseCase.execute({
title,
description,
phone,
latitude,
longitude,
})


return reply.status(201).send({
gym,
})

}