From e02b9a9379e4246073f8da4c30b7f0e20d825379 Mon Sep 17 00:00:00 2001 From: Don Walizer <12420708+dwalizer@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:52:49 -0500 Subject: [PATCH] #2218 Add tests for group toggle switch --- .../e2e/client-display/client-display_spec.js | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/e2e-tests/cypress/e2e/client-display/client-display_spec.js b/e2e-tests/cypress/e2e/client-display/client-display_spec.js index bb1d101e44..e11c0c4573 100644 --- a/e2e-tests/cypress/e2e/client-display/client-display_spec.js +++ b/e2e-tests/cypress/e2e/client-display/client-display_spec.js @@ -391,6 +391,96 @@ describe('Client Display Tests', () => { }); }); + it('ability to expand and collapse groups from subject page', () => { + for(let x = 1; x <= 2; x++) { + cy.createSkillsGroup(1, 2, x); + let startingSkill = 11 * x + for(let y = startingSkill; y < startingSkill + 3; y++) { + cy.addSkillToGroup(1, 2, x, y, { + pointIncrement: 50, + numPerformToCompletion: 2 + }); + } + } + + cy.cdVisit('/', true); + cy.cdClickSubj(1, 'Subject 2', false); + + cy.get('[data-cy=expandGroupsSwitch] input').should('be.checked') + checkGroupSkillExistence(true) + + cy.get('[data-cy=expandGroupsSwitch]').click() + cy.get('[data-cy=expandGroupsSwitch] input').should('not.be.checked') + checkGroupSkillExistence(false) + + cy.get('[data-cy=expandGroupsSwitch]').click() + cy.get('[data-cy=expandGroupsSwitch] input').should('be.checked') + checkGroupSkillExistence(true) + + cy.get('[data-cy="toggleGroup-group1Subj2"]').click() + cy.get('#skillProgressTitleLink-skill11Subj2').should('not.exist'); + cy.get('#skillProgressTitleLink-skill12Subj2').should('not.exist'); + cy.get('#skillProgressTitleLink-skill13Subj2').should('not.exist'); + cy.get('#skillProgressTitleLink-skill22Subj2').should('exist'); + cy.get('#skillProgressTitleLink-skill23Subj2').should('exist'); + cy.get('#skillProgressTitleLink-skill24Subj2').should('exist'); + + cy.get('[data-cy="toggleGroup-group2Subj2"]').click() + checkGroupSkillExistence(false) + + cy.get('[data-cy="toggleGroup-group1Subj2"]').click() + cy.get('#skillProgressTitleLink-skill11Subj2').should('exist'); + cy.get('#skillProgressTitleLink-skill12Subj2').should('exist'); + cy.get('#skillProgressTitleLink-skill13Subj2').should('exist'); + cy.get('#skillProgressTitleLink-skill22Subj2').should('not.exist'); + cy.get('#skillProgressTitleLink-skill23Subj2').should('not.exist'); + cy.get('#skillProgressTitleLink-skill24Subj2').should('not.exist'); + }); + + it('group expansion state persists', () => { + for(let x = 1; x <= 2; x++) { + cy.createSkillsGroup(1, 2, x); + let startingSkill = 11 * x + for(let y = startingSkill; y < startingSkill + 3; y++) { + cy.addSkillToGroup(1, 2, x, y, { + pointIncrement: 50, + numPerformToCompletion: 2 + }); + } + } + + cy.cdVisit('/subjects/subj2'); + + cy.get('[data-cy=expandGroupsSwitch] input').should('be.checked') + checkGroupSkillExistence(true) + + cy.get('[data-cy=expandGroupsSwitch]').click() + cy.get('[data-cy=expandGroupsSwitch] input').should('not.be.checked') + checkGroupSkillExistence(false) + + cy.cdVisit('/subjects/subj2'); + cy.get('[data-cy=expandGroupsSwitch] input').should('not.be.checked') + checkGroupSkillExistence(false) + + cy.cdVisit('/subjects/subj1'); + cy.get('[data-cy=expandGroupsSwitch] input').should('not.be.checked') + + cy.get('[data-cy=expandGroupsSwitch]').click() + cy.get('[data-cy=expandGroupsSwitch] input').should('be.checked') + + cy.cdVisit('/subjects/subj2'); + cy.get('[data-cy=expandGroupsSwitch] input').should('be.checked') + checkGroupSkillExistence(true) + }); + + const checkGroupSkillExistence = (exists) => { + for(let group = 1; group <= 2; group++) { + let startingSkill = 11 * group + for(let y = startingSkill; y < startingSkill + 3; y++) { + cy.get(`#skillProgressTitleLink-skill${y}Subj2`).should(exists ? 'exist' : 'not.exist'); + } + } + } });