Skip to content

Commit

Permalink
test fix and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Aug 14, 2023
1 parent fbe2b1b commit bf209ca
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 35 deletions.
4 changes: 3 additions & 1 deletion app/static/src/app/components/run/RunTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export default defineComponent({
const canDownloadOutput = computed(() => !updateMsg.value && store.state.run.resultOde?.solution);
const toggleShowDownloadOutput = (show: boolean) => { showDownloadOutput.value = show; };
const download = (payload: {fileName: string, points: number}) => store.dispatch(`run/${RunAction.DownloadOutput}`, payload);
const download = (payload: {fileName: string, points: number}) => store.dispatch(
`run/${RunAction.DownloadOutput}`, payload
);
return {
canRunModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@

<script lang="ts">
import {computed, defineComponent, onMounted, onUnmounted, ref, watch} from "vue";
import {AxisType, newPlot, Plots} from "plotly.js-basic-dist-min";
import {useStore} from "vuex";
import {config, fadePlotStyle, filterSeriesSet, margin, odinToPlotly, updatePlotTraceName} from "../../plot";
import {SensitivityPlotExtremePrefix, SensitivityPlotType, SensitivityScaleType} from "../../store/sensitivity/state";
import {SensitivityMutation} from "../../store/sensitivity/mutations";
import {Batch, OdinSeriesSet} from "../../types/responseTypes";
import {runPlaceholderMessage} from "../../utils";
import {RunGetter} from "../../store/run/getters";
import {Dict} from "../../types/utilTypes";
import {
computed, defineComponent, onMounted, onUnmounted, ref, watch
} from "vue";
import { AxisType, newPlot, Plots } from "plotly.js-basic-dist-min";
import { useStore } from "vuex";
import {
config, fadePlotStyle, filterSeriesSet, margin, odinToPlotly, updatePlotTraceName
} from "../../plot";
import { SensitivityPlotExtremePrefix, SensitivityPlotType, SensitivityScaleType } from "../../store/sensitivity/state";
import { SensitivityMutation } from "../../store/sensitivity/mutations";
import { Batch, OdinSeriesSet } from "../../types/responseTypes";
import { runPlaceholderMessage } from "../../utils";
import { RunGetter } from "../../store/run/getters";
import { Dict } from "../../types/utilTypes";
import WodinPlotDataSummary from "../WodinPlotDataSummary.vue";
import {verifyValidPlotSettingsTime} from "./support";
import { verifyValidPlotSettingsTime } from "./support";
export default defineComponent({
name: "SensitivitySummaryPlot",
Expand Down Expand Up @@ -113,10 +117,10 @@ export default defineComponent({
});
result.push(...psPlotData);
});
store.commit(`sensitivity/${SensitivityMutation.SetLoading}`, false);
store.commit(`${namespace}/${SensitivityMutation.SetLoading}`, false);
return result;
}
store.commit(`sensitivity/${SensitivityMutation.SetLoading}`, false);
store.commit(`${namespace}/${SensitivityMutation.SetLoading}`, false);
return [];
});
const hasPlotData = computed(() => !!(plotData.value?.length));
Expand Down
6 changes: 3 additions & 3 deletions app/static/src/app/components/sensitivity/support.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Commit } from "vuex";
import { SensitivityUpdateRequiredReasons } from "../../store/sensitivity/state";
import userMessages from "../../userMessages";
import { appendIf, joinStringsSentence } from "../../utils";
import {SensitivityMutation} from "../../store/sensitivity/mutations";
import {AppState} from "../../store/appState/state";
import {Commit} from "vuex";
import { SensitivityMutation } from "../../store/sensitivity/mutations";
import { AppState } from "../../store/appState/state";

