Skip to content

Commit

Permalink
fix: Fixed API interception in cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioEmmmanuel committed Jun 12, 2024
1 parent 1cdfc5b commit 64d7724
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 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
6 changes: 3 additions & 3 deletions src/components/Inputs/SleepTimeSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const SleepTimeSelection = ({

<div className='flex gap-x-3'>
<input
className='bg-input-purple rounded-2xl px-2 py-3 text-white md:px-10'
className='rounded-2xl bg-input-purple px-2 py-3 text-white md:px-10'
value={time}
type='time'
onChange={(e) => {
Expand All @@ -30,15 +30,15 @@ export const SleepTimeSelection = ({
onClick={() => {
setDay('Ayer')
}}
className={`${day === 'Ayer' ? 'bg-decoration-sleep-colordark' : 'bg-decoration-sleep-colorlight'} hover:bg-decoration-sleep-colordark rounded-2xl px-5 py-2 md:px-10`}
className={`${day === 'Ayer' ? 'bg-decoration-sleep-colordark' : 'bg-decoration-sleep-colorlight'} rounded-2xl px-5 py-2 hover:bg-decoration-sleep-colordark md:px-10`}
>
Ayer
</button>
<button
onClick={() => {
setDay('Hoy')
}}
className={`${day === 'Hoy' ? 'bg-decoration-sleep-colordark' : 'bg-decoration-sleep-colorlight'} hover:bg-decoration-sleep-colordark rounded-2xl px-5 py-2 md:px-10`}
className={`${day === 'Hoy' ? 'bg-decoration-sleep-colordark' : 'bg-decoration-sleep-colorlight'} rounded-2xl px-5 py-2 hover:bg-decoration-sleep-colordark md:px-10`}
>
Hoy
</button>
Expand Down
4 changes: 2 additions & 2 deletions src/components/information/toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ToggleComponent = ({ title, children, editModeToggle }: ToggleProps) => {
<div className='mt-2'>
<button
onClick={toggleOpen}
className='bg-toggle-title flex w-3/4 items-center justify-between rounded-2xl px-4 py-2 focus:outline-none'
className='flex w-3/4 items-center justify-between rounded-2xl bg-toggle-title px-4 py-2 focus:outline-none'
>
<p className='text-2xl text-white'>{title}</p>
{isOpen ? (
Expand All @@ -40,7 +40,7 @@ const ToggleComponent = ({ title, children, editModeToggle }: ToggleProps) => {
leaveFrom='opacity-100'
leaveTo='opacity-0'
>
<div className='bg-toggle-content mt-2 w-3/4 rounded-2xl px-4 py-2'>
<div className='mt-2 w-3/4 rounded-2xl bg-toggle-content px-4 py-2'>
{children}
</div>
</Transition>
Expand Down

0 comments on commit 64d7724

Please sign in to comment.