Skip to content

Commit

Permalink
feat: SKFP-1416 Adjust Cypress tests related to recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Karine St-Onge committed Jan 7, 2025
1 parent c7824d0 commit c7924d0
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 42 deletions.
14 changes: 7 additions & 7 deletions cypress/e2e/Facettes/PageDataExploration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,17 @@ describe('Page Data Exploration (Clinical) - Filtrer avec les facettes', () => {
});

it('Age at Diagnosis (days) - 1000', () => {
cy.validateFacetNumFilter('Age at Diagnosis (days)', '1000', /\d{1}/, true, 1);
cy.validateFacetNumFilter('Max', 'Age at Diagnosis (days)', '1000', /\d{1}/, true, 1);
cy.validateFacetRank(0, 'Age at Diagnosis (days)');
});

it('Age at Vital Status (days) - 1000', () => {
cy.validateFacetNumFilter('Age at Vital Status (days)', '1000', /\d{1}/, true, 1);
cy.validateFacetNumFilter('Max', 'Age at Vital Status (days)', '1000', /\d{1}/, true, 1);
cy.validateFacetRank(1, 'Age at Vital Status (days)');
});

it('Age at Observed Phenotype (days) - 1000', () => {
cy.validateFacetNumFilter('Age at Observed Phenotype (days)', '1000', /\d{1}/, true, 1);
cy.validateFacetNumFilter('Max', 'Age at Observed Phenotype (days)', '1000', /\d{1}/, true, 1);
cy.validateFacetRank(2, 'Age at Observed Phenotype (days)');
});

Expand Down Expand Up @@ -297,12 +297,12 @@ describe('Page Data Exploration (Biospecimen) - Filtrer avec les facettes', () =
});

it('Age at Biospec. Collection (days) - 2000', () => {
cy.validateFacetNumFilter('Age at Biospec. Collection (days)', '2000', /\d{1}/, true, 1);
cy.validateFacetNumFilter('Max', 'Age at Biospec. Collection (days)', '2000', /\d{1}/, true, 1);
cy.validateFacetRank(2, 'Age at Biospec. Collection (days)');
});

it('Age at Histological Diagnosis (days) - 1000', () => {
cy.validateFacetNumFilter('Age at Histological Diagnosis (days)', '1000', /\d{1}/, true, 1);
cy.validateFacetNumFilter('Max', 'Age at Histological Diagnosis (days)', '1000', /\d{1}/, true, 1);
cy.validateFacetRank(3, 'Age at Histological Diagnosis (days)');
});

Expand Down Expand Up @@ -507,8 +507,8 @@ describe('Page Data Exploration (Data Files) - Filtrer avec les facettes', () =>
cy.validateFacetRank(14, 'Body Part Examined');
});

