Skip to content

Commit b00a89a

Browse files
committed
Move the remember-choice Cypress tests to their own spec
Prior to this change, the per-SP remember-choice tests lived in wayf.general.spec.js, which is where the earlier stacked change moved them out of. After rebasing onto it, the additional tests from this branch still need to live next to the tooltip tests. This change adds the hidden-field, per-SP-only and legacy cookie tests to wayf.rememberChoice.spec.js.
1 parent bc87da1 commit b00a89a

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

‎tests/e2e/cypress/integration/skeune/wayf/wayf.rememberChoice.spec.js‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import {
2+
idpSelector,
3+
rememberChoiceId,
24
rememberChoicePerIdpClass,
35
rememberChoiceTooltipToggleSelector,
46
rememberChoiceTooltipValueSelector
@@ -15,6 +17,12 @@ context('WAYF per-SP remember my choice', () => {
1517
cy.get(rememberChoiceTooltipToggleSelector).should('exist');
1618
});
1719

20+
it('Renders the per-SP checkbox when only rememberChoicePerIdp is passed', () => {
21+
cy.visit('https://engine.dev.openconext.local/functional-testing/wayf?connectedIdps=5&rememberChoicePerIdp=true');
22+
cy.get(`.${rememberChoicePerIdpClass}`).should('exist');
23+
cy.onPage('Remember my choice');
24+
});
25+
1826
it('Hides the tooltip content until the toggle is activated', () => {
1927
cy.visit('https://engine.dev.openconext.local/functional-testing/wayf?connectedIdps=5&rememberChoiceFeature=true&rememberChoicePerIdp=true');
2028
cy.get(rememberChoiceTooltipValueSelector).should('not.be.visible');
@@ -50,5 +58,38 @@ context('WAYF per-SP remember my choice', () => {
5058
cy.get(rememberChoiceTooltipToggleSelector).should('not.exist');
5159
cy.onPage('Remember my choice');
5260
});
61+
62+
it('Sets the hidden rememberChoice field to 1 on the submitted IdP form when the checkbox is checked', () => {
63+
cy.visit('https://engine.dev.openconext.local/functional-testing/wayf?connectedIdps=1&addDiscoveries=0&rememberChoiceFeature=true&rememberChoicePerIdp=true');
64+
cy.window().then((win) => {
65+
cy.stub(win.HTMLFormElement.prototype, 'submit').as('formSubmit');
66+
});
67+
cy.get(`#${rememberChoiceId}`).check();
68+
cy.get(idpSelector).first().click({force: true});
69+
cy.get('@formSubmit').should('have.been.calledOnce');
70+
cy.get(idpSelector).first().find('input[name="rememberChoice"]').should('have.value', '1');
71+
});
72+
73+
it('Leaves the hidden rememberChoice field at 0 on the submitted IdP form when the checkbox is left unchecked', () => {
74+
cy.visit('https://engine.dev.openconext.local/functional-testing/wayf?connectedIdps=1&addDiscoveries=0&rememberChoiceFeature=true&rememberChoicePerIdp=true');
75+
cy.window().then((win) => {
76+
cy.stub(win.HTMLFormElement.prototype, 'submit').as('formSubmit');
77+
});
78+
cy.get(idpSelector).first().click({force: true});
79+
cy.get('@formSubmit').should('have.been.calledOnce');
80+
cy.get(idpSelector).first().find('input[name="rememberChoice"]').should('have.value', '0');
81+
});
82+
83+
it('Sets the legacy rememberchoice cookie when the checkbox is checked for the global variant', () => {
84+
cy.clearCookie('rememberchoice');
85+
cy.visit('https://engine.dev.openconext.local/functional-testing/wayf?connectedIdps=1&addDiscoveries=0&rememberChoiceFeature=true&rememberChoicePerIdp=false');
86+
cy.window().then((win) => {
87+
cy.stub(win.HTMLFormElement.prototype, 'submit').as('formSubmit');
88+
});
89+
cy.get(`#${rememberChoiceId}`).check();
90+
cy.get(idpSelector).first().click({force: true});
91+
cy.get('@formSubmit').should('have.been.calledOnce');
92+
cy.getCookie('rememberchoice').should('exist');
93+
});
5394
});
5495
});

0 commit comments

Comments
 (0)