Skip to content

Commit

Permalink
fix fetch url for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-oa committed Sep 14, 2023
1 parent 2326a95 commit 8d55a39
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 34 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/MainPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BASE_URL, SEARCH_TERM } from "./constants"

describe('Main Page', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/')
cy.visit(BASE_URL)
})

it('should render the search input', () => {
Expand All @@ -16,6 +16,6 @@ describe('Main Page', () => {
it('should search for products and redirect', () => {
cy.get('input').type(`${SEARCH_TERM}`)
cy.get('button').click()
cy.url().should('include', `${BASE_URL}/items?search=${SEARCH_TERM}`)
cy.url().should('include', `/items?search=${SEARCH_TERM}`)
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/ProductInfo.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BASE_URL, PRODUCT_ID, SEARCH_TERM } from "./constants"
import { BASE_URL, PRODUCT_ID } from "./constants"

describe('product details page', () => {
beforeEach(() => {
Expand Down
29 changes: 0 additions & 29 deletions src/app/og/route.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/services/getItemDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface Id {
}

export const getItemsDetails = async ({ id }: Id): Promise<ProductI> => {
const data = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/items/${id}`)
const data = await fetch(`${process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000'}/api/items/${id}`)
const res = data.json()

return res
Expand Down
2 changes: 1 addition & 1 deletion src/services/getItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Search = {


export const getItems = async ({ search }: Search): Promise<ProductsI> => {
const data = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/items?q=${search}`)
const data = await fetch(`${process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000'}/api/items?q=${search}`)
const res = data.json()

return res
Expand Down

0 comments on commit 8d55a39

Please sign in to comment.