it('Magnetic Field Strength - Illumina', () => {
cy.validateFacetNumFilter('Magnetic Field Strength', '2', /\d{1}/, true);
it('Magnetic Field Strength', () => {
cy.validateFacetNumFilter('Min', 'Magnetic Field Strength', '2', /\d{1}/, true);
cy.validateFacetRank(15, 'Magnetic Field Strength');
});

Expand Down
28 changes: 14 additions & 14 deletions cypress/e2e/Facettes/PageVariants.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe('Page des variants (Variant) - Filtrer avec les facettes', () => {
});

it('Position', () => {
cy.validateFacetNumFilter('Position', '100000', /^16,050$/, false, 1);
cy.validateFacetNumFilter('MinMax', 'Position', '119345794', /^1$/, false, 1);
cy.validateFacetRank(4, 'Position');
});

Expand Down Expand Up @@ -275,12 +275,12 @@ describe('Page des variants (Gene) - Filtrer avec les facettes', () => {
});

it('gnomAD pLI', () => {
cy.validateFacetNumFilter('gnomAD pLI', '0.01', /^7,450,643$/, false, 1);
cy.validateFacetNumFilter('Min', 'gnomAD pLI', '0.01', /^7,391,061$/, false, 1);
cy.validateFacetRank(2, 'gnomAD pLI');
});

it('gnomAD LOEUF', () => {
cy.validateFacetNumFilter('gnomAD LOEUF', '0.05', /^20,617$/, false, 1);
cy.validateFacetNumFilter('Max', 'gnomAD LOEUF', '0.05', /^20,617$/, false, 1);
cy.validateFacetRank(3, 'gnomAD LOEUF');
});

Expand Down Expand Up @@ -348,17 +348,17 @@ describe('Page des variants (Pathogenicity) - Filtrer avec les facettes', () =>
});

it('CADD (Raw)', () => {
cy.validateFacetNumFilter('CADD (Raw)', '0.01', /^16,878$/, false, 1);
cy.validateFacetNumFilter('Min', 'CADD (Raw)', '0.01', /^90,349$/, false, 1);
cy.validateFacetRank(2, 'CADD (Raw)');
});

it('CADD (Phred)', () => {
cy.validateFacetNumFilter('CADD (Phred)', '0.01', /^3,437$/, false, 1);
cy.validateFacetNumFilter('Min', 'CADD (Phred)', '0.01', /^103,690$/, false, 1);
cy.validateFacetRank(3, 'CADD (Phred)');
});

it('DANN', () => {
cy.validateFacetNumFilter('DANN', '0.1', /^818$/, false, 1);
cy.validateFacetNumFilter('Min', 'DANN', '0.1', /^105,002$/, false, 1);
cy.validateFacetRank(4, 'DANN');
});

Expand All @@ -378,12 +378,12 @@ describe('Page des variants (Pathogenicity) - Filtrer avec les facettes', () =>
});

it('REVEL', () => {
cy.validateFacetNumFilter('REVEL', '0.01', /^2,753$/, false, 1);
cy.validateFacetNumFilter('Min', 'REVEL', '0.01', /^92,081$/, false, 1);
cy.validateFacetRank(8, 'REVEL');
});

it('SpliceAI', () => {
cy.validateFacetNumFilter('SpliceAI', '0.01', /^8,589,370$/, false, 1);
cy.validateFacetNumFilter('Min', 'SpliceAI', '0.01', /^533,121$/, false, 1);
cy.validateFacetRank(9, 'SpliceAI');
});

Expand Down Expand Up @@ -412,32 +412,32 @@ describe('Page des variants (Frequency) - Filtrer avec les facettes', () => {
});

it('KF Allele Frequency', () => {
cy.validateFacetNumFilter('KF Allele Frequency', '0.01', /^17,512,325$/, false, 1);
cy.validateFacetNumFilter('Max', 'KF Allele Frequency', '0.01', /^17,512,325$/, false, 1);
cy.validateFacetRank(0, 'KF Allele Frequency');
});

it('gnomAD Genome 2.1.1', () => {
cy.validateFacetNumFilter('gnomAD Genome 2.1.1', '0.01', /^10,227,849$/, false, 1);
cy.validateFacetNumFilter('Max', 'gnomAD Genome 2.1.1', '0.01', /^10,227,849$/, false, 1);
cy.validateFacetRank(1, 'gnomAD Genome 2.1.1');
});

it('gnomAD Genome 3.1.2', () => {
cy.validateFacetNumFilter('gnomAD Genome 3.1.2', '0.01', /^13,410,289$/, false, 1);
cy.validateFacetNumFilter('Max', 'gnomAD Genome 3.1.2', '0.01', /^13,410,289$/, false, 1);
cy.validateFacetRank(2, 'gnomAD Genome 3.1.2');
});

it('gnomAD Exome 2.1.1', () => {
cy.validateFacetNumFilter('gnomAD Exome 2.1.1', '0.01', /^211,175$/, false, 1);
cy.validateFacetNumFilter('Max', 'gnomAD Exome 2.1.1', '0.01', /^211,175$/, false, 1);
cy.validateFacetRank(3, 'gnomAD Exome 2.1.1');
});

