UNCLASSIFIED

Commit 72508796 authored by Michael Winberry's avatar Michael Winberry
Browse files

Update missionappdns fields to only be required if one or more fields is filled out.

parent e624c051
......@@ -7,29 +7,26 @@
class="mb-8"
label="Dns Credential Name"
v-model="dns.credentialName"
hint="* Required"
:hint="hint"
persistent-hint
required
:rules="[inputRules.required]"
:required="isRequired"
/>
<v-text-field
class="mb-8"
label="App Host Name"
v-model="dns.appHostname"
hint="* Required"
:hint="hint"
persistent-hint
required
:rules="[inputRules.required]"
:required="isRequired"
/>
<v-select
class="stagingSelect"
v-model="dns.targetEnvironment"
:items="environments"
label="Target Environment"
hint="* Required"
:hint="hint"
persistent-hint
required
:rules="[inputRules.required]"
:required="isRequired"
solo
/>
</div>
......@@ -48,6 +45,18 @@ export default {
inputRules,
environments: ["IL2", "IL4", "IL5"],
}),
computed: {
isRequired() {
return (
this.dns.credentialName ||
this.dns.appHostname ||
this.dns.targetEnvironment
);
},
hint() {
return this.isRequired ? "* Required" : "";
},
},
watch: {
dns() {
this.$emit("input", this.dns);
......
......@@ -42,4 +42,20 @@ describe("Mission App Dns Form Section", () => {
wrapper.vm.environments[0]
);
});
describe("Required behavior | all or none", () => {
it("sets required to true if any of the fields are defined", () => {
inputs.at(0).setValue("dns-credentials");
expect(wrapper.vm.isRequired).toBeTruthy();
});
it("sets the hint to required if any of the fields are defined", () => {
inputs.at(0).setValue("dns-credentials");
expect(wrapper.vm.hint).toBe("* Required");
});
it("Does not return a hint if none of the fields are defined", () => {
expect(wrapper.vm.hint).toBe("");
});
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment