Skip to content

Commit

Permalink
Add more repos to cypress tests (#2188)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonasongg committed Apr 18, 2024
1 parent 4cceaea commit 3c53d58
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
3 changes: 3 additions & 0 deletions frontend/cypress/config/repo-config.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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,,,,,,,
34 changes: 15 additions & 19 deletions frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -31,19 +31,19 @@ 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()
.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('merge group option should be disabled when group by none', () => {
Expand All @@ -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);
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/tests/zoomView/zoomView_switchZoom.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 3c53d58

Please sign in to comment.