Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HS-1245681 Fix Hidden Question Validation #867

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/scripts/services/validateRegistrant.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ angular
block,
registrant,
ruleTypeConstants.SHOW_QUESTION,
conference,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add this to this.checkboxDisable also?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will be done in a follow-up PR

) ||
!blockInRegistrantType(block, registrant)
) {
Expand Down
31 changes: 30 additions & 1 deletion test/spec/services/validateRegistrant.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ describe('Service: validateRegistrant', function () {
).toBe(true);
});

it('should hide the child and grandchild questions when the parent answer change and the child is hidden', function () {
it('should hide the child and grandchild questions when the parent answer changes and the child is hidden', function () {
// all are visible
answerParent.value = 'radio option - hide child';
answerChild.value = 'radio option - show grandchild';
Expand Down Expand Up @@ -458,5 +458,34 @@ describe('Service: validateRegistrant', function () {
),
).toBe(false);
});

it('should return valid for hidden questions that are required and not filled out', function () {
answerParent.value = 'radio option - hide child';
answerChild.value = undefined;
answerGrandchild.value = undefined;

expect(
validateRegistrant.blockVisible(
Q2Multiple,
registrant,
false,
testData.conference,
),
).toBe(false);

expect(
validateRegistrant.blockVisible(
Q3Dropdown,
registrant,
false,
testData.conference,
),
).toBe(false);

// should be valid even though child and grandchild is undefined
expect(
validateRegistrant.validate(testData.conference, registrant).length,
).toBe(1);
});
});
});
4 changes: 2 additions & 2 deletions test/spec/testData.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ angular.module('confRegistrationWebApp').service('testData', function () {
title: 'Q2 Multiple Choice Question',
exportFieldTitle: null,
type: 'radioQuestion',
required: false,
required: true,
position: 5,
adminOnly: false,
content: {
Expand Down Expand Up @@ -520,7 +520,7 @@ angular.module('confRegistrationWebApp').service('testData', function () {
title: 'Q3 Dropdown Question',
exportFieldTitle: null,
type: 'selectQuestion',
required: false,
required: true,
position: 6,
adminOnly: false,
content: {
Expand Down
Loading