Skip to content

Commit

Permalink
Fix fragility in Cypress tests (#9867)
Browse files Browse the repository at this point in the history
* refactor assertions to make the tests less fragile

* refactor sort request specs to remove fragility

* fix: eslint issues

Co-authored-by: Graham Dixon <[email protected]>
  • Loading branch information
Jeremy Schuurmans and gdixon authored Dec 10, 2021
1 parent dd5a411 commit 2a18bad
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions cypress/integration/grants/test_grant_explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('Grants Explorer page', () => {

cy.get('.vs__dropdown-menu')
.should('contain', 'Discover')
.should('contain', 'Current Round')
.should('contain', 'All-Time')
.should('contain', 'Weighted Shuffle')
.should('contain', 'Trending')
.should('contain', 'Undiscovered Gems')
Expand All @@ -29,13 +31,10 @@ describe('Grants Explorer page', () => {
.should('contain', 'Oldest')
.should('contain', 'A to Z')
.should('contain', 'Z to A')
.should('contain', 'Current Round')
.should('contain', 'Highest Match Amount')
.should('contain', 'Highest Amount Raised')
.should('contain', 'Highest Contributor Count')
.should('contain', 'All-Time');
cy.get('.vs__dropdown-menu').find('#vs3__option-13').should('contain', 'Highest Amount Raised'); // need to be more specific to test two elements with same name
cy.get('.vs__dropdown-menu').find('#vs3__option-14').should('contain', 'Highest Contributor Count');
.should('contain', 'Highest Match Amount');

cy.get('.vs__dropdown-menu li').filter(':contains("Highest Amount Raised")').should('have.length', 2);
cy.get('.vs__dropdown-menu li').filter(':contains("Highest Contributor Count")').should('have.length', 2);
});

it('does not contain Most Relevant option by default', () => {
Expand Down Expand Up @@ -161,12 +160,12 @@ describe('Grants Explorer page', () => {
// Options in All-Time category
cy.get('.vselect-clean').click();

cy.get('.vs__dropdown-menu').find('#vs3__option-13').contains('Highest Amount Raised').click(); // Need to be more specific here because the same options exist above
cy.get('.vs__dropdown-menu li').filter(':contains("Highest Amount Raised")').last().click();
cy.url().should('contain', 'sort_option=-amount_received');

cy.get('.vselect-clean').click();

cy.get('.vs__dropdown-menu').find('#vs3__option-14').contains('Highest Contributor Count').click();
cy.get('.vs__dropdown-menu li').filter(':contains("Highest Contributor Count")').last().click();
cy.url().should('contain', 'sort_option=-contributor_count');

// Admin options
Expand Down

0 comments on commit 2a18bad

Please sign in to comment.