Skip to content

Commit e01379d

Browse files
authored
Merge pull request #21359 from dannon/vitest-cleanup
Vitest followup: switch to happy-dom, cleanup/fixes to mocks
2 parents 72b8818 + 6827d43 commit e01379d

File tree

24 files changed

+169
-457
lines changed

24 files changed

+169
-457
lines changed

client/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"querystring-es3": "^0.2.1",
100100
"regenerator-runtime": "^0.14.0",
101101
"requirejs": "2.3.7",
102-
"ro-crate-zip-explorer": "^0.4.0",
102+
"ro-crate-zip-explorer": "^0.4.1",
103103
"rxjs": "^7.8.1",
104104
"rxjs-spy": "^8.0.2",
105105
"rxjs-spy-devtools-plugin": "^0.0.4",
@@ -196,10 +196,9 @@
196196
"fork-ts-checker-webpack-plugin": "^9.0.2",
197197
"fs-extra": "^11.2.0",
198198
"gulp": "^5.0.0",
199+
"happy-dom": "^20.0.10",
199200
"ignore-loader": "^0.1.2",
200201
"imports-loader": "^5.0.0",
201-
"jsdom": "^27.2.0",
202-
"jsdom-worker": "^0.3.0",
203202
"json-loader": "^0.5.7",
204203
"mini-css-extract-plugin": "^2.9.2",
205204
"msw": "^2.3.4",

client/src/app/__mocks__/index.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

