Skip to content
Open
Show file tree
Hide file tree
Changes from all 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/static/src/components/WodinPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export default defineComponent({
legendConfigs,
handleClick,
placeholderMessage,
autoscaledMaxExtentsY
};
}
});
Expand Down
14 changes: 3 additions & 11 deletions app/static/tests/unit/components/basic/basicApp.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// Mock the import of third party packages to prevent errors
vi.mock("plotly.js-basic-dist-min", () => {
return {
default: undefined,
update: undefined
}
});
vi.mock("../../../../src/components/help/MarkdownItImport.ts", () => {
class MarkDownItClass {
constructor() {
Expand Down Expand Up @@ -38,7 +31,6 @@ import { ModelAction } from "../../../../src/store/model/actions";
import { VisualisationTab } from "../../../../src/store/appState/state";
import { AppStateMutation } from "../../../../src/store/appState/mutations";
import { AppConfig } from "../../../../src/types/responseTypes";
import { getters as graphsGetters } from "../../../../src/store/graphs/getters";

const mockTooltipDirective = vi.fn();

Expand Down Expand Up @@ -78,7 +70,6 @@ describe("BasicApp", () => {
graphs: {
namespaced: true,
state: mockGraphsState(),
getters: graphsGetters
}
}
});
Expand Down Expand Up @@ -135,8 +126,9 @@ describe("BasicApp", () => {
const wrapper = getWrapper(mockSetOpenTab);
const rightTabs = wrapper.findComponent("#right-tabs");
await rightTabs.findAll("li a").at(1)!.trigger("click"); // Click Sensitivity Tab
expect(mockSetOpenTab).toHaveBeenCalledTimes(1);
expect(mockSetOpenTab.mock.calls[0][1]).toBe(VisualisationTab.Sensitivity);
// sets it once on mounted and once for this test
expect(mockSetOpenTab).toHaveBeenCalledTimes(2);
expect(mockSetOpenTab.mock.calls[1][1]).toBe(VisualisationTab.Sensitivity);
});

it("renders help tab", () => {
Expand Down
14 changes: 3 additions & 11 deletions app/static/tests/unit/components/fit/fitApp.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// Mock the import of third party packages to prevent errors
vi.mock("plotly.js-basic-dist-min", () => {
return {
default: undefined,
update: undefined
}
});
vi.mock("../../../../src/components/help/MarkdownItImport.ts", () => {
class MarkDownItClass {
constructor() {
Expand Down Expand Up @@ -49,7 +42,6 @@ import { VisualisationTab } from "../../../../src/store/appState/state";
import { AppStateMutation } from "../../../../src/store/appState/mutations";
import { ModelFitGetter } from "../../../../src/store/modelFit/getters";
import { AppConfig } from "../../../../src/types/responseTypes";
import { getters as graphsGetters } from "../../../../src/store/graphs/getters";

function mockResizeObserver(this: any) {
this.observe = vi.fn();
Expand Down Expand Up @@ -99,7 +91,6 @@ describe("FitApp", () => {
graphs: {
namespaced: true,
state: mockGraphsState(),
getters: graphsGetters
}
}
});
Expand Down Expand Up @@ -172,8 +163,9 @@ describe("FitApp", () => {
const rightTabs = wrapper.find("#right-tabs");

await rightTabs.findAll("li a").at(1)!.trigger("click"); // Click Fit tab
expect(mockSetOpenTab).toHaveBeenCalledTimes(1);
expect(mockSetOpenTab.mock.calls[0][1]).toBe(VisualisationTab.Fit);
// always sets it once on mount
expect(mockSetOpenTab).toHaveBeenCalledTimes(2);
expect(mockSetOpenTab.mock.calls[1][1]).toBe(VisualisationTab.Fit);
});

it("renders help tab", () => {
Expand Down
15 changes: 4 additions & 11 deletions app/static/tests/unit/components/mixins/baseSensitivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { noSensitivityUpdateRequired } from "../../../../src/store/sensitivity/s
import { AppState } from "../../../../src/store/appState/state";
import { BaseSensitivityMutation } from "../../../../src/store/sensitivity/mutations";
import { BaseSensitivityAction } from "../../../../src/store/sensitivity/actions";
import { getters as graphGetters } from "../../../../src/store/graphs/getters";
import { mockGraphsState } from "../../../mocks";
import { defaultGraphSettings } from "../../../../src/store/graphs/state";
import { defaultGraphConfig } from "@/store/graphs/state";

describe("baseSensitivity mixin", () => {
const mockSensSetUserSummaryDownloadFileName = vi.fn();
Expand All @@ -24,22 +23,16 @@ describe("baseSensitivity mixin", () => {
multiSensitivityState: Partial<BaseSensitivityState> = {},
selectedVariables: string[] = ["A"]
) => {
const config = defaultGraphConfig("123");
config.selectedVariables = selectedVariables;
return new Vuex.Store<AppState>({
state: {} as any,
modules: {
graphs: {
namespaced: true,
state: mockGraphsState({
config: [
{
id: "123",
selectedVariables,
unselectedVariables: [],
settings: defaultGraphSettings()
}
]
configs: [config]
}),
getters: graphGetters
},
model: {
namespaced: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import ActionRequiredMessage from "../../../../src/components/ActionRequiredMess
import { MultiSensitivityState } from "../../../../src/store/multiSensitivity/state";
import ErrorInfo from "../../../../src/components/ErrorInfo.vue";
import SensitivitySummaryDownload from "../../../../src/components/sensitivity/SensitivitySummaryDownload.vue";
import { getters as graphsGetters } from "../../../../src/store/graphs/getters";

describe("MultiSensitivityTab", () => {
const mockRunMultiSensitivity = vi.fn();
Expand All @@ -26,13 +25,8 @@ describe("MultiSensitivityTab", () => {
graphs: {
namespaced: true,
state: {
config: [
{
selectedVariables: ["A"]
}
]
configs: [{ selectedVariables: ["A"] }]
},
getters: graphsGetters
},
model: {
namespaced: true,
Expand Down
27 changes: 11 additions & 16 deletions app/static/tests/unit/components/options/linkData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { FitState } from "../../../../src/store/fit/state";
import { getters } from "../../../../src/store/fitData/getters";
import { mockFitDataState, mockFitState, mockGraphsState, mockModelState } from "../../../mocks";
import { FitDataAction } from "../../../../src/store/fitData/actions";
import { getters as graphGetters } from "../../../../src/store/graphs/getters";
import { defaultGraphSettings } from "../../../../src/store/graphs/state";
import { defaultGraphConfig } from "@/store/graphs/state";

describe("LinkData", () => {
const getWrapper = (includeColumns = true, includeValidModel = true, mockUpdateLinkedVariable = vi.fn()) => {
const config = defaultGraphConfig("123");
config.selectedVariables = ["I", "R"];
const store = new Vuex.Store<FitState>({
state: mockFitState(),
modules: {
Expand All @@ -34,16 +35,8 @@ describe("LinkData", () => {
graphs: {
namespaced: true,
state: mockGraphsState({
config: [
{
id: "123",
selectedVariables: ["I", "R"],
unselectedVariables: [],
settings: defaultGraphSettings()
}
]
configs: [config]
}),
getters: graphGetters
},
model: {
namespaced: true,
Expand All @@ -67,13 +60,15 @@ describe("LinkData", () => {

const checkExpectedSelectOptions = (select: HTMLSelectElement) => {
const { options } = select;
expect(options.length).toBe(3);
expect(options.length).toBe(4);
expect(options[0].text).toBe("-- no link --");
expect(options[0].value).toBe("");
expect(options[1].text).toBe("I");
expect(options[1].value).toBe("I");
expect(options[2].text).toBe("R");
expect(options[2].value).toBe("R");
expect(options[1].text).toBe("S");
expect(options[1].value).toBe("S");
expect(options[2].text).toBe("I");
expect(options[2].value).toBe("I");
expect(options[3].text).toBe("R");
expect(options[3].value).toBe("R");
};

const checkCannotLink = (wrapper: VueWrapper<any>, expectedMessage: string) => {
Expand Down
24 changes: 5 additions & 19 deletions app/static/tests/unit/components/options/optionsTab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import SensitivityOptions from "../../../../src/components/options/SensitivityOp
import OptimisationOptions from "../../../../src/components/options/OptimisationOptions.vue";
import { mockModelState, mockRunState } from "../../../mocks";
import { RunMutation } from "../../../../src/store/run/mutations";
import GraphSettings from "../../../../src/components/GraphSettings.vue";
import ParameterSets from "../../../../src/components/options/ParameterSets.vue";
import { getters as runGetters } from "../../../../src/store/run/getters";
import AdvancedSettings from "../../../../src/components/options/AdvancedSettings.vue";
import GraphConfigsCollapsible from "../../../../src/components/graphConfig/GraphConfigsCollapsible.vue";
import { fitGraphId } from "@/store/graphs/state";
import { nextTick } from "vue";
import ConfigGroup from "@/components/graphConfig/ConfigGroup.vue";

describe("OptionsTab", () => {
const mockTooltipDirective = vi.fn();
Expand Down Expand Up @@ -131,7 +131,8 @@ describe("OptionsTab", () => {
}
}
});
const wrapper = await getWrapper(store);
const wrapper = getWrapper(store);
await nextTick();

expect(wrapper.find("#reset-params-btn").exists()).toBe(true);
const parameters = wrapper.findComponent(ParameterValues);
Expand All @@ -154,16 +155,6 @@ describe("OptionsTab", () => {
fitData: {
columnToFit: null
},
graphs: {
fitGraphConfig: {
id: fitGraphId,
selectVariables: [],
unselectedVariables: [],
settings: {
logScaleYAxis: false
}
}
}
} as any,
modules: {
run: {
Expand Down Expand Up @@ -216,11 +207,6 @@ describe("OptionsTab", () => {
run: mockRunState({
parameterValues: { param1: 1, param2: 2.2 }
}),
graphs: {
settings: {
logScaleYAxis: false
}
}
} as any
});
const wrapper = getWrapper(store);
Expand Down Expand Up @@ -309,6 +295,6 @@ describe("OptionsTab", () => {
}
});
expect(wrapper.findComponent(SensitivityOptions).exists()).toBe(true);
expect(wrapper.findComponent(GraphSettings).exists()).toBe(false);
expect(wrapper.findComponent(ConfigGroup).exists()).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import { BaseSensitivityAction } from "../../../../src/store/sensitivity/actions
import { BaseSensitivityMutation, SensitivityMutation } from "../../../../src/store/sensitivity/mutations";
import LoadingSpinner from "../../../../src/components/LoadingSpinner.vue";
import { ModelGetter } from "../../../../src/store/model/getters";
import { getters as graphsGetters } from "../../../../src/store/graphs/getters";
import { mockGraphsState } from "../../../mocks";
import { defaultGraphSettings } from "../../../../src/store/graphs/state";
import { defaultGraphConfig } from "@/store/graphs/state";

describe("SensitivitySummaryDownload", () => {
const mockSetUserSummaryDownloadFileName = vi.fn();
Expand Down Expand Up @@ -61,6 +60,9 @@ describe("SensitivitySummaryDownload", () => {
}
} as any;

const config = defaultGraphConfig("123");
config.selectedVariables = ["S"];

const store = new Vuex.Store<AppState>({
modules: {
model: {
Expand All @@ -85,16 +87,8 @@ describe("SensitivitySummaryDownload", () => {
graphs: {
namespaced: true,
state: mockGraphsState({
config: [
{
id: "123",
selectedVariables: ["S"],
unselectedVariables: [],
settings: defaultGraphSettings()
}
]
configs: [config]
}),
getters: graphsGetters
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { ModelAction } from "../../../../src/store/model/actions";
import { AppStateMutation } from "../../../../src/store/appState/mutations";
import { VisualisationTab } from "../../../../src/store/appState/state";
import { AppConfig } from "../../../../src/types/responseTypes";
import { getters as graphsGetters } from "../../../../src/store/graphs/getters";

const mockSetOpenVisualisationTab = vi.fn();
const mockTooltipDirective = vi.fn();
Expand Down Expand Up @@ -68,7 +67,6 @@ describe("StochasticApp", () => {
graphs: {
namespaced: true,
state: mockGraphsState(),
getters: graphsGetters
}
}
});
Expand Down Expand Up @@ -126,8 +124,9 @@ describe("StochasticApp", () => {
const wrapper = getWrapper();
const rightTabs = wrapper.findComponent("#right-tabs");
await rightTabs.findAll("li a").at(1)!.trigger("click"); // Click Sensitivity Tab
expect(mockSetOpenVisualisationTab).toHaveBeenCalledTimes(1);
expect(mockSetOpenVisualisationTab.mock.calls[0][1]).toBe(VisualisationTab.Sensitivity);
// always sets it once on mount
expect(mockSetOpenVisualisationTab).toHaveBeenCalledTimes(2);
expect(mockSetOpenVisualisationTab.mock.calls[1][1]).toBe(VisualisationTab.Sensitivity);
});

it("renders help tab", () => {
Expand Down
Loading
Loading