From bf34203b7b543fecdbbb40a97825b459167740a4 Mon Sep 17 00:00:00 2001 From: jonasongg Date: Tue, 30 Apr 2024 18:04:35 +0800 Subject: [PATCH 1/9] add cypress test for group by author show tag --- frontend/cypress/config/author-config.csv | 2 ++ .../tests/chartView/chartView_showTags.cy.js | 19 +++++++++++++++++++ frontend/src/components/c-summary-charts.vue | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 frontend/cypress/config/author-config.csv diff --git a/frontend/cypress/config/author-config.csv b/frontend/cypress/config/author-config.csv new file mode 100644 index 0000000000..407005520c --- /dev/null +++ b/frontend/cypress/config/author-config.csv @@ -0,0 +1,2 @@ +Repository's Location,Branch,Author's Git Host ID,Author's Emails,Author's Display Name,Author's Git Author Name,Ignore Glob List +https://github.com/reposense/publish-RepoSense.git,master,yong24s,,Yong Hao,, diff --git a/frontend/cypress/tests/chartView/chartView_showTags.cy.js b/frontend/cypress/tests/chartView/chartView_showTags.cy.js index 0e5ed49e67..bc4747f312 100644 --- a/frontend/cypress/tests/chartView/chartView_showTags.cy.js +++ b/frontend/cypress/tests/chartView/chartView_showTags.cy.js @@ -64,4 +64,23 @@ describe('show tags', () => { .should('equal', 'https://github.com/reposense/RepoSense/releases/tag/v1.0'); }); }); + + it('group by authors works with show tags', () => { + cy.get('div.mui-select.grouping > select:visible') + .select('groupByAuthors'); + + cy.get('div.mui-select.sort-within-group > select:visible') + .select('title dsc'); + + cy.get('#summary label.show-tags > input:visible') + .should('be.visible') + .check() + .should('be.checked'); + + cy.get('.summary-chart:first summary-chart__title--tags') + .should('not.exist'); + + cy.get('.summary-chart:nth-child(2) summary-chart__title--tags') + .should('not.exist'); + }); }); diff --git a/frontend/src/components/c-summary-charts.vue b/frontend/src/components/c-summary-charts.vue index e705e57240..0887053c26 100644 --- a/frontend/src/components/c-summary-charts.vue +++ b/frontend/src/components/c-summary-charts.vue @@ -942,7 +942,7 @@ export default defineComponent({ }, getTags(repo: Array, user?: User): Array { - if (user) repo = repo.filter((r) => r.name === user.name); + if (user) repo = repo.filter((r) => r.repoId === user.repoId); return [...new Set(repo.flatMap((r) => r.commits).flatMap((c) => c.commitResults).flatMap((r) => r.tags))] .filter(Boolean) as Array; }, From 7f729efd955800a89c8f22e8593aad80a619cef6 Mon Sep 17 00:00:00 2001 From: jonasongg Date: Tue, 30 Apr 2024 18:07:56 +0800 Subject: [PATCH 2/9] fix lint --- frontend/cypress/tests/chartView/chartView_showTags.cy.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/cypress/tests/chartView/chartView_showTags.cy.js b/frontend/cypress/tests/chartView/chartView_showTags.cy.js index bc4747f312..0532336d2f 100644 --- a/frontend/cypress/tests/chartView/chartView_showTags.cy.js +++ b/frontend/cypress/tests/chartView/chartView_showTags.cy.js @@ -68,18 +68,18 @@ describe('show tags', () => { it('group by authors works with show tags', () => { cy.get('div.mui-select.grouping > select:visible') .select('groupByAuthors'); - + cy.get('div.mui-select.sort-within-group > select:visible') .select('title dsc'); - + cy.get('#summary label.show-tags > input:visible') .should('be.visible') .check() .should('be.checked'); - + cy.get('.summary-chart:first summary-chart__title--tags') .should('not.exist'); - + cy.get('.summary-chart:nth-child(2) summary-chart__title--tags') .should('not.exist'); }); From f16c1a5f91760f16a38c3ad7c5edd51de34e7b31 Mon Sep 17 00:00:00 2001 From: jonasongg Date: Tue, 30 Apr 2024 18:22:28 +0800 Subject: [PATCH 3/9] fix failing cypress --- .../tests/chartView/chartView_mergeGroup.cy.js | 16 ++++++++-------- .../chartView/chartView_scrollToActiveRepo.cy.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js b/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js index 9c3a9bc460..8ecfb58c20 100644 --- a/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js +++ b/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js @@ -17,9 +17,9 @@ describe('merge group', () => { .uncheck() .should('not.be.checked'); - // after un-checking merge group, all 14 summary charts will show + // after un-checking merge group, all 9 summary charts will show cy.get('#summary-charts').find('.summary-chart') - .should('have.length', 14); + .should('have.length', 9); }); it('check and uncheck merge group when group by authors', () => { @@ -31,9 +31,9 @@ describe('merge group', () => { .check() .should('be.checked'); - // after checking merge group, 14 merged author groups will show + // after checking merge group, 8 merged author groups will show cy.get('#summary-charts').find('.summary-chart') - .should('have.length', 14); + .should('have.length', 8); cy.get('#summary label.merge-group > input:visible') .first() @@ -41,9 +41,9 @@ describe('merge group', () => { .uncheck() .should('not.be.checked'); - // after un-checking merge group, all 14 summary charts will show + // after un-checking merge group, all 9 summary charts will show cy.get('#summary-charts').find('.summary-chart') - .should('have.length', 14); + .should('have.length', 9); }); it('merge group option should be disabled when group by none', () => { @@ -62,7 +62,7 @@ describe('merge group', () => { .should('be.checked'); // get the chart bars and assert they have the correct initial widths - const expectedWidths = [100, 100, 100, 15, 100, 100, 90, 30, 15]; + const expectedWidths = [100, 100, 100, 80, 20]; cy.get('.stacked-bar__contrib--bar') .should('have.length', expectedWidths.length) .then(($bars) => { @@ -70,7 +70,7 @@ describe('merge group', () => { const parentWidth = $bars.eq(0).parent().width(); expectedWidths.forEach((expectedWidth, index) => { const width = (parseFloat(window.getComputedStyle($bars[index]).width) / parentWidth) * 100; - expect(width).to.be.closeTo(expectedWidth, 1); + expect(width).to.be.closeTo(expectedWidth, 3); }); }); }); diff --git a/frontend/cypress/tests/chartView/chartView_scrollToActiveRepo.cy.js b/frontend/cypress/tests/chartView/chartView_scrollToActiveRepo.cy.js index aa7d3a887a..b2c0dfb4b5 100644 --- a/frontend/cypress/tests/chartView/chartView_scrollToActiveRepo.cy.js +++ b/frontend/cypress/tests/chartView/chartView_scrollToActiveRepo.cy.js @@ -49,7 +49,7 @@ describe('scroll to active repo', () => { }); cy.url() - .should('contain', 'tabAuthor=Yong%20Hao%20TENG') + .should('contain', 'tabAuthor=yong24s') .should('contain', 'tabRepo=reposense%2Fpublish-RepoSense%5Bmaster%5D'); cy.reload(); From 43dffe7a753b70b762bfd3aed90714ec21f43b1e Mon Sep 17 00:00:00 2001 From: jonasongg Date: Mon, 6 May 2024 00:09:43 +0800 Subject: [PATCH 4/9] fix cypress test --- frontend/cypress/tests/chartView/chartView_showTags.cy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/cypress/tests/chartView/chartView_showTags.cy.js b/frontend/cypress/tests/chartView/chartView_showTags.cy.js index 0532336d2f..2a4345aeaa 100644 --- a/frontend/cypress/tests/chartView/chartView_showTags.cy.js +++ b/frontend/cypress/tests/chartView/chartView_showTags.cy.js @@ -77,10 +77,10 @@ describe('show tags', () => { .check() .should('be.checked'); - cy.get('.summary-chart:first summary-chart__title--tags') + cy.get('.summary-chart:first .summary-chart__title--tags') .should('not.exist'); - cy.get('.summary-chart:nth-child(2) summary-chart__title--tags') - .should('not.exist'); + cy.get('.summary-chart:nth-child(2) .summary-chart__title--tags') + .should('exist'); }); }); From d5897139da64c8e86e705ec784c176942ac28ab2 Mon Sep 17 00:00:00 2001 From: jonasongg Date: Mon, 6 May 2024 00:45:38 +0800 Subject: [PATCH 5/9] fix author config --- frontend/cypress/config/author-config.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/cypress/config/author-config.csv b/frontend/cypress/config/author-config.csv index 407005520c..1c1e437180 100644 --- a/frontend/cypress/config/author-config.csv +++ b/frontend/cypress/config/author-config.csv @@ -1,2 +1,2 @@ Repository's Location,Branch,Author's Git Host ID,Author's Emails,Author's Display Name,Author's Git Author Name,Ignore Glob List -https://github.com/reposense/publish-RepoSense.git,master,yong24s,,Yong Hao,, +https://github.com/reposense/publish-RepoSense.git,master,yong24s,,,Yong Hao TENG;yong24s, From aaef585aaa480cd1ce9706ae68333fc4dc21615c Mon Sep 17 00:00:00 2001 From: jonasongg Date: Mon, 6 May 2024 03:40:30 +0800 Subject: [PATCH 6/9] fix cypress --- frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js | 4 ++-- frontend/cypress/tests/chartView/chartView_showTags.cy.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js b/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js index 8ecfb58c20..4d9f483be5 100644 --- a/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js +++ b/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js @@ -62,7 +62,7 @@ describe('merge group', () => { .should('be.checked'); // get the chart bars and assert they have the correct initial widths - const expectedWidths = [100, 100, 100, 80, 20]; + const expectedWidths = [100, 100, 20, 100, 100, 3, 20, 5]; cy.get('.stacked-bar__contrib--bar') .should('have.length', expectedWidths.length) .then(($bars) => { @@ -70,7 +70,7 @@ describe('merge group', () => { const parentWidth = $bars.eq(0).parent().width(); expectedWidths.forEach((expectedWidth, index) => { const width = (parseFloat(window.getComputedStyle($bars[index]).width) / parentWidth) * 100; - expect(width).to.be.closeTo(expectedWidth, 3); + expect(width).to.be.closeTo(expectedWidth, 2); }); }); }); diff --git a/frontend/cypress/tests/chartView/chartView_showTags.cy.js b/frontend/cypress/tests/chartView/chartView_showTags.cy.js index 2a4345aeaa..4bac46ef12 100644 --- a/frontend/cypress/tests/chartView/chartView_showTags.cy.js +++ b/frontend/cypress/tests/chartView/chartView_showTags.cy.js @@ -78,9 +78,10 @@ describe('show tags', () => { .should('be.checked'); cy.get('.summary-chart:first .summary-chart__title--tags') - .should('not.exist'); + .find('a') + .should('have.length', 0); cy.get('.summary-chart:nth-child(2) .summary-chart__title--tags') - .should('exist'); + .should('have.length.gt', 0); }); }); From 60e59d2dc855402fa941f7e6fd0234a78754d6b0 Mon Sep 17 00:00:00 2001 From: jonasongg Date: Mon, 6 May 2024 03:41:45 +0800 Subject: [PATCH 7/9] fix group by bug --- frontend/src/components/c-summary-charts.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/c-summary-charts.vue b/frontend/src/components/c-summary-charts.vue index 0887053c26..ae7e8b1c8e 100644 --- a/frontend/src/components/c-summary-charts.vue +++ b/frontend/src/components/c-summary-charts.vue @@ -942,7 +942,7 @@ export default defineComponent({ }, getTags(repo: Array, user?: User): Array { - if (user) repo = repo.filter((r) => r.repoId === user.repoId); + if (user) repo = repo.filter((r) => r.name === user.name && r.repoId === user.repoId); return [...new Set(repo.flatMap((r) => r.commits).flatMap((c) => c.commitResults).flatMap((r) => r.tags))] .filter(Boolean) as Array; }, From afbccbd67bb601d59eff732e8aea743b81a196a2 Mon Sep 17 00:00:00 2001 From: jonasongg Date: Mon, 6 May 2024 04:00:04 +0800 Subject: [PATCH 8/9] add tests for group by author and none --- .../tests/chartView/chartView_showTags.cy.js | 71 ++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/frontend/cypress/tests/chartView/chartView_showTags.cy.js b/frontend/cypress/tests/chartView/chartView_showTags.cy.js index 4bac46ef12..c5c99d3e75 100644 --- a/frontend/cypress/tests/chartView/chartView_showTags.cy.js +++ b/frontend/cypress/tests/chartView/chartView_showTags.cy.js @@ -77,11 +77,78 @@ describe('show tags', () => { .check() .should('be.checked'); - cy.get('.summary-chart:first .summary-chart__title--tags') + cy.get('.summary-chart') + .first() + .find('.summary-chart__title--tags') .find('a') .should('have.length', 0); - cy.get('.summary-chart:nth-child(2) .summary-chart__title--tags') + cy.get('.summary-chart') + .eq(1) + .find('.summary-chart__title--tags') + .find('a') .should('have.length.gt', 0); + + cy.get('.icon-button.fa-list-ul') + .should('exist') + .eq(1) + .click(); + + const correctTags = []; + + cy.get('.zoom__title--tags') + .find('.tag') + .each(($tag) => correctTags.push($tag.text().trim())) + .then(() => { + cy.get('.summary-chart') + .eq(1) + .find('.summary-chart__title--tags') + .find('.tag') + .each(($tag) => { + expect(correctTags).to.include($tag.text().trim()); + }); + + cy.get('.summary-chart') + .eq(1) + .find('.summary-chart__title--tags') + .find('.tag') + .should('have.length', correctTags.length); + }); + }); + + it('group by none works with show tags', () => { + cy.get('div.mui-select.grouping > select:visible') + .select('groupByNone'); + + cy.get('#summary label.show-tags > input:visible') + .should('be.visible') + .check() + .should('be.checked'); + + cy.get('.icon-button.fa-list-ul') + .should('exist') + .first() + .click(); + + const correctTags = []; + + cy.get('.zoom__title--tags') + .find('.tag') + .each(($tag) => correctTags.push($tag.text().trim())) + .then(() => { + cy.get('.summary-chart') + .first() + .find('.summary-chart__title--tags') + .find('.tag') + .each(($tag) => { + expect(correctTags).to.include($tag.text().trim()); + }); + + cy.get('.summary-chart') + .first() + .find('.summary-chart__title--tags') + .find('.tag') + .should('have.length', correctTags.length); + }); }); }); From b22810956210e368cf6982655adb13d95474abcf Mon Sep 17 00:00:00 2001 From: jonasongg Date: Mon, 6 May 2024 11:55:40 +0800 Subject: [PATCH 9/9] fix lint --- frontend/cypress/tests/chartView/chartView_showTags.cy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/cypress/tests/chartView/chartView_showTags.cy.js b/frontend/cypress/tests/chartView/chartView_showTags.cy.js index c5c99d3e75..265c290cd3 100644 --- a/frontend/cypress/tests/chartView/chartView_showTags.cy.js +++ b/frontend/cypress/tests/chartView/chartView_showTags.cy.js @@ -131,7 +131,7 @@ describe('show tags', () => { .click(); const correctTags = []; - + cy.get('.zoom__title--tags') .find('.tag') .each(($tag) => correctTags.push($tag.text().trim())) @@ -143,7 +143,7 @@ describe('show tags', () => { .each(($tag) => { expect(correctTags).to.include($tag.text().trim()); }); - + cy.get('.summary-chart') .first() .find('.summary-chart__title--tags')