Skip to content

Commit

Permalink
Merge pull request #157 from wizelineacademy/cypress-fix
Browse files Browse the repository at this point in the history
fix: Fixed API interception in cypress tests
  • Loading branch information
JulioEmmmanuel authored Jun 12, 2024
2 parents 134edf9 + 64d7724 commit 8f97af3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cypress/e2e/CreateChallenge.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ describe('CreateChallenge Component', () => {

it('should submit the form with valid input', () => {
cy.intercept('POST', '/api/challenges', {}).as('createChallenge')
cy.intercept('GET', '/api/healthdata', {}).as('getData')
cy.intercept('GET', '/api/membership', {}).as('getMembership')

// Llena el formulario con valores válidos
cy.get('input[id="name"]').type('My Challenge')
Expand Down
6 changes: 6 additions & 0 deletions cypress/e2e/GeneralData.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
describe('GeneralData E2E Test', () => {
beforeEach(() => {
cy.login()
// Cambia esta ruta a la ruta donde se monta tu componente
cy.visit('/home/generalData')
cy.getSubscription()
})

it('renders the page correctly', () => {
Expand All @@ -22,6 +24,8 @@ describe('GeneralData E2E Test', () => {
},
}).as('getHealthData')

cy.intercept('POST', '/api/healthdata', {}).as('sendData')

// Ensure the page has loaded the initial data
cy.wait('@getHealthData')

Expand Down Expand Up @@ -66,6 +70,8 @@ describe('GeneralData E2E Test', () => {
},
}).as('getHealthData')

cy.intercept('POST', '/api/healthdata', {}).as('sendData')

// Ensure the page has loaded the initial data
cy.wait('@getHealthData')

Expand Down
2 changes: 2 additions & 0 deletions src/app/(pages)/(main)/home/generalData/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ const GeneralData = () => {
{!editMode ? (
<div className='mb-6 ml-2 flex lg:items-center lg:justify-center'>
<button
type='button'
onClick={() => setEditMode(true)}
className='mt-2 w-60 rounded-full bg-button-home py-2 text-2xl text-white'
>
Expand All @@ -294,6 +295,7 @@ const GeneralData = () => {
<>
<div className='mb-6 ml-2 flex lg:items-center lg:justify-center'>
<button
type='button'
onClick={handleCancelEdit}
className='mr-6 mt-2 w-60 rounded-full bg-mid-red px-3 py-2 text-2xl text-white'
>
Expand Down

0 comments on commit 8f97af3

Please sign in to comment.