Skip to content

Commit 98ec6ef

Browse files
committed
Fix router-related test failures
Add router to test mounts for Vue 3/VTU v2 compatibility.
1 parent dc41775 commit 98ec6ef

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

client/src/components/History/Export/HistoryExportWizard.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createTestingPinia } from "@pinia/testing";
2-
import { getLocalVue } from "@tests/jest/helpers";
2+
import { getLocalVue, injectTestRouter } from "@tests/jest/helpers";
33
import { mount } from "@vue/test-utils";
44
import flushPromises from "flush-promises";
55
import { setActivePinia } from "pinia";
@@ -10,6 +10,7 @@ import type { BrowsableFilesSourcePlugin } from "@/api/remoteFiles";
1010
import HistoryExportWizard from "./HistoryExportWizard.vue";
1111

1212
const localVue = getLocalVue(true);
13+
const router = injectTestRouter();
1314

1415
const FAKE_HISTORY_ID = "fake-history-id";
1516
const FAKE_HISTORY_NAME = "Test History";
@@ -99,7 +100,7 @@ async function mountHistoryExportWizard(options: MountOptions = {}) {
99100
},
100101
global: {
101102
...localVue.global,
102-
plugins: [...localVue.global.plugins, pinia],
103+
plugins: [...localVue.global.plugins, pinia, router],
103104
},
104105
});
105106

client/src/components/Login/LoginForm.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createTestingPinia } from "@pinia/testing";
2-
import { getLocalVue } from "@tests/jest/helpers";
2+
import { getLocalVue, injectTestRouter } from "@tests/jest/helpers";
33
import { mount } from "@vue/test-utils";
44
import axios from "axios";
55
import MockAdapter from "axios-mock-adapter";
@@ -12,6 +12,7 @@ import { HttpResponse } from "@/api/client/__mocks__/index";
1212
import MountTarget from "./LoginForm.vue";
1313

1414
const globalConfig = getLocalVue(true);
15+
const router = injectTestRouter();
1516

1617
const { server, http } = useServerMock();
1718

@@ -30,7 +31,7 @@ async function mountLoginForm() {
3031
},
3132
global: {
3233
...globalConfig.global,
33-
plugins: [...globalConfig.global.plugins, testingPinia],
34+
plugins: [...globalConfig.global.plugins, testingPinia, router],
3435
stubs: {
3536
ExternalLogin: true,
3637
},

client/src/components/Login/LoginIndex.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { mount } from "@vue/test-utils";
2-
import { getLocalVue } from "tests/jest/helpers";
2+
import { getLocalVue, injectTestRouter } from "tests/jest/helpers";
33

44
import MountTarget from "./LoginIndex.vue";
55

66
const globalConfig = getLocalVue(true);
7+
const router = injectTestRouter();
78

89
const SELECTORS = {
910
REGISTER_TOGGLE: "[id=register-toggle]",
@@ -19,7 +20,10 @@ describe("LoginIndex", () => {
1920
allowUserCreation: false,
2021
sessionCsrfToken: "sessionCsrfToken",
2122
},
22-
global: globalConfig.global,
23+
global: {
24+
...globalConfig.global,
25+
plugins: [...globalConfig.global.plugins, router],
26+
},
2327
});
2428
});
2529

client/src/components/Register/RegisterForm.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { createTestingPinia } from "@pinia/testing";
2-
import { getLocalVue } from "@tests/jest/helpers";
2+
import { getLocalVue, injectTestRouter } from "@tests/jest/helpers";
33
import { mount, type VueWrapper } from "@vue/test-utils";
44
import axios from "axios";
55
import MockAdapter from "axios-mock-adapter";
66

77
import MountTarget from "./RegisterForm.vue";
88

99
const localVue = getLocalVue(true);
10+
const router = injectTestRouter();
1011

1112
// const SELECTORS = {
1213
// LOGIN_TOGGLE: "[id=login-toggle]",
@@ -27,7 +28,7 @@ describe("RegisterForm", () => {
2728
},
2829
global: {
2930
...localVue.global,
30-
plugins: [...localVue.global.plugins, pinia],
31+
plugins: [...localVue.global.plugins, pinia, router],
3132
},
3233
});
3334
});

client/src/components/Tool/ToolSuccessMessage.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { mount, type VueWrapper } from "@vue/test-utils";
2-
import { getLocalVue } from "tests/jest/helpers";
2+
import { getLocalVue, injectTestRouter } from "tests/jest/helpers";
33

44
import jobInformationResponse from "@/components/JobInformation/testData/jobInformationResponse.json";
55

@@ -32,6 +32,7 @@ const SELECTORS = {
3232
};
3333

3434
const globalConfig = getLocalVue();
35+
const router = injectTestRouter();
3536

3637
describe("ToolSuccessMessage", () => {
3738
let wrapper: VueWrapper<any>;
@@ -44,6 +45,7 @@ describe("ToolSuccessMessage", () => {
4445
},
4546
global: {
4647
...globalConfig.global,
48+
plugins: [...globalConfig.global.plugins, router],
4749
stubs: {
4850
FontAwesomeIcon: true,
4951
},

0 commit comments

Comments
 (0)