-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GITC-511: improve grant explorer sorting experience (#9700)
* add new labels and organize selections, disable keyboard input * add admin labels * add admin selections * refactor * remove some admin options (misunderstood requirements) * styling * sort by title, alphabetical and reverse alphabetical * refactor * refactor options to mimic optgroups, add more styling * display admin options if user is an admin * eslint fixes * refactor * refactor * fix broken admin options display * add test for admin options * fix typo * refactor specs * add a test for sorting functionality * refactor tests * fix broken mobile layout
- Loading branch information
Jeremy Schuurmans
authored
Nov 18, 2021
1 parent
dd5c14b
commit 635953e
Showing
6 changed files
with
223 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
describe('Grants Explorer page', () => { | ||
before(() => { | ||
cy.setupMetamask(); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.logout(); | ||
}); | ||
|
||
after(() => { | ||
cy.clearWindows(); | ||
}); | ||
|
||
describe('grants explorer sort menu', () => { | ||
it('contains the proper sort options', () => { | ||
cy.impersonateUser(); | ||
|
||
cy.visit('grants/explorer'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu') | ||
.should('contain', 'Discover') | ||
.should('contain', 'Weighted Shuffle') | ||
.should('contain', 'Trending') | ||
.should('contain', 'Undiscovered Gems') | ||
.should('contain', 'Recently Updated') | ||
.should('contain', 'Newest') | ||
.should('contain', 'Oldest') | ||
.should('contain', 'A to Z') | ||
.should('contain', 'Z to A') | ||
.should('contain', 'Current Round') | ||
.should('contain', 'Most Relevant') | ||
.should('contain', 'Highest Amount Raised') | ||
.should('contain', 'Highest Contributor Count') | ||
.should('contain', 'All-Time'); | ||
cy.get('.vs__dropdown-menu').find('#vs3__option-14').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-15').should('contain', 'Highest Contributor Count'); | ||
}); | ||
|
||
it('divides the sort options into category names with disabled labels', () => { | ||
cy.impersonateUser(); | ||
|
||
cy.visit('grants/explorer'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.contains('Discover').parent().should('have.class', 'vs__dropdown-option--disabled'); | ||
cy.contains('Current Round').parent().should('have.class', 'vs__dropdown-option--disabled'); | ||
cy.contains('All-Time').parent().should('have.class', 'vs__dropdown-option--disabled'); | ||
}); | ||
|
||
it('does not display admin options when user is not staff', () => { | ||
cy.impersonateUser(); | ||
|
||
cy.visit('grants/explorer'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu') | ||
.should('not.contain', 'Misc') | ||
.should('not.contain', 'ADMIN: Risk Score') | ||
.should('not.contain', 'ADMIN: Sybil Score'); | ||
}); | ||
|
||
it('displays admin options when user is staff', () => { | ||
cy.impersonateStaffUser(); | ||
|
||
cy.visit('grants/explorer'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu') | ||
.should('contain', 'Misc') | ||
.should('contain', 'ADMIN: Risk Score') | ||
.should('contain', 'ADMIN: Sybil Score'); | ||
}); | ||
|
||
it('sends the proper sort request to the API', () => { | ||
cy.impersonateStaffUser(); | ||
|
||
cy.visit('grants/explorer'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
// Options in Discover category | ||
cy.get('.vs__dropdown-menu').contains('Weighted Shuffle').click(); | ||
cy.url().should('contain', 'sort_option=weighted_shuffle'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Trending').click(); | ||
cy.url().should('contain', 'sort_option=-metadata__upcoming'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Undiscovered Gems').click(); | ||
cy.url().should('contain', 'sort_option=-metadata__gem'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Recently Updated').click(); | ||
cy.url().should('contain', 'sort_option=-last_update'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Newest').click(); | ||
cy.url().should('contain', 'sort_option=-created_on'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Oldest').click(); | ||
cy.url().should('contain', 'sort_option=created_on'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('A to Z').click(); | ||
cy.url().should('contain', 'sort_option=title'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Z to A').click(); | ||
cy.url().should('contain', 'sort_option=-title'); | ||
|
||
// Options in Current Round category | ||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Most Relevant').click(); | ||
cy.url().should('contain', 'sort_option='); // The value of this option is purposely set to empty string (see app/assets/v2/js/grants/index.js) | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Highest Amount Raised').click(); | ||
cy.url().should('contain', 'sort_option=-amount_received_in_round'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('Highest Contributor Count').click(); | ||
cy.url().should('contain', 'sort_option=-positive_round_contributor_count'); | ||
|
||
// Options in All-Time category | ||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').find('#vs3__option-14').contains('Highest Amount Raised').click(); // Need to be more specific here because the same options exist above | ||
cy.url().should('contain', 'sort_option=-amount_received'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').find('#vs3__option-15').contains('Highest Contributor Count').click(); | ||
cy.url().should('contain', 'sort_option=-contributor_count'); | ||
|
||
// Admin options | ||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('ADMIN: Risk Score').click(); | ||
cy.url().should('contain', 'sort_option=-weighted_risk_score'); | ||
|
||
cy.get('.vselect-clean').click(); | ||
|
||
cy.get('.vs__dropdown-menu').contains('ADMIN: Sybil Score').click(); | ||
cy.url().should('contain', 'sort_option=-sybil_score'); | ||
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
635953e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closes: https://gitcoin.atlassian.net/browse/GITC-511
@Jer-Sch
seems like Z->A sorting isn't working (I think you said you caught a bug here), but take a look?
why is there "most relevant" under "current round"? That shouldn't be there, I believe that should only show when one uses the search function in order to preserve the exact title match (https://gitcoin.atlassian.net/browse/GITC-406).
635953e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frankchen07
635953e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frankchen07 These issues have been resolved in #9717