From c7924d094b201e9f0370df519a786f92f5a3dc10 Mon Sep 17 00:00:00 2001 From: Karine St-Onge Date: Tue, 7 Jan 2025 09:24:24 -0500 Subject: [PATCH] feat: SKFP-1416 Adjust Cypress tests related to recent changes --- .../e2e/Facettes/PageDataExploration.cy.ts | 14 +++++----- cypress/e2e/Facettes/PageVariants.cy.ts | 28 +++++++++---------- .../SampleDataTableauBiospecimens.cy.ts | 2 +- .../Telechargement/TableauBiospecimens.cy.ts | 2 +- cypress/e2e/Telechargement/TableauFiles.cy.ts | 2 +- .../Telechargement/TableauParticipants.cy.ts | 2 +- cypress/e2e/Widgets/BiospecimenRequests.cy.ts | 4 +-- cypress/e2e/Widgets/CavaticaProjects.cy.ts | 10 +++---- cypress/e2e/Widgets/SavedFilters.cy.ts | 4 +-- cypress/e2e/Widgets/SavedSets.cy.ts | 4 +-- cypress/support/commands.ts | 19 ++++++++++--- cypress/support/index.d.ts | 4 +-- 12 files changed, 53 insertions(+), 42 deletions(-) diff --git a/cypress/e2e/Facettes/PageDataExploration.cy.ts b/cypress/e2e/Facettes/PageDataExploration.cy.ts index 80fb484bb..f4b781703 100644 --- a/cypress/e2e/Facettes/PageDataExploration.cy.ts +++ b/cypress/e2e/Facettes/PageDataExploration.cy.ts @@ -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)'); }); @@ -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)'); }); @@ -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'); }); diff --git a/cypress/e2e/Facettes/PageVariants.cy.ts b/cypress/e2e/Facettes/PageVariants.cy.ts index 22f60b9eb..c6ec33385 100644 --- a/cypress/e2e/Facettes/PageVariants.cy.ts +++ b/cypress/e2e/Facettes/PageVariants.cy.ts @@ -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'); }); @@ -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'); }); @@ -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'); }); @@ -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'); }); @@ -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'); }); }); \ No newline at end of file diff --git a/cypress/e2e/Telechargement/SampleDataTableauBiospecimens.cy.ts b/cypress/e2e/Telechargement/SampleDataTableauBiospecimens.cy.ts index cc2b1913e..512609312 100644 --- a/cypress/e2e/Telechargement/SampleDataTableauBiospecimens.cy.ts +++ b/cypress/e2e/Telechargement/SampleDataTableauBiospecimens.cy.ts @@ -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); }); diff --git a/cypress/e2e/Telechargement/TableauBiospecimens.cy.ts b/cypress/e2e/Telechargement/TableauBiospecimens.cy.ts index 2041f1140..dc2d328d2 100644 --- a/cypress/e2e/Telechargement/TableauBiospecimens.cy.ts +++ b/cypress/e2e/Telechargement/TableauBiospecimens.cy.ts @@ -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); }); diff --git a/cypress/e2e/Telechargement/TableauFiles.cy.ts b/cypress/e2e/Telechargement/TableauFiles.cy.ts index c7c6e9291..9a9c66bb6 100644 --- a/cypress/e2e/Telechargement/TableauFiles.cy.ts +++ b/cypress/e2e/Telechargement/TableauFiles.cy.ts @@ -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); }); diff --git a/cypress/e2e/Telechargement/TableauParticipants.cy.ts b/cypress/e2e/Telechargement/TableauParticipants.cy.ts index cb7813b0e..1b017585d 100644 --- a/cypress/e2e/Telechargement/TableauParticipants.cy.ts +++ b/cypress/e2e/Telechargement/TableauParticipants.cy.ts @@ -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); }); diff --git a/cypress/e2e/Widgets/BiospecimenRequests.cy.ts b/cypress/e2e/Widgets/BiospecimenRequests.cy.ts index 8d743a84d..c8a7fa561 100644 --- a/cypress/e2e/Widgets/BiospecimenRequests.cy.ts +++ b/cypress/e2e/Widgets/BiospecimenRequests.cy.ts @@ -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) => { if ($el.text().includes('Biospecimen Requests')) { diff --git a/cypress/e2e/Widgets/CavaticaProjects.cy.ts b/cypress/e2e/Widgets/CavaticaProjects.cy.ts index 2a0631e0e..9fffee0cc 100644 --- a/cypress/e2e/Widgets/CavaticaProjects.cy.ts +++ b/cypress/e2e/Widgets/CavaticaProjects.cy.ts @@ -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'); }); }); diff --git a/cypress/e2e/Widgets/SavedFilters.cy.ts b/cypress/e2e/Widgets/SavedFilters.cy.ts index c80c9ecee..c3b546ddc 100644 --- a/cypress/e2e/Widgets/SavedFilters.cy.ts +++ b/cypress/e2e/Widgets/SavedFilters.cy.ts @@ -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'); }); diff --git a/cypress/e2e/Widgets/SavedSets.cy.ts b/cypress/e2e/Widgets/SavedSets.cy.ts index 8ea099834..0a69f32a0 100644 --- a/cypress/e2e/Widgets/SavedSets.cy.ts +++ b/cypress/e2e/Widgets/SavedSets.cy.ts @@ -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'); }); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index aa3be6a67..e68dd1e96 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -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}); @@ -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}); } diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index 46d5b3886..7d27b0aa6 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -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): Chainable; closePopup(): cy & CyEventEmitter; createBioReqIfNotExists(bioreqName: string, itemPosition: number): cy & CyEventEmitter; @@ -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;