From e02ab1240132d4f4a2051b96668ca2749edc15e5 Mon Sep 17 00:00:00 2001 From: Seah Shau Chung Nicholas <97350362+nseah21@users.noreply.github.com> Date: Tue, 23 Jan 2024 06:12:38 +0100 Subject: [PATCH 01/10] [#1986] Add cypress tests for renderFilterHash (#2017) There were a few instances of URL parameters being incorrectly loaded due to bugs in the code. These bugs were not able to be detected early due to a lack of tests for the renderFilterHash method. Let's add tests to check that the URL parameters are loaded correctly after the application reloads. --- .../codeView/codeView_renderFilterHash.cy.js | 339 ++++++++++++++++++ 1 file changed, 339 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..10cc717b0c --- /dev/null +++ b/frontend/cypress/tests/codeView/codeView_renderFilterHash.cy.js @@ -0,0 +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'); + }); +}); From 3cd680c3ddfa5a96f9168d3ab411d0cccfc3c52f Mon Sep 17 00:00:00 2001 From: Alvis Ng Date: Fri, 26 Jan 2024 13:22:55 +0800 Subject: [PATCH 02/10] [#2082] Fix typo in command in Setting Up page (#2083) Fix typo in Setting Up page The command given in the developer guide for checking the local Node.js version is `npm -v`, which displays the version of npm instead. Let's replace the command with `node -v`, which correctly displays the Node.js version. --- docs/dg/settingUp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dg/settingUp.md b/docs/dg/settingUp.md index a82a04e90b..6542919046 100644 --- a/docs/dg/settingUp.md +++ b/docs/dg/settingUp.md @@ -15,7 +15,7 @@ - Type `java -version`, `npm -v` and `git --version` respectively on your OS terminal and ensure that you have the correct version of each prerequisite installed. + Type `java -version`, `node -v` and `git --version` respectively on your OS terminal and ensure that you have the correct version of each prerequisite installed. From eb7a944532ba9b99e890d9fa1c45787dcbec33a0 Mon Sep 17 00:00:00 2001 From: jonasongg <120372506+jonasongg@users.noreply.github.com> Date: Fri, 26 Jan 2024 13:45:04 +0800 Subject: [PATCH 03/10] [#2004] Remove redundant Segment class (#2085) Remove Segment class, replace with AuthorshipFileSegment The Segment class and AuthorshipFileSegment interface are equivalent in their usage and their redundancy seems to be a remnant when the code was migrated from JS to TS. Let's remove the Segment class for consistency and to improve runtime performance. --- frontend/src/components/c-segment-collection.vue | 4 ++-- frontend/src/components/c-segment.vue | 6 +++--- frontend/src/utils/segment.ts | 13 ------------- frontend/src/views/c-authorship.vue | 15 +++++++-------- 4 files changed, 12 insertions(+), 26 deletions(-) delete mode 100644 frontend/src/utils/segment.ts diff --git a/frontend/src/components/c-segment-collection.vue b/frontend/src/components/c-segment-collection.vue index e305083a31..591dbb247d 100644 --- a/frontend/src/components/c-segment-collection.vue +++ b/frontend/src/components/c-segment-collection.vue @@ -7,7 +7,7 @@