From d0134192c6cece007be1576c275b7fbe8063003a Mon Sep 17 00:00:00 2001 From: Valtteri Kantanen Date: Mon, 18 Nov 2024 17:14:51 +0200 Subject: [PATCH] [Filters] Fix tests --- cypress.config.js | 6 +++--- cypress/e2e/Filters.js | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cypress.config.js b/cypress.config.js index d1c4a56b2b..3fabeac8b8 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,7 +1,7 @@ -/* eslint-disable global-require */ -/* eslint-disable import/extensions */ +/* eslint-disable @typescript-eslint/no-require-imports */ +/* eslint-disable import/no-commonjs */ /* eslint-disable import/no-extraneous-dependencies */ - +/* eslint-disable import/no-unused-modules */ const { defineConfig } = require('cypress') module.exports = defineConfig({ diff --git a/cypress/e2e/Filters.js b/cypress/e2e/Filters.js index 4ad4ed889e..90d8275cb1 100644 --- a/cypress/e2e/Filters.js +++ b/cypress/e2e/Filters.js @@ -18,7 +18,6 @@ const clearSingleDropdownSelection = dataCyAttribute => { } const testRangeFilter = (parentEl, min, max, expected) => { - cy.clock(MOCKED_DATE, ['Date']) cy.cs(parentEl) .cs('range-selector-min') .find('input') @@ -29,13 +28,17 @@ const testRangeFilter = (parentEl, min, max, expected) => { .find('input') .invoke('val') .then(initialMax => { - cy.cs(parentEl).cs('range-selector-min').find('input').type(`{selectall}{backspace}${min}`).blur() - cy.cs(parentEl).cs('range-selector-max').find('input').type(`{selectall}{backspace}${max}`).blur() + cy.cs(parentEl).cs('range-selector-min').find('input').clear() + cy.cs(parentEl).cs('range-selector-min').find('input').type(min) + cy.cs(parentEl).cs('range-selector-max').find('input').clear() + cy.cs(parentEl).cs('range-selector-max').find('input').type(max) checkFilteringResult(expected) - cy.cs(parentEl).cs('range-selector-min').find('input').type(`{selectall}{backspace}${initialMin}`).blur() - cy.cs(parentEl).cs('range-selector-max').find('input').type(`{selectall}{backspace}${initialMax}`).blur() + cy.cs(parentEl).cs('range-selector-min').find('input').clear() + cy.cs(parentEl).cs('range-selector-min').find('input').type(initialMin) + cy.cs(parentEl).cs('range-selector-max').find('input').clear() + cy.cs(parentEl).cs('range-selector-max').find('input').type(initialMax) }) }) } @@ -169,6 +172,7 @@ describe('Population Statistics', () => { }) it('Age filter works', { retries: 3 }, () => { + cy.clock(MOCKED_DATE, ['Date']) runTestStepWithPreAndPostParts('Age', () => { testRangeFilter('Age-filter-card', 23, 30, 21) }) @@ -228,6 +232,7 @@ describe('Population Statistics', () => { }) it('Filter combinations work', () => { + cy.clock(MOCKED_DATE, ['Date']) runTestStepWithPreAndPostParts('GraduatedFromProgramme', () => { runTestStepWithPreAndPostParts('Age', () => { const getCard = () => cy.cs('GraduatedFromProgramme-filter-card') @@ -291,6 +296,7 @@ describe('Course Statistics', () => { }) it('Age filter works', { retries: 3 }, () => { + cy.clock(MOCKED_DATE, ['Date']) runTestStepWithPreAndPostParts('Age', () => { testRangeFilter('Age-filter-card', 21, 30, 36) }) @@ -322,6 +328,7 @@ describe('Course Statistics', () => { }) it('Filter combinations work', () => { + cy.clock(MOCKED_DATE, ['Date']) runTestStepWithPreAndPostParts('Grade', () => { runTestStepWithPreAndPostParts('Age', () => { cy.cs('gradeFilter-5').click()