Skip to content

Commit

Permalink
#2218 Add tests for group toggle switch
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalizer committed Dec 31, 2024
1 parent cdc4b04 commit e258f60
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions e2e-tests/cypress/e2e/client-display/client-display_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
});


0 comments on commit e258f60

Please sign in to comment.