Skip to content

Commit

Permalink
add second repo to cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasongg committed Apr 8, 2024
1 parent 84e0e4e commit 5d617d6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions frontend/cypress/config/repo-config.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ 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,,,,,,,
26 changes: 16 additions & 10 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 two merged repo groups will show
cy.get('#summary-charts').find('.summary-chart')
.should('have.length', 1);
.should('have.length', 2);

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 11 summary charts will show
cy.get('#summary-charts').find('.summary-chart')
.should('have.length', 5);
.should('have.length', 11);
});

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, 11 merged author groups will show
cy.get('#summary-charts').find('.summary-chart')
.should('have.length', 5);
.should('have.length', 11);

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 11 summary charts will show
cy.get('#summary-charts').find('.summary-chart')
.should('have.length', 5);
.should('have.length', 11);
});

it('merge group option should be disabled when group by none', () => {
Expand All @@ -64,18 +64,24 @@ describe('merge group', () => {

// get the three chart bars and assert they have the correct initial widths
cy.get('.stacked-bar__contrib--bar')
.should('have.length', 3)
.should('have.length', 6)
.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;
const width4 = (parseFloat(window.getComputedStyle($bars[3]).width) / parentWidth) * 100;
const width5 = (parseFloat(window.getComputedStyle($bars[4]).width) / parentWidth) * 100;
const width6 = (parseFloat(window.getComputedStyle($bars[5]).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);
expect(width3).to.be.closeTo(100, 1);
expect(width4).to.be.closeTo(100, 1);
expect(width5).to.be.closeTo(75, 5);
expect(width6).to.be.closeTo(25, 5);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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}');

// Enter does not work. Related issue: https://github.com/cypress-io/cypress/issues/3405
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 5d617d6

Please sign in to comment.