From 3c53d58c0458a42c58ce84231ea61f8f1cac6930 Mon Sep 17 00:00:00 2001 From: jonasongg <120372506+jonasongg@users.noreply.github.com> Date: Fri, 19 Apr 2024 02:08:38 +0800 Subject: [PATCH] Add more repos to cypress tests (#2188) Add more repos to Cypress tests Currently, our Cypress config only tests with a single repo. This can cause our testing to be limited and cause certain bugs to go unnoticed. Let's add more repos so that our testing can be more extensive. --- frontend/cypress/config/repo-config.csv | 3 ++ .../chartView/chartView_mergeGroup.cy.js | 34 ++++++++----------- .../chartView_scrollToActiveRepo.cy.js | 4 +-- .../chartView_toolBar_searchBox.cy.js | 2 +- .../codeView/codeView_switchAuthorship.cy.js | 2 +- .../tests/zoomView/zoomView_switchZoom.cy.js | 2 +- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/frontend/cypress/config/repo-config.csv b/frontend/cypress/config/repo-config.csv index 2766cf6f7d..ac97718da5 100644 --- a/frontend/cypress/config/repo-config.csv +++ b/frontend/cypress/config/repo-config.csv @@ -5,3 +5,6 @@ https://github.com/reposense/testrepo-Empty2.git,master,,,,,,, https://github.com/reposense/testrepo-Empty3.git,master,,,,,,, https://github.com/reposense/testrepo-Empty4.git,master,,,,,,, https://github.com/reposense/testrepo-Empty5.git,master,,,,,,, +https://github.com/reposense/publish-RepoSense.git,master,,,,,,, +https://github.com/reposense/repoSense-action.git,main,,,,,,, +https://github.com/reposense/RepoSense-auth-helper.git,master,,,,,,, diff --git a/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js b/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js index 9f363d802a..9c3a9bc460 100644 --- a/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js +++ b/frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js @@ -8,18 +8,18 @@ describe('merge group', () => { .check() .should('be.checked'); - // after checking merge group, only one merged repo group will show + // after checking merge group, only four merged repo groups will show cy.get('#summary-charts').find('.summary-chart') - .should('have.length', 1); + .should('have.length', 4); cy.get('#summary label.merge-group > input:visible') .should('be.visible') .uncheck() .should('not.be.checked'); - // after un-checking merge group, all 5 summary charts will show + // after un-checking merge group, all 14 summary charts will show cy.get('#summary-charts').find('.summary-chart') - .should('have.length', 5); + .should('have.length', 14); }); 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, 5 merged author groups will show + // after checking merge group, 14 merged author groups will show cy.get('#summary-charts').find('.summary-chart') - .should('have.length', 5); + .should('have.length', 14); 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 5 summary charts will show + // after un-checking merge group, all 14 summary charts will show cy.get('#summary-charts').find('.summary-chart') - .should('have.length', 5); + .should('have.length', 14); }); it('merge group option should be disabled when group by none', () => { @@ -56,26 +56,22 @@ describe('merge group', () => { }); it('should have the correct number of merge group contribution bars and correct length', () => { - // Assumption: The number of merge group contribution bars is 3 and the width of the third bar is 50%. cy.get('#summary label.merge-group > input:visible') .should('be.visible') .check() .should('be.checked'); - // get the three chart bars and assert they have the correct initial widths + // get the chart bars and assert they have the correct initial widths + const expectedWidths = [100, 100, 100, 15, 100, 100, 90, 30, 15]; cy.get('.stacked-bar__contrib--bar') - .should('have.length', 3) + .should('have.length', expectedWidths.length) .then(($bars) => { // calculate the percentage of the width relative to the parent container const parentWidth = $bars.eq(0).parent().width(); - const width1 = (parseFloat(window.getComputedStyle($bars[0]).width) / parentWidth) * 100; - const width2 = (parseFloat(window.getComputedStyle($bars[1]).width) / parentWidth) * 100; - const width3 = (parseFloat(window.getComputedStyle($bars[2]).width) / parentWidth) * 100; - - // assert that the widths are close enough to 100% and 50% - expect(width1).to.be.closeTo(100, 1); - expect(width2).to.be.closeTo(100, 1); - expect(width3).to.be.closeTo(50, 1); + expectedWidths.forEach((expectedWidth, index) => { + const width = (parseFloat(window.getComputedStyle($bars[index]).width) / parentWidth) * 100; + expect(width).to.be.closeTo(expectedWidth, 1); + }); }); }); diff --git a/frontend/cypress/tests/chartView/chartView_scrollToActiveRepo.cy.js b/frontend/cypress/tests/chartView/chartView_scrollToActiveRepo.cy.js index 97afc7b1ea..aa7d3a887a 100644 --- a/frontend/cypress/tests/chartView/chartView_scrollToActiveRepo.cy.js +++ b/frontend/cypress/tests/chartView/chartView_scrollToActiveRepo.cy.js @@ -49,8 +49,8 @@ describe('scroll to active repo', () => { }); cy.url() - .should('contain', 'tabAuthor=yong24s') - .should('contain', 'tabRepo=reposense%2FRepoSense%5Bcypress%5D'); + .should('contain', 'tabAuthor=Yong%20Hao%20TENG') + .should('contain', 'tabRepo=reposense%2Fpublish-RepoSense%5Bmaster%5D'); cy.reload(); diff --git a/frontend/cypress/tests/chartView/chartView_toolBar_searchBox.cy.js b/frontend/cypress/tests/chartView/chartView_toolBar_searchBox.cy.js index 8fb9352fb6..51afc43787 100644 --- a/frontend/cypress/tests/chartView/chartView_toolBar_searchBox.cy.js +++ b/frontend/cypress/tests/chartView/chartView_toolBar_searchBox.cy.js @@ -18,7 +18,7 @@ describe('search bar', () => { it('unique author shows one result', () => { cy.get('#app #tab-resize .tab-close').click(); cy.get('#summary-wrapper input[type=text]') - .type('Yong Hao TENG') + .type('Metta') .type('{enter}'); cy.get('#summary-wrapper form.summary-picker') diff --git a/frontend/cypress/tests/codeView/codeView_switchAuthorship.cy.js b/frontend/cypress/tests/codeView/codeView_switchAuthorship.cy.js index d9667eee02..214ef84c40 100644 --- a/frontend/cypress/tests/codeView/codeView_switchAuthorship.cy.js +++ b/frontend/cypress/tests/codeView/codeView_switchAuthorship.cy.js @@ -24,7 +24,7 @@ describe('switch authorship', () => { // switch authorship view cy.get('.icon-button.fa-code') .should('exist') - .last() + .eq(4) .click(); // check default controls diff --git a/frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js b/frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js index 2ffa7eb383..dba07ecbc6 100644 --- a/frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js +++ b/frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js @@ -24,7 +24,7 @@ describe('switch zoom', () => { // switch zoom view cy.get('.icon-button.fa-list-ul') .should('exist') - .last() + .eq(4) .click(); cy.get('#tabs-wrapper').scrollTo('top');