Skip to content
Snippets Groups Projects
Commit b2fee6fe authored by Valdemar Åstorp Beere's avatar Valdemar Åstorp Beere
Browse files

test(homepage):

Add more e2e tests to homeView.cy.ts
parent a8db2693
No related branches found
No related tags found
3 merge requests!66Final merge,!32refactor(component):,!4Pipeline fix
...@@ -41,4 +41,55 @@ describe('Goals and Challenges Page Load', () => { ...@@ -41,4 +41,55 @@ describe('Goals and Challenges Page Load', () => {
cy.get('[data-cy=goal-title]').should('exist').and('contain', 'gaming'); cy.get('[data-cy=goal-title]').should('exist').and('contain', 'gaming');
cy.get('[data-cy=challenge-title]').should('exist').and('contain', 'Coffee Challenge'); cy.get('[data-cy=challenge-title]').should('exist').and('contain', 'Coffee Challenge');
}); });
it('Should increment a challenges progress when the increment button is clicked', () => {
cy.wait('@fetchChallenges');
// Separate aliases for clarity
cy.intercept('PUT', '/users/me/challenges/1', {
statusCode: 200,
body: {
id: 1,
title: 'Coffee Challenge',
type: 'coffee',
perPurchase: 20,
saved: 80, // this is the updated amount
target: 100,
completion: 80,
},
}).as('incrementChallenge1');
cy.intercept('PUT', '/users/me/goals/1', {
statusCode: 200,
body: { id: 1, title: 'gaming', saved: 170, target: 1000, completion: 15 },
}).as('incrementChallenge');
// Mock the POST request for renewing the token if it's not implemented in the backend
cy.intercept('POST', '/auth/renewToken', {
statusCode: 200,
body: {
accessToken: 'newlyRenewedAccessToken'
}
}).as('renewToken');
cy.get('[data-cy=increment-challenge1]').click();
cy.wait('@incrementChallenge1'); // Wait for the specific challenge update intercept
// Check if the progress bar reflects the right percentage
cy.get('[data-cy=challenge-progress]')
.invoke('attr', 'style')
.should('contain', 'width: 80%'); // Directly check the style attribute for the width
});
it('Should navigate to the spare challenges page when adding a new challenge', () => {
// Mock the routing to the spare challenges page
cy.intercept('GET', '/spareutfordringer', {
statusCode: 200,
body: { content: 'Spare Challenges Page' }
}).as('spareChallenges');
// Trigger the route change
cy.get('[data-cy=challenge-icon-1]').click();
// Assert that navigation has occurred
cy.url().should('include', '/spareutfordringer/1');
});
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment