Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more repos to cypress tests #2188

Merged
merged 12 commits into from
Apr 18, 2024
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 @@ -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
Loading