export const sensitivityUpdateRequiredExplanation = (reasons: SensitivityUpdateRequiredReasons): string => {
const explanation: string[] = [];
Expand Down
3 changes: 2 additions & 1 deletion app/static/src/app/excel/wodinModelOutputDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export class WodinModelOutputDownload extends WodinExcelDownload {
const { selectedVariables } = this._state.model;

const worksheet = WodinModelOutputDownload._generateModelledOutput(
selectedVariables, solutionOutput, [], null);
selectedVariables, solutionOutput, [], null
);
XLSX.utils.book_append_sheet(this._workbook, worksheet, "Modelled");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ export class WodinSensitivitySummaryDownload extends WodinExcelDownload {
this._addParameters([varyingParameter]);
});
};
}
}
4 changes: 3 additions & 1 deletion app/static/tests/unit/components/run/runTab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jest.mock("plotly.js-basic-dist-min", () => {});
/* eslint-disable import/first */
import Vuex from "vuex";
import { shallowMount } from "@vue/test-utils";
import { nextTick } from "vue";
import { BasicState } from "../../../../src/app/store/basic/state";
import {
mockBasicState, mockModelState, mockRunState, mockStochasticState
Expand Down Expand Up @@ -119,7 +120,7 @@ describe("RunTab", () => {
};

it("renders as expected when can run model", () => {
const runState = {...defaultRunState, userDownloadFileName: "test.xlsx" }
const runState = { ...defaultRunState, userDownloadFileName: "test.xlsx" };
const wrapper = getWrapper(defaultModelState, runState);
expect(wrapper.find("button#run-btn").text()).toBe("Run model");
expect((wrapper.find("button#run-btn").element as HTMLButtonElement).disabled).toBe(false);
Expand Down Expand Up @@ -255,6 +256,7 @@ describe("RunTab", () => {
const download = wrapper.findComponent(DownloadOutput);
expect(download.props().open).toBe(true);
download.vm.$emit("close");
await nextTick();
expect(download.props().open).toBe(false);
});

Expand Down
24 changes: 12 additions & 12 deletions app/static/tests/unit/components/sensitivity/sensitivityTab.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {mount} from "@vue/test-utils";
import { mount } from "@vue/test-utils";
import Vuex from "vuex";
import {ModelState} from "../../../../src/app/store/model/state";
import { nextTick } from "vue";
import { ModelState } from "../../../../src/app/store/model/state";
import SensitivityTab from "../../../../src/app/components/sensitivity/SensitivityTab.vue";
import ActionRequiredMessage from "../../../../src/app/components/ActionRequiredMessage.vue";
import {SensitivityGetter} from "../../../../src/app/store/sensitivity/getters";
import { SensitivityGetter } from "../../../../src/app/store/sensitivity/getters";
import SensitivityTracesPlot from "../../../../src/app/components/sensitivity/SensitivityTracesPlot.vue";
import {SensitivityPlotType, SensitivityState} from "../../../../src/app/store/sensitivity/state";
import {SensitivityAction} from "../../../../src/app/store/sensitivity/actions";
import { SensitivityPlotType, SensitivityState } from "../../../../src/app/store/sensitivity/state";
import { SensitivityAction } from "../../../../src/app/store/sensitivity/actions";
import SensitivitySummaryPlot from "../../../../src/app/components/sensitivity/SensitivitySummaryPlot.vue";
import ErrorInfo from "../../../../src/app/components/ErrorInfo.vue";
import {AppState, AppType} from "../../../../src/app/store/appState/state";
import {ModelGetter} from "../../../../src/app/store/model/getters";
import { AppState, AppType } from "../../../../src/app/store/appState/state";
import { ModelGetter } from "../../../../src/app/store/model/getters";
import LoadingSpinner from "../../../../src/app/components/LoadingSpinner.vue";
import {SensitivityMutation} from "../../../../src/app/store/sensitivity/mutations";
import { SensitivityMutation } from "../../../../src/app/store/sensitivity/mutations";
import DownloadOutput from "../../../../src/app/components/DownloadOutput.vue";
import {nextTick} from "vue";

jest.mock("plotly.js-basic-dist-min", () => {});

Expand Down Expand Up @@ -169,7 +169,7 @@ describe("SensitivityTab", () => {
const enabledResult = {
inputs: {},
batch: {
solutions: [ "test solution" ] as any,
solutions: ["test solution"] as any,
errors: []
},
error: null
Expand All @@ -187,13 +187,13 @@ describe("SensitivityTab", () => {
// disabled if update required
expectDownloadButtonEnabled({
...enabledState,
sensitivityUpdateRequired: { modelChanged: true}
sensitivityUpdateRequired: { modelChanged: true }
}, false);

// disabled if no batch result
expectDownloadButtonEnabled({
...enabledState,
result: {...enabledResult, batch: null}
result: { ...enabledResult, batch: null }
}, false);
});

Expand Down
4 changes: 2 additions & 2 deletions app/static/tests/unit/components/sensitivity/support.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
sensitivityUpdateRequiredExplanation,
verifyValidPlotSettingsTime
} from "../../../../src/app/components/sensitivity/support";
import {mockBasicState, mockRunState, mockSensitivityState} from "../../../mocks";
import {SensitivityMutation} from "../../../../src/app/store/sensitivity/mutations";
import { mockBasicState, mockRunState, mockSensitivityState } from "../../../mocks";
import { SensitivityMutation } from "../../../../src/app/store/sensitivity/mutations";

describe("construct actionable fit update messages from fit state changes", () => {
const base = {
Expand Down
2 changes: 1 addition & 1 deletion app/static/tests/unit/excel/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jest.mock("xlsx", () => ({
book_new: () => mockBookNew(),
book_append_sheet: (wb: any, ws: any, name: string) => mockBookAppendSheet(wb, ws, name)
}
}));
}));
2 changes: 2 additions & 0 deletions app/static/tests/unit/serialiser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ describe("serialise", () => {
const sensitivityState = {
running: true,
loading: false,
downloading: false,
userSummaryDownloadFileName: "",
paramSettings: {
parameterToVary: "alpha",
scaleType: SensitivityScaleType.Arithmetic,
Expand Down

0 comments on commit bf209ca

Please sign in to comment.