it('TopMed', () => {
cy.validateFacetNumFilter('TopMed', '0.01', /^11,270,523$/, false, 1);
cy.validateFacetNumFilter('Max', 'TopMed', '0.01', /^11,270,523$/, false, 1);
cy.validateFacetRank(4, 'TopMed');
});

it('1000 Genomes', () => {
cy.validateFacetNumFilter('1000 Genomes', '0.01', /^125,526$/, false, 1);
cy.validateFacetNumFilter('Max', '1000 Genomes', '0.01', /^125,526$/, false, 1);
cy.validateFacetRank(5, '1000 Genomes');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ beforeEach(() => {
cy.visitDataExploration('biospecimens', '?sharedFilterId=c80e4b42-a3e3-4525-a425-933b44eafef9');
cy.sortTableAndIntercept('Study', 1);
cy.get('div[role="tabpanel"] [class*="ant-table-row"]').eq(0).find('[type="checkbox"]').check({force: true});
cy.clickAndIntercept('[class*="Header_ProTableHeader"] button[class*="ant-btn-default"]', 'POST', '**/biospecimen-data', 1, 1);
cy.clickAndIntercept('[class*="Header_ProTableHeader"] button[class*="ant-btn-default"]', 'POST', '**/biospecimen-data', 1, false/*beVisible*/, 1);
cy.waitUntilFile(oneMinute);
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/Telechargement/TableauBiospecimens.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ beforeEach(() => {
cy.showColumn('External Sample ID');
cy.showColumn('External Collection ID');

cy.clickAndIntercept('div[id="content"] svg[data-icon="download"]', 'POST', '**/download', 1, 1);
cy.clickAndIntercept('div[id="content"] svg[data-icon="download"]', 'POST', '**/download', 1, false/*beVisible*/, 1);
cy.waitUntilFile(oneMinute);
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/Telechargement/TableauFiles.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ beforeEach(() => {
cy.showColumn('Device ID');
cy.wait(1000);

cy.clickAndIntercept('div[id="content"] svg[data-icon="download"]', 'POST', '**/download', 1, 1);
cy.clickAndIntercept('div[id="content"] svg[data-icon="download"]', 'POST', '**/download', 1, false/*beVisible*/, 1);
cy.waitUntilFile(oneMinute);
});

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/Telechargement/TableauParticipants.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ beforeEach(() => {
cy.showColumn('Observed Phenotype (Source Text)');
cy.wait(1000);

cy.clickAndIntercept('div[id="content"] svg[data-icon="download"]', 'POST', '**/download', 1, 1);
cy.clickAndIntercept('div[id="content"] svg[data-icon="download"]', 'POST', '**/download', 1, false/*beVisible*/, 1);
cy.waitUntilFile(oneMinute);
});

Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/Widgets/BiospecimenRequests.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ describe('Page Dashboard - Widget Biospecimen Requests', () => {
cy.wrap($el).find('svg[data-icon="edit"]').clickAndWait({force:true});
};
});
cy.get('[class="ant-modal-content"] input').clear().type('Cypress_BrB');
cy.get('[class="ant-modal-content"] input[id="name"]').filter(':visible').clear().type('Cypress_BrB');
cy.get(`[class="ant-modal-content"] input[value="Cypress_BrB"]`).should('exist');
cy.clickAndIntercept('[class="ant-modal-content"] button[class*="ant-btn-primary"]', 'PUT', '**/sets/**', 1);
cy.clickAndIntercept('[class="ant-modal-content"] button[class*="ant-btn-primary"]', 'PUT', '**/sets/**', 1, true/*beVisible*/);

cy.get('[class*="DashboardCards_dashboardCard"]').each(($el: JQuery<HTMLElement>) => {
if ($el.text().includes('Biospecimen Requests')) {
Expand Down
10 changes: 5 additions & 5 deletions cypress/e2e/Widgets/CavaticaProjects.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ describe('Page Dashboard - Widget Cavatica Projects (connecté)', () => {
});

cy.get('@cavaticaFooter').find('button').clickAndWait({force: true});
cy.get('[class="ant-modal-title"]').contains('New project').should('exist');
cy.get('label[for="project_name"]').contains('Project name').should('exist');
cy.get('input').should('have.attr', 'placeholder', 'e.g. KF-NBL Neuroblastoma Aligned Reads');
cy.get('label[for="project_billing_group"]').contains('Project billing group').should('exist');
cy.get('[class="ant-select-selection-item"]').contains('Pilot Funds (mock)').should('exist');
cy.get('[class*="CavaticaCreateProjectModal"] [class="ant-modal-title"]').contains('New project').should('exist');
cy.get('[class*="CavaticaCreateProjectModal"] label[for="project_name"]').contains('Project name').should('exist');
cy.get('[class*="CavaticaCreateProjectModal"] input').should('have.attr', 'placeholder', 'e.g. KF-NBL Neuroblastoma Aligned Reads');
cy.get('[class*="CavaticaCreateProjectModal"] label[for="project_billing_group"]').contains('Project billing group').should('exist');
cy.get('[class*="CavaticaCreateProjectModal"] [class="ant-select-selection-item"]').contains('Pilot Funds (mock)').should('exist');
});
});
4 changes: 2 additions & 2 deletions cypress/e2e/Widgets/SavedFilters.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ describe('Page Dashboard - Widget Saved Filters', () => {
cy.wrap($el).find('svg[data-icon="edit"]').clickAndWait({force:true});
}
});
cy.get('[class="ant-modal-content"] input').clear().type('Cypress_FB');
cy.get('[class="ant-modal-content"] input[id="title"]').filter(':visible').clear().type('Cypress_FB');
cy.get(`[class="ant-modal-content"] input[value="Cypress_FB"]`).should('exist');
cy.clickAndIntercept('[class="ant-modal-content"] button[class*="ant-btn-primary"]', 'PUT', '**/saved-filters', 1);
cy.clickAndIntercept('[class="ant-modal-content"] button[class*="ant-btn-primary"]', 'PUT', '**/saved-filters', 1, true/*beVisible*/);
cy.get('[class*="SavedFilters_setTabs"]').contains('Cypress_FB').should('exist');
cy.get('[class*="SavedFilters_setTabs"]').contains('Cypress_FA').should('not.exist');
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/Widgets/SavedSets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ describe('Page Dashboard - Widget Saved Sets', () => {
cy.wrap($el).find('svg[data-icon="edit"]').clickAndWait({force:true});
}
});
cy.get('[class="ant-modal-content"] input').clear().type('Cypress_SB');
cy.get('[class="ant-modal-content"] input[id="save-set_nameSet"]').filter(':visible').clear().type('Cypress_SB');
cy.get('[class="ant-modal-content"] input[value="Cypress_SB"]').should('exist');
cy.clickAndIntercept('[class="ant-modal-content"] button[class*="ant-btn-primary"]', 'PUT', '**/sets/**', 1);
cy.clickAndIntercept('[class="ant-modal-content"] button[class*="ant-btn-primary"]', 'PUT', '**/sets/**', 1, true/*beVisible*/);
cy.get('[class*="SavedSets_setTabs"]').contains('Cypress_SB').should('exist');
cy.get('[class*="SavedSets_setTabs"]').contains('Cypress_SA').should('not.exist');
});
Expand Down
19 changes: 15 additions & 4 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ Cypress.Commands.add('checkValueFacet', (facetTitle: string, value: string) => {
cy.waitWhileSpin(oneMinute);
});

