Skip to content

Commit

Permalink
Addressing code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
uLucasFraga authored and stefanteixeira committed Aug 3, 2022
1 parent 25775a7 commit c650234
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/api/cart.api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ test.describe.parallel('Carts API', () => {
})

test('retrieves an existing cart by its id', async ({ request }) => {
const idProduct = await getProductId(request, authorization, getProductBody())
const _id = await getCartId(request, authorization, getCartBody(idProduct))
const productId = await getProductId(request, authorization, getProductBody())
const cartId = await getCartId(request, authorization, getCartBody(productId))

const response = await request.get(`/carrinhos/${_id}`)
const response = await request.get(`/carrinhos/${cartId}`)

await expect(response).toBeOK()
})

test('creates a cart successfully', async ({ request }) => {
const authorization = await getAuthToken(request)
const idProduct = await getProductId(request, authorization, getProductBody())
const productId = await getProductId(request, authorization, getProductBody())

const response = await request.post('/carrinhos', {
data: getCartBody(idProduct),
data: getCartBody(productId),
headers: { 'Authorization': authorization }
})
const responseBody = JSON.parse(await response.text())
Expand All @@ -39,7 +39,7 @@ test.describe.parallel('Carts API', () => {
expect(responseBody.message).toEqual(POST_SUCESS)
})

test('delete an order successfully', async ({ request }) => {
test('deletes an order successfully', async ({ request }) => {
const idProduct = await getProductId(request, authorization, getProductBody())
await getCartId(request, authorization, getCartBody(idProduct))

Expand All @@ -54,7 +54,7 @@ test.describe.parallel('Carts API', () => {
await expect(responseBody.message).toBe('Registro excluído com sucesso')
})

test('delete an order without a cart', async ({ request }) => {
test('deletes an order without a cart', async ({ request }) => {
const response = await request.delete('/carrinhos/concluir-compra', {
headers: { 'Authorization': authorization }
})
Expand All @@ -66,7 +66,7 @@ test.describe.parallel('Carts API', () => {
await expect(responseBody.message).toBe('Não foi encontrado carrinho para esse usuário')
})

test('delete an order without a token', async ({ request }) => {
test('fails to delete an order if authorization token is not provided', async ({ request }) => {
const response = await request.delete('/carrinhos/concluir-compra', {
headers: { 'Authorization': '' }
})
Expand All @@ -78,7 +78,7 @@ test.describe.parallel('Carts API', () => {
await expect(responseBody.message).toBe('Token de acesso ausente, inválido, expirado ou usuário do token não existe mais')
})

test('cancel an order successfully', async ({ request }) => {
test('cancels an order successfully', async ({ request }) => {
const idProduct = await getProductId(request, authorization, getProductBody())
await getCartId(request, authorization, getCartBody(idProduct))

Expand All @@ -93,7 +93,7 @@ test.describe.parallel('Carts API', () => {
await expect(responseBody.message).toBe('Registro excluído com sucesso. Estoque dos produtos reabastecido')
})

test('cancel an order without a cart', async ({ request }) => {
test('cancels an order without a cart', async ({ request }) => {
const response = await request.delete('/carrinhos/cancelar-compra', {
headers: { 'Authorization': authorization }
})
Expand All @@ -105,7 +105,7 @@ test.describe.parallel('Carts API', () => {
await expect(responseBody.message).toBe('Não foi encontrado carrinho para esse usuário')
})

test('cancel an order without a token', async ({ request }) => {
test('fails to cancel an order if authorization token is not provided', async ({ request }) => {
const response = await request.delete('/carrinhos/cancelar-compra', {
headers: { 'Authorization': '' }
})
Expand Down

0 comments on commit c650234

Please sign in to comment.