From 3efa09e4c09fb18a8ab776b980134ac9e343eb2a Mon Sep 17 00:00:00 2001 From: nseah21 Date: Fri, 7 Jul 2023 00:41:45 +0800 Subject: [PATCH 1/5] Add initial tests for renderFilterHash --- .../codeView/codeView_renderFilterHash.cy.js | 387 ++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js diff --git a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js new file mode 100644 index 0000000000..b6df866e5e --- /dev/null +++ b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js @@ -0,0 +1,387 @@ +describe('render filter hash', () => { + it('search', () => { + /* Check initial state */ + cy.get('div.mui-textfield.search_box > input:visible') + .should('be.visible') + .invoke('val') + .should('eq', ''); + + /* Enter search and test URL before and after reload */ + cy.get('div.mui-textfield.search_box > input:visible') + .should('be.visible') + .type('eugene{enter}'); + + cy.url() + .should('contain', 'search=eugene'); + + cy.reload(); + + cy.url() + .should('contain', 'search=eugene'); + }); + + it('group by', () => { + /* Check initial state */ + cy.get('div.mui-select.grouping > select:visible') + .invoke('val') + .should('eq', 'groupByRepos'); + + cy.url() + .should('contain', 'groupSelect=groupByRepos'); + + /* Select group by none and test URL before and after reload */ + cy.get('div.mui-select.grouping > select:visible') + .select('groupByNone'); + + cy.url() + .should('contain', 'groupSelect=groupByNone'); + + cy.reload(); + + // cy.get('div.mui-select.grouping > select:visible') + // .invoke('val') + // .should('eq', 'groupByNone'); + + cy.url() + .should('contain', 'groupSelect=groupByNone'); + + /* Select group by authors and test URL before and after reload */ + cy.get('div.mui-select.grouping > select:visible') + .select('groupByAuthors'); + + cy.url() + .should('contain', 'groupSelect=groupByAuthors'); + + cy.reload(); + + // cy.get('div.mui-select.grouping > select:visible') + // .invoke('val') + // .should('eq', 'groupByAuthors'); + + cy.url() + .should('contain', 'groupSelect=groupByAuthors'); + }); + + it('sort groups by', () => { + /* Check initial state */ + cy.get('div.mui-select.sort-group > select:visible') + .invoke('val') + .should('eq', 'groupTitle dsc'); + + cy.url() + .should('contain', 'sort=groupTitle%20dsc'); + + /* Select sort by group title ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('groupTitle'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'groupTitle'); + + cy.url() + .should('contain', 'sort=groupTitle'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=groupTitle'); + + /* Select sort by contribution descending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('totalCommits dsc'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'totalCommits dsc'); + + cy.url() + .should('contain', 'sort=totalCommits%20dsc'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=totalCommits%20dsc'); + + /* Select sort by contribution ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('totalCommits'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'totalCommits'); + + cy.url() + .should('contain', 'sort=totalCommits'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=totalCommits'); + + /* Select sort by variance descending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('variance dsc'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'variance dsc'); + + cy.url() + .should('contain', 'sort=variance%20dsc'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=variance%20dsc'); + + /* Select sort by variance ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('variance'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'variance'); + + cy.url() + .should('contain', 'sort=variance'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=variance'); + }); + + it('sort within groups by', () => { + /* Check initial state */ + cy.get('div.mui-select.sort-within-group > select:visible') + .invoke('val') + .should('eq', 'title'); + + cy.url() + .should('contain', 'sortWithin=title'); + + /* Select sort by group title ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('title dsc'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'groupTitle'); + + cy.url() + .should('contain', 'sortWithin=title'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=title'); + + /* Select sort by contribution descending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('totalCommits dsc'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'totalCommits dsc'); + + cy.url() + .should('contain', 'sortWithin=totalCommits%20dsc'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=totalCommits%20dsc'); + + /* Select sort by contribution ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('totalCommits'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'totalCommits'); + + cy.url() + .should('contain', 'sortWithin=totalCommits'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=totalCommits'); + + /* Select sort by variance descending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('variance dsc'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'variance dsc'); + + cy.url() + .should('contain', 'sortWithin=variance%20dsc'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=variance%20dsc'); + + /* Select sort by variance ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('variance'); + + // cy.get('div.mui-select.sort-group > select:visible') + // .invoke('val') + // .should('eq', 'variance'); + + cy.url() + .should('contain', 'sortWithin=variance'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=variance'); + }); + + it('granularity', () => { + /* Check initial state */ + cy.get('div.mui-select.granularity > select:visible') + .invoke('val') + .should('eq', 'commit'); + + cy.url() + .should('contain', 'timeframe=commit'); + + /* Select timeframe as day and test URL before and after reload */ + cy.get('div.mui-select.granularity > select:visible') + .select('day'); + + cy.url() + .should('contain', 'timeframe=day'); + + cy.reload(); + + cy.url() + .should('contain', 'timeframe=day'); + + /* Select timeframe as week and test URL before and after reload */ + cy.get('div.mui-select.granularity > select:visible') + .select('week'); + + cy.url() + .should('contain', 'timeframe=week'); + + cy.reload(); + + cy.url() + .should('contain', 'timeframe=week'); + }); + + it('since', () => { + /* Check initial state */ + cy.get('input[name="since"]:visible') + .invoke('val') + .should('eq', '2018-05-03'); + + cy.url() + .should('contain', 'since=2018-05-03'); + + /* Modify since date and test URL before and after reload */ + cy.get('input[name="since"]:visible') + .type('2019-06-04'); + + cy.url() + .should('contain', 'since=2019-06-04'); + + cy.reload(); + + cy.url() + .should('contain', 'since=2019-06-04'); + }); + + it('until', () => { + /* Check initial state (will require dayjs for getting current date) */ + // cy.get('input[name="until"]:visible') + // .invoke('val') + // .should('eq', dayjs().format('YYYY-MM-DD')); + + // cy.url() + // .should('contain', 'date=2023-07-06'); + + /* Modify since date and test URL before and after reload */ + cy.get('input[name="until"]:visible') + .type('2019-06-04'); + + cy.url() + .should('contain', 'until=2019-06-04'); + + cy.reload(); + + cy.url() + .should('contain', 'until=2019-06-04'); + }); + + it('breakdown by file type', () => { + cy.get('#summary label.filter-breakdown input:visible') + .should('not.be.checked'); + + cy.url() + .should('include', 'breakdown=false'); + + cy.get('#summary label.filter-breakdown input:visible') + .check(); + + cy.reload(); + + cy.url() + .should('include', 'breakdown=true'); + }); + + it('merge all groups', () => { + cy.get('#summary label.merge-group > input:visible') + .should('be.visible') + .check(); + + cy.url() + .should('contain', 'mergegroup=reposense%2FRepoSense%5Bcypress%5D'); + + cy.reload(); + + cy.url() + .should('contain', 'mergegroup=reposense%2FRepoSense%5Bcypress%5D'); + }); + + it('checked file types', () => { + cy.get('#summary label.filter-breakdown input:visible') + .should('not.be.checked'); + + cy.url() + .should('not.contain', 'gradle'); + + cy.get('#summary label.filter-breakdown input:visible') + .check() + .should('be.checked'); + + cy.get('#summary div.fileTypes input[id="gradle"]') + .should('be.checked'); + + cy.url() + .should('contain', 'gradle'); + + cy.reload(); + + cy.url() + .should('contain', 'gradle'); + + cy.get('#summary div.fileTypes input[id="gradle"]') + .uncheck() + .should('not.be.checked'); + + cy.url() + .should('not.contain', 'gradle'); + + cy.reload(); + + cy.url() + .should('not.contain', 'gradle'); + }); +}); From 861f9f92f190c6d62f374d9c4a457cd9836c5707 Mon Sep 17 00:00:00 2001 From: nseah21 Date: Fri, 7 Jul 2023 03:06:51 +0800 Subject: [PATCH 2/5] Update descriptions for individual tests --- .../codeView/codeView_renderFilterHash.cy.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js index b6df866e5e..e4b8f61f87 100644 --- a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js +++ b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js @@ -1,5 +1,5 @@ describe('render filter hash', () => { - it('search', () => { + it('search: url params should persist after change and reload', () => { /* Check initial state */ cy.get('div.mui-textfield.search_box > input:visible') .should('be.visible') @@ -20,7 +20,7 @@ describe('render filter hash', () => { .should('contain', 'search=eugene'); }); - it('group by', () => { + it('group by: url params should persist after change and reload', () => { /* Check initial state */ cy.get('div.mui-select.grouping > select:visible') .invoke('val') @@ -62,7 +62,7 @@ describe('render filter hash', () => { .should('contain', 'groupSelect=groupByAuthors'); }); - it('sort groups by', () => { + it('sort groups by: url params should persist after change and reload', () => { /* Check initial state */ cy.get('div.mui-select.sort-group > select:visible') .invoke('val') @@ -152,7 +152,7 @@ describe('render filter hash', () => { .should('contain', 'sort=variance'); }); - it('sort within groups by', () => { + it('sort within groups by: url params should persist after change and reload', () => { /* Check initial state */ cy.get('div.mui-select.sort-within-group > select:visible') .invoke('val') @@ -242,7 +242,7 @@ describe('render filter hash', () => { .should('contain', 'sortWithin=variance'); }); - it('granularity', () => { + it('granularity: url params should persist after change and reload', () => { /* Check initial state */ cy.get('div.mui-select.granularity > select:visible') .invoke('val') @@ -276,7 +276,7 @@ describe('render filter hash', () => { .should('contain', 'timeframe=week'); }); - it('since', () => { + it('since: url params should persist after change and reload', () => { /* Check initial state */ cy.get('input[name="since"]:visible') .invoke('val') @@ -298,7 +298,7 @@ describe('render filter hash', () => { .should('contain', 'since=2019-06-04'); }); - it('until', () => { + it('until: url params should persist after change and reload', () => { /* Check initial state (will require dayjs for getting current date) */ // cy.get('input[name="until"]:visible') // .invoke('val') @@ -320,7 +320,7 @@ describe('render filter hash', () => { .should('contain', 'until=2019-06-04'); }); - it('breakdown by file type', () => { + it('breakdown by file type: url params should persist after change and reload', () => { cy.get('#summary label.filter-breakdown input:visible') .should('not.be.checked'); @@ -336,7 +336,7 @@ describe('render filter hash', () => { .should('include', 'breakdown=true'); }); - it('merge all groups', () => { + it('merge all groups: url params should persist after change and reload', () => { cy.get('#summary label.merge-group > input:visible') .should('be.visible') .check(); @@ -350,7 +350,7 @@ describe('render filter hash', () => { .should('contain', 'mergegroup=reposense%2FRepoSense%5Bcypress%5D'); }); - it('checked file types', () => { + it('checked file types: url params should persist after change and reload', () => { cy.get('#summary label.filter-breakdown input:visible') .should('not.be.checked'); From 3ccbdcb20f65b26c73fb3e04ea2429c8f7e6abda Mon Sep 17 00:00:00 2001 From: nseah21 Date: Fri, 7 Jul 2023 03:12:25 +0800 Subject: [PATCH 3/5] Remove unused assertions --- .../codeView/codeView_renderFilterHash.cy.js | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js index e4b8f61f87..436995a213 100644 --- a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js +++ b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js @@ -38,10 +38,6 @@ describe('render filter hash', () => { cy.reload(); - // cy.get('div.mui-select.grouping > select:visible') - // .invoke('val') - // .should('eq', 'groupByNone'); - cy.url() .should('contain', 'groupSelect=groupByNone'); @@ -54,10 +50,6 @@ describe('render filter hash', () => { cy.reload(); - // cy.get('div.mui-select.grouping > select:visible') - // .invoke('val') - // .should('eq', 'groupByAuthors'); - cy.url() .should('contain', 'groupSelect=groupByAuthors'); }); @@ -75,10 +67,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-group > select:visible') .select('groupTitle'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'groupTitle'); - cy.url() .should('contain', 'sort=groupTitle'); @@ -91,10 +79,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-group > select:visible') .select('totalCommits dsc'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'totalCommits dsc'); - cy.url() .should('contain', 'sort=totalCommits%20dsc'); @@ -107,10 +91,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-group > select:visible') .select('totalCommits'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'totalCommits'); - cy.url() .should('contain', 'sort=totalCommits'); @@ -123,10 +103,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-group > select:visible') .select('variance dsc'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'variance dsc'); - cy.url() .should('contain', 'sort=variance%20dsc'); @@ -139,10 +115,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-group > select:visible') .select('variance'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'variance'); - cy.url() .should('contain', 'sort=variance'); @@ -165,10 +137,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-within-group > select:visible') .select('title dsc'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'groupTitle'); - cy.url() .should('contain', 'sortWithin=title'); @@ -181,10 +149,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-within-group > select:visible') .select('totalCommits dsc'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'totalCommits dsc'); - cy.url() .should('contain', 'sortWithin=totalCommits%20dsc'); @@ -197,10 +161,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-within-group > select:visible') .select('totalCommits'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'totalCommits'); - cy.url() .should('contain', 'sortWithin=totalCommits'); @@ -213,10 +173,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-within-group > select:visible') .select('variance dsc'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'variance dsc'); - cy.url() .should('contain', 'sortWithin=variance%20dsc'); @@ -229,10 +185,6 @@ describe('render filter hash', () => { cy.get('div.mui-select.sort-within-group > select:visible') .select('variance'); - // cy.get('div.mui-select.sort-group > select:visible') - // .invoke('val') - // .should('eq', 'variance'); - cy.url() .should('contain', 'sortWithin=variance'); From ec83994c6dae1e9da040cd00b70f1c58e047432d Mon Sep 17 00:00:00 2001 From: nseah21 Date: Fri, 7 Jul 2023 03:14:06 +0800 Subject: [PATCH 4/5] Standardise chainers to use contain instead of include --- .../cypress/tests/codeView/codeView_renderFilterHash.cy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js index 436995a213..f3af250e5f 100644 --- a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js +++ b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js @@ -277,7 +277,7 @@ describe('render filter hash', () => { .should('not.be.checked'); cy.url() - .should('include', 'breakdown=false'); + .should('contain', 'breakdown=false'); cy.get('#summary label.filter-breakdown input:visible') .check(); @@ -285,7 +285,7 @@ describe('render filter hash', () => { cy.reload(); cy.url() - .should('include', 'breakdown=true'); + .should('contain', 'breakdown=true'); }); it('merge all groups: url params should persist after change and reload', () => { From 47a7127bf7366a6ea9852a3cc1db188b64bfd367 Mon Sep 17 00:00:00 2001 From: nseah21 Date: Fri, 14 Jul 2023 19:59:30 +0800 Subject: [PATCH 5/5] Fix environmental checks --- .../codeView/codeView_renderFilterHash.cy.js | 678 +++++++++--------- 1 file changed, 339 insertions(+), 339 deletions(-) diff --git a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js index f3af250e5f..10cc717b0c 100644 --- a/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js +++ b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js @@ -1,339 +1,339 @@ -describe('render filter hash', () => { - it('search: url params should persist after change and reload', () => { - /* Check initial state */ - cy.get('div.mui-textfield.search_box > input:visible') - .should('be.visible') - .invoke('val') - .should('eq', ''); - - /* Enter search and test URL before and after reload */ - cy.get('div.mui-textfield.search_box > input:visible') - .should('be.visible') - .type('eugene{enter}'); - - cy.url() - .should('contain', 'search=eugene'); - - cy.reload(); - - cy.url() - .should('contain', 'search=eugene'); - }); - - it('group by: url params should persist after change and reload', () => { - /* Check initial state */ - cy.get('div.mui-select.grouping > select:visible') - .invoke('val') - .should('eq', 'groupByRepos'); - - cy.url() - .should('contain', 'groupSelect=groupByRepos'); - - /* Select group by none and test URL before and after reload */ - cy.get('div.mui-select.grouping > select:visible') - .select('groupByNone'); - - cy.url() - .should('contain', 'groupSelect=groupByNone'); - - cy.reload(); - - cy.url() - .should('contain', 'groupSelect=groupByNone'); - - /* Select group by authors and test URL before and after reload */ - cy.get('div.mui-select.grouping > select:visible') - .select('groupByAuthors'); - - cy.url() - .should('contain', 'groupSelect=groupByAuthors'); - - cy.reload(); - - cy.url() - .should('contain', 'groupSelect=groupByAuthors'); - }); - - it('sort groups by: url params should persist after change and reload', () => { - /* Check initial state */ - cy.get('div.mui-select.sort-group > select:visible') - .invoke('val') - .should('eq', 'groupTitle dsc'); - - cy.url() - .should('contain', 'sort=groupTitle%20dsc'); - - /* Select sort by group title ascending and test URL before and after reload */ - cy.get('div.mui-select.sort-group > select:visible') - .select('groupTitle'); - - cy.url() - .should('contain', 'sort=groupTitle'); - - cy.reload(); - - cy.url() - .should('contain', 'sort=groupTitle'); - - /* Select sort by contribution descending and test URL before and after reload */ - cy.get('div.mui-select.sort-group > select:visible') - .select('totalCommits dsc'); - - cy.url() - .should('contain', 'sort=totalCommits%20dsc'); - - cy.reload(); - - cy.url() - .should('contain', 'sort=totalCommits%20dsc'); - - /* Select sort by contribution ascending and test URL before and after reload */ - cy.get('div.mui-select.sort-group > select:visible') - .select('totalCommits'); - - cy.url() - .should('contain', 'sort=totalCommits'); - - cy.reload(); - - cy.url() - .should('contain', 'sort=totalCommits'); - - /* Select sort by variance descending and test URL before and after reload */ - cy.get('div.mui-select.sort-group > select:visible') - .select('variance dsc'); - - cy.url() - .should('contain', 'sort=variance%20dsc'); - - cy.reload(); - - cy.url() - .should('contain', 'sort=variance%20dsc'); - - /* Select sort by variance ascending and test URL before and after reload */ - cy.get('div.mui-select.sort-group > select:visible') - .select('variance'); - - cy.url() - .should('contain', 'sort=variance'); - - cy.reload(); - - cy.url() - .should('contain', 'sort=variance'); - }); - - it('sort within groups by: url params should persist after change and reload', () => { - /* Check initial state */ - cy.get('div.mui-select.sort-within-group > select:visible') - .invoke('val') - .should('eq', 'title'); - - cy.url() - .should('contain', 'sortWithin=title'); - - /* Select sort by group title ascending and test URL before and after reload */ - cy.get('div.mui-select.sort-within-group > select:visible') - .select('title dsc'); - - cy.url() - .should('contain', 'sortWithin=title'); - - cy.reload(); - - cy.url() - .should('contain', 'sortWithin=title'); - - /* Select sort by contribution descending and test URL before and after reload */ - cy.get('div.mui-select.sort-within-group > select:visible') - .select('totalCommits dsc'); - - cy.url() - .should('contain', 'sortWithin=totalCommits%20dsc'); - - cy.reload(); - - cy.url() - .should('contain', 'sortWithin=totalCommits%20dsc'); - - /* Select sort by contribution ascending and test URL before and after reload */ - cy.get('div.mui-select.sort-within-group > select:visible') - .select('totalCommits'); - - cy.url() - .should('contain', 'sortWithin=totalCommits'); - - cy.reload(); - - cy.url() - .should('contain', 'sortWithin=totalCommits'); - - /* Select sort by variance descending and test URL before and after reload */ - cy.get('div.mui-select.sort-within-group > select:visible') - .select('variance dsc'); - - cy.url() - .should('contain', 'sortWithin=variance%20dsc'); - - cy.reload(); - - cy.url() - .should('contain', 'sortWithin=variance%20dsc'); - - /* Select sort by variance ascending and test URL before and after reload */ - cy.get('div.mui-select.sort-within-group > select:visible') - .select('variance'); - - cy.url() - .should('contain', 'sortWithin=variance'); - - cy.reload(); - - cy.url() - .should('contain', 'sortWithin=variance'); - }); - - it('granularity: url params should persist after change and reload', () => { - /* Check initial state */ - cy.get('div.mui-select.granularity > select:visible') - .invoke('val') - .should('eq', 'commit'); - - cy.url() - .should('contain', 'timeframe=commit'); - - /* Select timeframe as day and test URL before and after reload */ - cy.get('div.mui-select.granularity > select:visible') - .select('day'); - - cy.url() - .should('contain', 'timeframe=day'); - - cy.reload(); - - cy.url() - .should('contain', 'timeframe=day'); - - /* Select timeframe as week and test URL before and after reload */ - cy.get('div.mui-select.granularity > select:visible') - .select('week'); - - cy.url() - .should('contain', 'timeframe=week'); - - cy.reload(); - - cy.url() - .should('contain', 'timeframe=week'); - }); - - it('since: url params should persist after change and reload', () => { - /* Check initial state */ - cy.get('input[name="since"]:visible') - .invoke('val') - .should('eq', '2018-05-03'); - - cy.url() - .should('contain', 'since=2018-05-03'); - - /* Modify since date and test URL before and after reload */ - cy.get('input[name="since"]:visible') - .type('2019-06-04'); - - cy.url() - .should('contain', 'since=2019-06-04'); - - cy.reload(); - - cy.url() - .should('contain', 'since=2019-06-04'); - }); - - it('until: url params should persist after change and reload', () => { - /* Check initial state (will require dayjs for getting current date) */ - // cy.get('input[name="until"]:visible') - // .invoke('val') - // .should('eq', dayjs().format('YYYY-MM-DD')); - - // cy.url() - // .should('contain', 'date=2023-07-06'); - - /* Modify since date and test URL before and after reload */ - cy.get('input[name="until"]:visible') - .type('2019-06-04'); - - cy.url() - .should('contain', 'until=2019-06-04'); - - cy.reload(); - - cy.url() - .should('contain', 'until=2019-06-04'); - }); - - it('breakdown by file type: url params should persist after change and reload', () => { - cy.get('#summary label.filter-breakdown input:visible') - .should('not.be.checked'); - - cy.url() - .should('contain', 'breakdown=false'); - - cy.get('#summary label.filter-breakdown input:visible') - .check(); - - cy.reload(); - - cy.url() - .should('contain', 'breakdown=true'); - }); - - it('merge all groups: url params should persist after change and reload', () => { - cy.get('#summary label.merge-group > input:visible') - .should('be.visible') - .check(); - - cy.url() - .should('contain', 'mergegroup=reposense%2FRepoSense%5Bcypress%5D'); - - cy.reload(); - - cy.url() - .should('contain', 'mergegroup=reposense%2FRepoSense%5Bcypress%5D'); - }); - - it('checked file types: url params should persist after change and reload', () => { - cy.get('#summary label.filter-breakdown input:visible') - .should('not.be.checked'); - - cy.url() - .should('not.contain', 'gradle'); - - cy.get('#summary label.filter-breakdown input:visible') - .check() - .should('be.checked'); - - cy.get('#summary div.fileTypes input[id="gradle"]') - .should('be.checked'); - - cy.url() - .should('contain', 'gradle'); - - cy.reload(); - - cy.url() - .should('contain', 'gradle'); - - cy.get('#summary div.fileTypes input[id="gradle"]') - .uncheck() - .should('not.be.checked'); - - cy.url() - .should('not.contain', 'gradle'); - - cy.reload(); - - cy.url() - .should('not.contain', 'gradle'); - }); -}); +describe('render filter hash', () => { + it('search: url params should persist after change and reload', () => { + /* Check initial state */ + cy.get('div.mui-textfield.search_box > input:visible') + .should('be.visible') + .invoke('val') + .should('eq', ''); + + /* Enter search and test URL before and after reload */ + cy.get('div.mui-textfield.search_box > input:visible') + .should('be.visible') + .type('eugene{enter}'); + + cy.url() + .should('contain', 'search=eugene'); + + cy.reload(); + + cy.url() + .should('contain', 'search=eugene'); + }); + + it('group by: url params should persist after change and reload', () => { + /* Check initial state */ + cy.get('div.mui-select.grouping > select:visible') + .invoke('val') + .should('eq', 'groupByRepos'); + + cy.url() + .should('contain', 'groupSelect=groupByRepos'); + + /* Select group by none and test URL before and after reload */ + cy.get('div.mui-select.grouping > select:visible') + .select('groupByNone'); + + cy.url() + .should('contain', 'groupSelect=groupByNone'); + + cy.reload(); + + cy.url() + .should('contain', 'groupSelect=groupByNone'); + + /* Select group by authors and test URL before and after reload */ + cy.get('div.mui-select.grouping > select:visible') + .select('groupByAuthors'); + + cy.url() + .should('contain', 'groupSelect=groupByAuthors'); + + cy.reload(); + + cy.url() + .should('contain', 'groupSelect=groupByAuthors'); + }); + + it('sort groups by: url params should persist after change and reload', () => { + /* Check initial state */ + cy.get('div.mui-select.sort-group > select:visible') + .invoke('val') + .should('eq', 'groupTitle dsc'); + + cy.url() + .should('contain', 'sort=groupTitle%20dsc'); + + /* Select sort by group title ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('groupTitle'); + + cy.url() + .should('contain', 'sort=groupTitle'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=groupTitle'); + + /* Select sort by contribution descending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('totalCommits dsc'); + + cy.url() + .should('contain', 'sort=totalCommits%20dsc'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=totalCommits%20dsc'); + + /* Select sort by contribution ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('totalCommits'); + + cy.url() + .should('contain', 'sort=totalCommits'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=totalCommits'); + + /* Select sort by variance descending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('variance dsc'); + + cy.url() + .should('contain', 'sort=variance%20dsc'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=variance%20dsc'); + + /* Select sort by variance ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-group > select:visible') + .select('variance'); + + cy.url() + .should('contain', 'sort=variance'); + + cy.reload(); + + cy.url() + .should('contain', 'sort=variance'); + }); + + it('sort within groups by: url params should persist after change and reload', () => { + /* Check initial state */ + cy.get('div.mui-select.sort-within-group > select:visible') + .invoke('val') + .should('eq', 'title'); + + cy.url() + .should('contain', 'sortWithin=title'); + + /* Select sort by group title ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('title dsc'); + + cy.url() + .should('contain', 'sortWithin=title'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=title'); + + /* Select sort by contribution descending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('totalCommits dsc'); + + cy.url() + .should('contain', 'sortWithin=totalCommits%20dsc'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=totalCommits%20dsc'); + + /* Select sort by contribution ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('totalCommits'); + + cy.url() + .should('contain', 'sortWithin=totalCommits'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=totalCommits'); + + /* Select sort by variance descending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('variance dsc'); + + cy.url() + .should('contain', 'sortWithin=variance%20dsc'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=variance%20dsc'); + + /* Select sort by variance ascending and test URL before and after reload */ + cy.get('div.mui-select.sort-within-group > select:visible') + .select('variance'); + + cy.url() + .should('contain', 'sortWithin=variance'); + + cy.reload(); + + cy.url() + .should('contain', 'sortWithin=variance'); + }); + + it('granularity: url params should persist after change and reload', () => { + /* Check initial state */ + cy.get('div.mui-select.granularity > select:visible') + .invoke('val') + .should('eq', 'commit'); + + cy.url() + .should('contain', 'timeframe=commit'); + + /* Select timeframe as day and test URL before and after reload */ + cy.get('div.mui-select.granularity > select:visible') + .select('day'); + + cy.url() + .should('contain', 'timeframe=day'); + + cy.reload(); + + cy.url() + .should('contain', 'timeframe=day'); + + /* Select timeframe as week and test URL before and after reload */ + cy.get('div.mui-select.granularity > select:visible') + .select('week'); + + cy.url() + .should('contain', 'timeframe=week'); + + cy.reload(); + + cy.url() + .should('contain', 'timeframe=week'); + }); + + it('since: url params should persist after change and reload', () => { + /* Check initial state */ + cy.get('input[name="since"]:visible') + .invoke('val') + .should('eq', '2018-05-03'); + + cy.url() + .should('contain', 'since=2018-05-03'); + + /* Modify since date and test URL before and after reload */ + cy.get('input[name="since"]:visible') + .type('2019-06-04'); + + cy.url() + .should('contain', 'since=2019-06-04'); + + cy.reload(); + + cy.url() + .should('contain', 'since=2019-06-04'); + }); + + it('until: url params should persist after change and reload', () => { + /* Check initial state (will require dayjs for getting current date) */ + // cy.get('input[name="until"]:visible') + // .invoke('val') + // .should('eq', dayjs().format('YYYY-MM-DD')); + + // cy.url() + // .should('contain', 'date=2023-07-06'); + + /* Modify since date and test URL before and after reload */ + cy.get('input[name="until"]:visible') + .type('2019-06-04'); + + cy.url() + .should('contain', 'until=2019-06-04'); + + cy.reload(); + + cy.url() + .should('contain', 'until=2019-06-04'); + }); + + it('breakdown by file type: url params should persist after change and reload', () => { + cy.get('#summary label.filter-breakdown input:visible') + .should('not.be.checked'); + + cy.url() + .should('contain', 'breakdown=false'); + + cy.get('#summary label.filter-breakdown input:visible') + .check(); + + cy.reload(); + + cy.url() + .should('contain', 'breakdown=true'); + }); + + it('merge all groups: url params should persist after change and reload', () => { + cy.get('#summary label.merge-group > input:visible') + .should('be.visible') + .check(); + + cy.url() + .should('contain', 'mergegroup=reposense%2FRepoSense%5Bcypress%5D'); + + cy.reload(); + + cy.url() + .should('contain', 'mergegroup=reposense%2FRepoSense%5Bcypress%5D'); + }); + + it('checked file types: url params should persist after change and reload', () => { + cy.get('#summary label.filter-breakdown input:visible') + .should('not.be.checked'); + + cy.url() + .should('not.contain', 'gradle'); + + cy.get('#summary label.filter-breakdown input:visible') + .check() + .should('be.checked'); + + cy.get('#summary div.fileTypes input[id="gradle"]') + .should('be.checked'); + + cy.url() + .should('contain', 'gradle'); + + cy.reload(); + + cy.url() + .should('contain', 'gradle'); + + cy.get('#summary div.fileTypes input[id="gradle"]') + .uncheck() + .should('not.be.checked'); + + cy.url() + .should('not.contain', 'gradle'); + + cy.reload(); + + cy.url() + .should('not.contain', 'gradle'); + }); +});