Skip to content

Commit

Permalink
[Filters] Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valtterikantanen committed Nov 18, 2024
1 parent f7609dc commit d013419
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
17 changes: 12 additions & 5 deletions cypress/e2e/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
})
})
}
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit d013419

Please sign in to comment.