UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
Commit 4632e0a1 authored by Michael Winberry's avatar Michael Winberry
Browse files

Update the fortify configuration to retrieve a list of values from the...

Update the fortify configuration to retrieve a list of values from the backend. References platform-one/party-bus/valkyrie/valkyrie-api#2
parent 89d88215
No related branches found
No related tags found
1 merge request!142Introduce Valkyrie MissionApplication creation to Launchboard projects page.
import { createBaseHttp } from "@/api/http-common"; import { createBaseHttp, HTTP } from "@/api/http-common";
export default { export default {
async postMissionApp(missionApp) { async postMissionApp(missionApp) {
return createBaseHttp().post("/mission-app", missionApp); return createBaseHttp().post("/mission-app", missionApp);
}, },
async getFortifyValues() {
return HTTP.get("/mission-app/fortify-values");
},
}; };
...@@ -3,17 +3,25 @@ ...@@ -3,17 +3,25 @@
<h4 class="text-xl-left text-lg-left ml-xl-0 ml-lg-0 pl-lg-0 pl-lg-0 mb-8"> <h4 class="text-xl-left text-lg-left ml-xl-0 ml-lg-0 pl-lg-0 pl-lg-0 mb-8">
Fortify Configuration (Optional) Fortify Configuration (Optional)
</h4> </h4>
<v-select
<v-text-field v-if="!loading"
class="mb-8"
label="Language"
v-model="fortifyConfiguration.language" v-model="fortifyConfiguration.language"
hint="* optional, ie: javascript" :items="fortifyValues"
persistent-hint item-text="name"
item-value="value"
class="mb-8"
label="Select Fortify Language"
outlined
clearable
color="primary"
/> />
<span v-else>"Loading fortify values..."</span>
</div> </div>
</template> </template>
<script> <script>
import { SET_ERROR_DIALOG, SET_ERROR_MESSAGE } from "@/store/mutation-types";
import MissionAppApi from "@/api/services/missionApp";
export default { export default {
name: "MissionAppFortifyConfig", name: "MissionAppFortifyConfig",
props: { props: {
...@@ -22,6 +30,27 @@ export default { ...@@ -22,6 +30,27 @@ export default {
required: true, required: true,
}, },
}, },
created() {
this.retrieveFortifyValues();
},
data: () => ({
loading: true,
fortifyValues: null,
}),
methods: {
async retrieveFortifyValues() {
try {
this.fortifyValues = await MissionAppApi.getFortifyValues();
this.loading = false;
} catch {
this.$store.commit(
SET_ERROR_MESSAGE,
"Failed to retrieve fortify values."
);
this.$store.commit(SET_ERROR_DIALOG, true);
}
},
},
watch: { watch: {
fortifyConfiguration() { fortifyConfiguration() {
this.$emit("input", this.fortifyConfiguration); this.$emit("input", this.fortifyConfiguration);
......
...@@ -34,7 +34,12 @@ ...@@ -34,7 +34,12 @@
> >
<div class="projectInfo mb-8"> <div class="projectInfo mb-8">
<h4 <h4
class="text-xl-left text-lg-left ml-xl-0 ml-lg-0 pl-lg-0 pl-lg-0 mb-8" class="
text-xl-left text-lg-left
ml-xl-0 ml-lg-0
pl-lg-0 pl-lg-0
mb-8
"
> >
Project Info Project Info
</h4> </h4>
......
...@@ -16,7 +16,7 @@ const mockMissionAppBody = { ...@@ -16,7 +16,7 @@ const mockMissionAppBody = {
productionUrl: "product.dso.mil", productionUrl: "product.dso.mil",
}; };
describe("mission app service", () => { describe("mission app service", () => {
describe("should call HTTP", () => { describe("Posting Mission App", () => {
let postFn; let postFn;
beforeEach(() => { beforeEach(() => {
postFn = jest.fn().mockResolvedValue(); postFn = jest.fn().mockResolvedValue();
...@@ -30,4 +30,14 @@ describe("mission app service", () => { ...@@ -30,4 +30,14 @@ describe("mission app service", () => {
expect(postFn).toHaveBeenCalledWith("/mission-app", mockMissionAppBody); expect(postFn).toHaveBeenCalledWith("/mission-app", mockMissionAppBody);
}); });
}); });
describe("Retrieving fortify values", () => {
it("should retrieve the fortify mission values", async () => {
const mockFortifyValues = [{ value: "C++", name: "C++" }];
jest.spyOn(HTTP_HELPERS.HTTP, "get").mockResolvedValue(mockFortifyValues);
expect(await MissionAppService.getFortifyValues()).toBe(
mockFortifyValues
);
});
});
}); });
...@@ -2,6 +2,7 @@ import Vuex from "vuex"; ...@@ -2,6 +2,7 @@ import Vuex from "vuex";
import Vuetify from "vuetify"; import Vuetify from "vuetify";
import { mount, createLocalVue } from "@vue/test-utils"; import { mount, createLocalVue } from "@vue/test-utils";
import MissionAppFortifyConfig from "@/components/MissionAppFortifyConfig"; import MissionAppFortifyConfig from "@/components/MissionAppFortifyConfig";
import MissionAppApi from "@/api/services/missionApp";
const localVue = createLocalVue(); const localVue = createLocalVue();
const vuetify = new Vuetify(); const vuetify = new Vuetify();
...@@ -10,20 +11,45 @@ localVue.use(vuetify); ...@@ -10,20 +11,45 @@ localVue.use(vuetify);
describe("Mission App Dns Form Section", () => { describe("Mission App Dns Form Section", () => {
let wrapper; let wrapper;
let inputs; let mockFortifyValue;
beforeEach(() => { beforeEach(() => {
mockFortifyValue = {
name: "Fortify Lanuage Name",
value: "Fortify Language Value",
};
jest
.spyOn(MissionAppApi, "getFortifyValues")
.mockResolvedValue([mockFortifyValue]);
wrapper = mount(MissionAppFortifyConfig, { wrapper = mount(MissionAppFortifyConfig, {
localVue, localVue,
vuetify, vuetify,
propsData: { propsData: {
fortifyConfiguration: {}, fortifyConfiguration: {},
}, },
mocks: {
$store: {},
},
}); });
inputs = wrapper.findAll("input");
}); });
it("sets the fortify language", () => { it("populates the fortify values on create", () => {
inputs.at(0).setValue("javascript"); expect(MissionAppApi.getFortifyValues).toHaveBeenCalledTimes(1);
expect(wrapper.props().fortifyConfiguration.language).toEqual("javascript"); });
it("Sets the fortifyConfiguration language", () => {
wrapper.find("input").setValue(mockFortifyValue.value);
expect(wrapper.props().fortifyConfiguration.language).toBe(
mockFortifyValue.value
);
});
it("should handle error", async () => {
wrapper.vm.$store.commit = jest.fn();
console.error = jest.fn();
jest
.spyOn(MissionAppApi, "getFortifyValues")
.mockRejectedValue(new Error("Some Error"));
await wrapper.vm.retrieveFortifyValues();
expect(wrapper.vm.$store.commit).toHaveBeenCalled();
}); });
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment