Skip to content

Commit 988f004

Browse files
committed
Fix test infrastructure issues for Vue 3 / VTU v2
- Add missing vi import in PersistentTaskProgressMonitorAlert test - Remove duplicate jest helper imports (now using vitest helpers) - Update VueRouter usage to v4 pattern with createTestRouter() - Change wrapper.destroy() to wrapper.unmount() (VTU v2 API) - Change propsData to props in mount options (VTU v2 API)
1 parent 9aba3be commit 988f004

11 files changed

Lines changed: 13 additions & 18 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import { createTestingPinia } from "@pinia/testing";
2-
import { getLocalVue } from "@tests/vitest/helpers";
2+
import { createTestRouter, getLocalVue } from "@tests/vitest/helpers";
33
import { setupMockHistoryBreadcrumbs } from "@tests/vitest/mockHistoryBreadcrumbs";
44
import { mount, type Wrapper } from "@vue/test-utils";
55
import flushPromises from "flush-promises";
66
import { beforeEach, describe, expect, it, vi } from "vitest";
7-
import VueRouter from "vue-router";
87

98
import { setMockConfig } from "@/composables/__mocks__/config";
109

1110
import CitationItem from "./CitationItem.vue";
1211
import MountTarget from "./CitationsList.vue";
1312

1413
const localVue = getLocalVue(true);
15-
localVue.use(VueRouter);
1614

1715
vi.mock("@/composables/config");
1816

@@ -45,7 +43,7 @@ describe("CitationsList", () => {
4543
beforeEach(async () => {
4644
const pinia = createTestingPinia({ createSpy: vi.fn });
4745

48-
const router = new VueRouter();
46+
const router = createTestRouter();
4947
router.push("/histories/citations?id=test-id");
5048

5149
wrapper = mount(MountTarget as object, {

client/src/components/Common/PersistentTaskProgressMonitorAlert.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { shallowMount } from "@vue/test-utils";
2+
import { vi } from "vitest";
23
import { ref } from "vue";
34

45
import type { TaskMonitor } from "@/composables/genericTaskMonitor";

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import "@/composables/__mocks__/filter";
44
import { createTestingPinia } from "@pinia/testing";
55
import { dispatchEvent, getLocalVue } from "@tests/vitest/helpers";
66
import { mount } from "@vue/test-utils";
7-
import { dispatchEvent, getLocalVue } from "tests/jest/helpers";
87

98
import { testDatatypesMapper } from "@/components/Datatypes/test_fixtures";
109
import { useDatatypesMapperStore } from "@/stores/datatypesMapperStore";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe("DirectoryPathEditableBreadcrumb", () => {
9393
});
9494
afterEach(async () => {
9595
if (wrapper) {
96-
wrapper.destroy();
96+
wrapper.unmount();
9797
}
9898
wrapper = undefined;
9999
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe("FormInput", () => {
3131

3232
const inputRange = await getInputRange(wrapper);
3333
expect(inputRange.exists()).toBe(shoudExist);
34-
wrapper.destroy();
34+
wrapper.unmount();
3535
};
3636

3737
const props = { value: 50, type: "float" };
@@ -59,7 +59,7 @@ describe("FormInput", () => {
5959
const alert = await getAlert(wrapper);
6060
expect(alert.exists()).toBeTruthy();
6161
expect(alert.text().includes(`${number} is out`)).toBeTruthy();
62-
wrapper.destroy();
62+
wrapper.unmount();
6363
};
6464

6565
const numberBiggerThanRange = [110, Number.MAX_VALUE];
@@ -87,7 +87,7 @@ describe("FormInput", () => {
8787

8888
const alert = await getAlert(wrapper);
8989
expect(alert.exists()).toBeTruthy();
90-
wrapper.destroy();
90+
wrapper.unmount();
9191
};
9292

9393
const props = { value: 50, type: "integer", min: 10, max: 100 };

client/src/components/History/CurrentHistory/HistoryNavigation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async function createWrapper(props: object, userData?: Partial<RegisteredUser>)
1414
const pinia = createPinia();
1515

1616
const wrapper = shallowMount(HistoryNavigation as object, {
17-
propsData,
17+
props,
1818
global: localVue,
1919
pinia,
2020
});

client/src/components/Libraries/LibraryFolder/FolderDetails/FolderDetails.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("Libraries/LibraryFolder/FolderDetails/FolderDetails.vue", () => {
4949
});
5050

5151
afterEach(async () => {
52-
wrapper.destroy();
52+
wrapper.unmount();
5353
});
5454

5555
it("Should display details button", async () => {

client/src/components/ObjectStore/ObjectStoreBadge.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getLocalVue } from "@tests/vitest/helpers";
22
import { mount, type Wrapper } from "@vue/test-utils";
3-
import { getLocalVue } from "tests/jest/helpers";
43

54
import type { ObjectStoreBadgeType } from "@/api/objectStores.templates";
65
import { MESSAGES } from "@/components/ObjectStore/badgeMessages";

client/src/components/Popper/usePopper.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe("usePopper", () => {
6161
test("should destroy Popper instance on unmount", () => {
6262
const wrapper = createTestComponent();
6363
const popperInstance = createPopper.mock.results[0].value;
64-
wrapper.destroy();
64+
wrapper.unmount();
6565
expect(popperInstance.destroy).toHaveBeenCalled();
6666
});
6767

client/src/components/Tool/Buttons/ToolTourGeneratorItem.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe("Tool Generated Tour Dropdown Item", () => {
100100
});
101101

102102
afterEach(() => {
103-
wrapper.destroy();
103+
wrapper.unmount();
104104
server.resetHandlers();
105105
currentItemState.value = null;
106106
setTourMock.mockClear();

0 commit comments

Comments
 (0)