Skip to content

Commit

Permalink
Fix mistake in conditions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienClairembault authored and trasher committed Feb 18, 2025
1 parent 3344660 commit f6a5bd1
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions tests/cypress/e2e/form/editor/conditions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,24 +578,28 @@ describe ('Conditions', () => {
preview();

// The form questions are all empty, we expect the following default state
validateThatQuestionIsVisible("My question used as a criteria");
validateThatQuestionIsVisible("My question that is always visible");
validateThatQuestionIsNotVisible("My question that is visible if some criteria are met");
validateThatQuestionIsVisible("My question that is hidden if some criteria are met");

// Note: after changing the answer, make sure that the first value that is being
// checked has a different visibility that in the previous assertions.
// Indeed, if we don't do that the assertion might be validated instantly
// before the UI is updated with the new visibilities.
// By checking for a different value, we make sure the first assertion can't
// run until the UI is updated - thus making the other assertions safe.

// Set first answer to "Expected answer 1" and check the displayed content again.
setTextAnswer("My question used as a criteria", "Expected answer 1");
validateThatQuestionIsVisible("My question used as a criteria");
validateThatQuestionIsVisible("My question that is always visible");
validateThatQuestionIsVisible("My question that is visible if some criteria are met");
validateThatQuestionIsVisible("My question that is hidden if some criteria are met");
validateThatQuestionIsVisible("My question that is always visible");

// Set first answer to "Expected answer 2" and check the displayed content again.
setTextAnswer("My question used as a criteria", "Expected answer 2");
validateThatQuestionIsVisible("My question used as a criteria");
validateThatQuestionIsVisible("My question that is always visible");
validateThatQuestionIsVisible("My question that is visible if some criteria are met");
validateThatQuestionIsNotVisible("My question that is hidden if some criteria are met");
validateThatQuestionIsNotVisible("My question that is visible if some criteria are met");
validateThatQuestionIsVisible("My question that is always visible");
});

it('conditions are applied on comments', () => {
Expand Down Expand Up @@ -638,24 +642,28 @@ describe ('Conditions', () => {
preview();

// The form questions are all empty, we expect the following default state
validateThatQuestionIsVisible("My question used as a criteria");
validateThatCommentIsVisible("My comment that is always visible");
validateThatCommentIsNotVisible("My comment that is visible if some criteria are met");
validateThatCommentIsVisible("My comment that is hidden if some criteria are met");
validateThatCommentIsNotVisible("My comment that is visible if some criteria are met");

// Note: after changing the answer, make sure that the first value that is being
// checked has a different visibility that in the previous assertions.
// Indeed, if we don't do that the assertion might be validated instantly
// before the UI is updated with the new visibilities.
// By checking for a different value, we make sure the first assertion can't
// run until the UI is updated - thus making the other assertions safe.

// Set first answer to "Expected answer 1" and check the displayed content again.
setTextAnswer("My question used as a criteria", "Expected answer 1");
validateThatQuestionIsVisible("My question used as a criteria");
validateThatCommentIsVisible("My comment that is always visible");
validateThatCommentIsVisible("My comment that is visible if some criteria are met");
validateThatCommentIsVisible("My comment that is hidden if some criteria are met");
validateThatCommentIsVisible("My comment that is always visible");

// Set first answer to "Expected answer 2" and check the displayed content again.
setTextAnswer("My question used as a criteria", "Expected answer 2");
validateThatQuestionIsVisible("My question used as a criteria");
validateThatCommentIsVisible("My comment that is always visible");
validateThatCommentIsVisible("My comment that is visible if some criteria are met");
validateThatCommentIsNotVisible("My comment that is hidden if some criteria are met");
validateThatCommentIsNotVisible("My comment that is visible if some criteria are met");
validateThatCommentIsVisible("My comment that is always visible");
});

it('conditions are applied on sections', () => {
Expand Down

0 comments on commit f6a5bd1

Please sign in to comment.