Cypress.Commands.add('clickAndIntercept', (selector: string, methodHTTP: string, routeMatcher: string, nbCalls: number, eq?: number) => {
Cypress.Commands.add('clickAndIntercept', (selector: string, methodHTTP: string, routeMatcher: string, nbCalls: number, beVisible: boolean = false, eq?: number) => {
if (!eq) {
eq = 0;
}

cy.intercept(methodHTTP, routeMatcher).as('getRouteMatcher');

cy.get(selector).eq(eq).clickAndWait({force: true});
if (beVisible) {
cy.get(selector).filter(':visible').eq(eq).clickAndWait({force: true});
}
else {
cy.get(selector).eq(eq).clickAndWait({force: true});
}

for (let i = 0; i < nbCalls; i++) {
cy.wait('@getRouteMatcher', {timeout: oneMinute});
Expand Down Expand Up @@ -350,9 +355,15 @@ Cypress.Commands.add('validateFacetFilter', (facetTitle: string, valueFront: str
cy.validateTableResultsCount(expectedCount);
});

Cypress.Commands.add('validateFacetNumFilter', (facetTitle: string, value: string, expectedCount: string|RegExp, isNoData: Boolean = false, eq: number = 0) => {
Cypress.Commands.add('validateFacetNumFilter', (operator: string, facetTitle: string, value: string, expectedCount: string|RegExp, isNoData: Boolean = false, eq: number = 0) => {
cy.wait(2000);
cy.get(`[data-cy="InputNumber_Max_${facetTitle}"]`).type(value, {force: true});
if (operator === 'MinMax') {
cy.get(`[data-cy="InputNumber_Min_${facetTitle}"]`).type(value, {force: true});
cy.get(`[data-cy="InputNumber_Max_${facetTitle}"]`).type(value, {force: true});
}
else {
cy.get(`[data-cy="InputNumber_${operator}_${facetTitle}"]`).type(value, {force: true});
}
if (isNoData) {
cy.get(`[data-cy="Checkbox_NoData_${facetTitle}"]`).check({force: true});
}
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ declare namespace Cypress {
interface Chainable {
checkValueFacetAndApply(facetTitle: string, value: string): cy & CyEventEmitter;
checkValueFacet(facetTitle: string, value: string): cy & CyEventEmitter;
clickAndIntercept(selector: string, methodHTTP: string, routeMatcher: string, nbCalls: number, eq?: number): cy & CyEventEmitter;
clickAndIntercept(selector: string, methodHTTP: string, routeMatcher: string, nbCalls: number, beVisible: boolean = false, eq?: number): cy & CyEventEmitter;
clickAndWait(options?: Partial<ClickOptions>): Chainable<Element>;
closePopup(): cy & CyEventEmitter;
createBioReqIfNotExists(bioreqName: string, itemPosition: number): cy & CyEventEmitter;
Expand All @@ -29,7 +29,7 @@ declare namespace Cypress {
typeAndIntercept(selector: string, text: string, methodHTTP: string, routeMatcher: string, nbCalls: number, eq: number = 0): cy & CyEventEmitter;
validateClearAllButton(shouldExist: boolean): cy & CyEventEmitter;
validateFacetFilter(facetTitle: string, valueFront: string, valueBack: string, expectedCount: string|RegExp, eq: number = 0, applyButton: boolean = true): cy & CyEventEmitter;
validateFacetNumFilter(facetTitle: string, value: string, expectedCount: string|RegExp, isNoData: Boolean = false, eq: number = 0): cy & CyEventEmitter;
validateFacetNumFilter(operator: string, facetTitle: string, value: string, expectedCount: string|RegExp, isNoData: Boolean = false, eq: number = 0): cy & CyEventEmitter;
validateFacetRank(facetRank: number, facetTitle: string): cy & CyEventEmitter;
validateFileContent(fixture: string, replacements?: Replacement[]): cy & CyEventEmitter;
validateFileHeaders(fixture: string): cy & CyEventEmitter;
Expand Down

0 comments on commit c7924d0

Please sign in to comment.