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

[#2195] Add cypress test for show tag when grouping by author and by none #2197

Merged
merged 10 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/cypress/config/author-config.csv
Original file line number Diff line number Diff line change
@@ -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 TENG;yong24s,
16 changes: 8 additions & 8 deletions frontend/cypress/tests/chartView/chartView_mergeGroup.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -31,19 +31,19 @@ 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()
.should('be.visible')
.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', () => {
Expand All @@ -62,15 +62,15 @@ 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, 20, 100, 100, 3, 20, 5];
cy.get('.stacked-bar__contrib--bar')
.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();
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, 2);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
87 changes: 87 additions & 0 deletions frontend/cypress/tests/chartView/chartView_showTags.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,91 @@ 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()
.find('.summary-chart__title--tags')
.find('a')
.should('have.length', 0);

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);
});
});
});
2 changes: 1 addition & 1 deletion frontend/src/components/c-summary-charts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ export default defineComponent({
},

getTags(repo: Array<User>, user?: User): Array<string> {
if (user) repo = repo.filter((r) => r.name === user.name);
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<string>;
},
Expand Down
Loading