Skip to content

Commit

Permalink
Merge pull request #4038 from manavagr1108/disable-continue-button-on…
Browse files Browse the repository at this point in the history
…-unchecked-terms

Disable checkbox based on policyAccepted
  • Loading branch information
akolson authored Apr 25, 2023
2 parents 6dfeae9 + 8b88e7c commit 6a90478
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@
data-test="accept-checkbox"
@change="togglePolicyAccepted"
/>
<div class="red--text" :style="{ height: '14pt' }">
<span v-if="showError">{{ $tr('checkboxValidationErrorMessage') }}</span>
</div>
</KGridItem>
<KGridItem :layout="{ span: 1 }">
<KButton
:text="$tr('continueButton')"
:primary="true"
:style="{ 'display': 'block', 'margin-left': 'auto' }"
:disabled="!policyAccepted"
data-test="continue-button"
@click="onPolicyAccept"
/>
Expand Down Expand Up @@ -87,7 +85,6 @@
data() {
return {
policyAccepted: false,
showError: false,
};
},
computed: {
Expand All @@ -104,7 +101,6 @@
this.$emit('close');
},
validate() {
this.showError = !this.policyAccepted;
return this.policyAccepted;
},
onPolicyAccept() {
Expand All @@ -117,7 +113,6 @@
lastUpdated: 'Last updated {date}',
closeButton: 'Close',
continueButton: 'Continue',
checkboxValidationErrorMessage: 'Field is required',
checkboxText: 'I have agreed to the above terms',
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,10 @@ describe('PoliciesModal', () => {
});

describe('when accept policy checkbox is not checked', () => {
it('clicking continue button should display validation error', () => {
wrapper.find('[data-test="continue-button"]').trigger('click');

expect(wrapper.text()).toContain('Field is required');
});

it("clicking continue button shouldn't emit accept event", () => {
wrapper.find('[data-test="continue-button"]').trigger('click');

expect(wrapper.emitted().accept).toBeFalsy();
it('disable continue button', () => {
expect(wrapper.find('[data-test="continue-button"]').attributes().disabled).toEqual(
'disabled'
);
});
});

Expand Down

0 comments on commit 6a90478

Please sign in to comment.