client/src/components/ActivityBar/ActivitySettings.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe("ActivitySettings", () => {
7878
expect(items.length).toBe(1);
7979
const checkbox = items.at(0).find("[data-title='Hide in Activity Bar']");
8080
expect(checkbox.exists()).toBeTruthy();
81-
const icon = wrapper.find("[icon='activity-test-icon'");
81+
const icon = wrapper.find("[icon='activity-test-icon']");
8282
expect(icon.exists()).toBeTruthy();
8383
expect(activityStore.getAll()[0].visible).toBeTruthy();
8484
checkbox.trigger("click");

client/src/components/Citation/CitationsList.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ import flushPromises from "flush-promises";
66
import { beforeEach, describe, expect, it, vi } from "vitest";
77
import VueRouter from "vue-router";
88

9+
import { setMockConfig } from "@/composables/__mocks__/config";
10+
911
import CitationItem from "./CitationItem.vue";
1012
import MountTarget from "./CitationsList.vue";
1113

1214
const localVue = getLocalVue(true);
1315
localVue.use(VueRouter);
1416

15-
vi.mock("@/composables/config", () => ({
16-
useConfig: vi.fn(() => ({
17-
config: {
18-
value: {
19-
citation_bibtex:
20-
"@article{Galaxy2024, title={The Galaxy platform for accessible, reproducible, and collaborative data analyses: 2024 update}, author={{The Galaxy Community}}, journal={Nucleic Acids Research}, year={2024}, doi={10.1093/nar/gkae410}, url={https://doi.org/10.1093/nar/gkae410}}",
21-
},
22-
},
23-
})),
24-
}));
17+
vi.mock("@/composables/config");
18+
19+
setMockConfig({
20+
citation_bibtex:
21+
"@article{Galaxy2024, title={The Galaxy platform for accessible, reproducible, and collaborative data analyses: 2024 update}, author={{The Galaxy Community}}, journal={Nucleic Acids Research}, year={2024}, doi={10.1093/nar/gkae410}, url={https://doi.org/10.1093/nar/gkae410}}",
22+
});
2523

2624
vi.mock("@/components/Citation/services", () => ({
2725
getCitations: vi.fn(() =>

client/src/components/DatasetInformation/DatasetError.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ const localVue = getLocalVue();
1515

1616
const DATASET_ID = "dataset_id";
1717

18-
vi.mock("@/composables/config", () => ({
19-
useConfig: vi.fn(() => ({
20-
config: {},
21-
isConfigLoaded: true,
22-
})),
23-
}));
18+
vi.mock("@/composables/config");
2419

2520
const { server, http } = useServerMock();
2621

client/src/components/Form/Elements/FormData/FormData.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ describe("FormData", () => {
442442
});
443443
const noCheckLinked = wrapper.find("input[type='checkbox']");
444444
expect(noCheckLinked.exists()).toBeFalsy();
445-
await wrapper.find("[title='Multiple datasets'").trigger("click");
445+
await wrapper.find("[title='Multiple datasets']").trigger("click");
446446
expect(wrapper.emitted()!.input![1]![0]).toEqual(null);
447447
const elements_0 = wrapper.findAll(SELECT_OPTIONS);
448448
expect(elements_0.length).toEqual(6);
@@ -508,7 +508,7 @@ describe("FormData", () => {
508508
const selectedValues = wrapper.findAll(SELECTED_VALUE);
509509
expect(selectedValues.length).toBe(1);
510510
expect(selectedValues.at(0).text()).toBe("5: hdcaName5");
511-
await wrapper.find("[title='Multiple datasets'").trigger("click");
511+
await wrapper.find("[title='Multiple datasets']").trigger("click");
512512
expect(options.at(0).classes()).toContain("active");
513513
expect(wrapper.emitted()!.input![2]![0]).toEqual(null);
514514
});

client/src/components/Form/Elements/FormText.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ describe("FormText", () => {
4747
it("should be able to render border and text color from props", async () => {
4848
const wrapper = await mountFormText({});
4949
const el = wrapper.find("input");
50-
expect(el.element.style).toMatchObject({});
50+
expect(el.element.style.color).toBeFalsy();
5151
await wrapper.setProps({ color: "green" });
52-
expect(el.element.style).toMatchObject({ color: "green", "border-color": "green" });
52+
expect(el.element.style.color).toBe("green");
53+
expect(el.element.style.borderColor).toBe("green");
5354
await wrapper.setProps({ cls: "my-custom-class" });
5455
expect(el.element.classList).toContain("my-custom-class");
5556
});

client/src/components/Markdown/Sections/MarkdownGalaxy.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ describe("MarkdownContainer", () => {
9191
const container = wrapper.find(".collapse");
9292
expect(container.attributes("style")).toBe("display: none;");
9393
await link.trigger("click");
94-
expect(container.attributes("style")).toBe("");
94+
// After click, style attribute is removed
95+
expect(container.attributes("style")).toBeFalsy();
9596
});
9697

9798
it("Renders time stamp", async () => {

client/src/components/Panels/Common/ToolSection.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ import { mount } from "@vue/test-utils";
33
import { createPinia } from "pinia";
44
import { describe, expect, test, vi } from "vitest";
55

6+
import { setMockConfig } from "@/composables/__mocks__/config";
7+
68
import ToolSection from "./ToolSection.vue";
79

8-
vi.mock("@/composables/config", () => ({
9-
useConfig: vi.fn(() => ({
10-
config: {
11-
toolbox_auto_sort: true,
12-
},
13-
isConfigLoaded: true,
14-
})),
15-
}));
10+
vi.mock("@/composables/config");
11+
12+
setMockConfig({
13+
toolbox_auto_sort: true,
14+
});
1615

1716
const localVue = getLocalVue();
1817
const pinia = createPinia();

client/src/components/Panels/ToolBox.test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
44

55
import toolsList from "@/components/ToolsView/testData/toolsList";
66
import toolsListInPanel from "@/components/ToolsView/testData/toolsListInPanel";
7+
import { setMockConfig } from "@/composables/__mocks__/config";
78

89
import { createSortedResultPanel, filterTools } from "./utilities";
910

10-
vi.mock("@/composables/config", () => ({
11-
useConfig: vi.fn(() => ({
12-
config: {
13-
toolbox_auto_sort: true,
14-
},
15-
isConfigLoaded: true,
16-
})),
17-
}));
11+
vi.mock("@/composables/config");
12+
13+
setMockConfig({
14+
toolbox_auto_sort: true,
15+
});
1816

1917
describe("ToolBox", () => {
2018
const toolsMock = toolsList.reduce((acc, item) => {

0 commit comments

Comments
 (0)