Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Jest Test Output (part 2) #19178

Merged
merged 23 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2887f39
Fix console.error in upload-queue.test.js.
jmchilton Nov 19, 2024
1f81714
Drop console errors and warnings around NodeOutput.test.ts.
jmchilton Nov 19, 2024
66b821a
Suppress known console.debug in Index.test.ts.
jmchilton Nov 19, 2024
913c04f
Fix extraneous output in Workflow/Editor/Index.test.ts.
jmchilton Nov 19, 2024
8bfe85d
stub help popovers in formdata to eliminate extra logging
jmchilton Nov 19, 2024
c83c4cf
This really stablizes these tests - they sort of runaway without this.
jmchilton Nov 19, 2024
752063b
Eliminate a extraneous logging event in HistoryView.test.js.
jmchilton Nov 19, 2024
be6aad9
Mock out popover to clean test logging for SelectPreferredStore.
jmchilton Nov 19, 2024
be8043a
Fix up FormTool.test.js.
jmchilton Nov 19, 2024
7a2dea0
remove unused option to clean up test output
jmchilton Nov 19, 2024
7e03ded
Should not call onScopeDispose when jest testing.
jmchilton Nov 19, 2024
1fbaea7
Fix unregistered component in test for Details.vue.
jmchilton Nov 19, 2024
2322991
Remove extra logging from watchHistory.test.js
jmchilton Nov 19, 2024
9648ce5
Suppress one stray expected log for taskMonitor.test.ts
jmchilton Nov 20, 2024
7bf53c4
Refactor to avoid unneeded logging in formUtil.ts.
jmchilton Nov 20, 2024
c567829
Cleanup extra printings of Vue production and devtools message.
jmchilton Nov 20, 2024
f24648f
Fix extra test logging and establish abstractions for config mocking.
jmchilton Nov 20, 2024
a2c2d23
fewer warnings around ToolCard.test.js
jmchilton Nov 20, 2024
7a9dcf0
Suppress debug logging when running app.test.js
jmchilton Nov 20, 2024
9f91db1
Fixes warnings in StatelessTags.test.vue.
jmchilton Nov 20, 2024
5815738
Suppress expected console debug.
jmchilton Nov 21, 2024
82a4498
Update client/tests/jest/jest.setup.js
jmchilton Nov 21, 2024
be68f7b
Merge branch 'dev' into testing_24.2_3
bgruening Nov 21, 2024
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
5 changes: 5 additions & 0 deletions client/src/app/app.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import galaxyOptions from "@tests/test-data/bootstrapped";
import { getGalaxyInstance, setGalaxyInstance } from "app";
import Backbone from "backbone";
import { suppressDebugConsole } from "tests/jest/helpers";

export function setupTestGalaxy(galaxyOptions_ = null) {
galaxyOptions_ = galaxyOptions_ || galaxyOptions;
Expand All @@ -13,6 +14,10 @@ export function setupTestGalaxy(galaxyOptions_ = null) {
});
}

// the app console debugs make sense but we just don't want to see them in test
// output.
suppressDebugConsole();

describe("App base construction/initializiation defaults", () => {
beforeEach(() => {
setupTestGalaxy(galaxyOptions);
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/ConfigTemplates/formUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ export function upgradeForm(template: TemplateSummary, instance: Instance): Form
}
for (const secret of secrets) {
const secretName = secret.name;
if (secretsSet.indexOf(secretName) >= 0) {
console.log("skipping...");
} else {
if (secretsSet.indexOf(secretName) < 0) {
form.push(templateSecretFormEntry(secret));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallowMount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { getLocalVue } from "tests/jest/helpers";
import { getLocalVue, suppressDebugConsole } from "tests/jest/helpers";

import { type DatasetStorageDetails } from "@/api";
import { useServerMock } from "@/api/client/__mocks__";
Expand Down Expand Up @@ -58,6 +58,7 @@ describe("DatasetStorage.vue", () => {
});

it("test error rendering...", async () => {
suppressDebugConsole();
mount({ simulateError: true });
await flushPromises();
expect(wrapper.findAll(".error").length).toBe(1);
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/Form/Elements/FormData/FormData.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "tests/jest/mockHelpPopovers";

import { createTestingPinia } from "@pinia/testing";
import { mount } from "@vue/test-utils";
import { PiniaVuePlugin } from "pinia";
Expand Down
13 changes: 3 additions & 10 deletions client/src/components/Grid/GridList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@ import { mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { PiniaVuePlugin } from "pinia";
import { getLocalVue } from "tests/jest/helpers";
import { setupMockConfig } from "tests/jest/mockConfig";

import { useConfig } from "@/composables/config";
import Filtering from "@/utils/filtering";

import MountTarget from "./GridList.vue";

jest.useFakeTimers();

jest.mock("composables/config");
useConfig.mockReturnValue({
config: {
value: {
disabled: false,
enabled: true,
},
},
isConfigLoaded: true,
});

setupMockConfig({ disabled: false, enabled: true });

jest.mock("vue-router/composables");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import flushPromises from "flush-promises";
import { getLocalVue } from "tests/jest/helpers";
import { h } from "vue";

import { useServerMock } from "@/api/client/__mocks__";
import { ROOT_COMPONENT } from "@/utils/navigation/schema";
Expand Down Expand Up @@ -42,6 +43,13 @@ async function mountComponent() {

const PREFERENCES = ROOT_COMPONENT.preferences;

// bootstrap vue will try to match targets to actual HTML elements in DOM but there
// may be no DOM for jest tests, just stub out an alternative minimal implementation.
jest.mock("@/components/ObjectStore/ObjectStoreSelectButtonPopover.vue", () => ({
name: "ObjectStoreSelectButtonPopover",
render: () => h("div", "Mocked Popover"),
}));

describe("SelectPreferredStore.vue", () => {
let axiosMock: MockAdapter;

Expand Down
7 changes: 3 additions & 4 deletions client/src/components/History/Multiple/MultipleView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { createPinia } from "pinia";
import { getLocalVue } from "tests/jest/helpers";
import { setupMockConfig } from "tests/jest/mockConfig";

import { useServerMock } from "@/api/client/__mocks__";
import { useHistoryStore } from "@/stores/historyStore";
Expand All @@ -13,6 +14,8 @@ import MultipleView from "./MultipleView.vue";
const USER_ID = "test-user-id";
const FIRST_HISTORY_ID = "test-history-id-0";

setupMockConfig({});

const { server, http } = useServerMock();

const getFakeHistorySummaries = (num) => {
Expand All @@ -29,10 +32,6 @@ describe("MultipleView", () => {
const fakeSummaries = getFakeHistorySummaries(count);

server.use(
http.get("/api/configuration", ({ response }) => {
return response(200).json({});
}),

http.get("/api/histories/{history_id}", ({ response, params }) => {
const { history_id } = params;
const summary = fakeSummaries.find((s) => s.id === history_id);
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/JobInformation/JobInformation.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "tests/jest/mockHelpPopovers";

import { mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { getLocalVue } from "tests/jest/helpers";
Expand Down
12 changes: 2 additions & 10 deletions client/src/components/Masthead/QuotaMeter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getFakeRegisteredUser } from "@tests/test-data";
import { mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { getLocalVue } from "tests/jest/helpers";
import { setupMockConfig } from "tests/jest/mockConfig";

import { type RegisteredUser } from "@/api";
import { useUserStore } from "@/stores/userStore";
Expand All @@ -11,19 +12,10 @@ import QuotaMeter from "./QuotaMeter.vue";

jest.mock("@/api/schema");

let configValues = { enable_quotas: true };

jest.mock("@/composables/config", () => ({
useConfig: jest.fn(() => ({
config: { value: { ...configValues } },
isConfigLoaded: true,
})),
}));

const localVue = getLocalVue();

async function createQuotaMeterWrapper(config: any, user: RegisteredUser) {
configValues = { ...config };
setupMockConfig(config);
const pinia = createTestingPinia();
const userStore = useUserStore();
userStore.currentUser = user;
Expand Down
11 changes: 2 additions & 9 deletions client/src/components/StsDownloadButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import MockAdapter from "axios-mock-adapter";
import flushPromises from "flush-promises";
import { createPinia } from "pinia";
import { getLocalVue } from "tests/jest/helpers";

import { useServerMock } from "@/api/client/__mocks__";
import { setupMockConfig } from "tests/jest/mockConfig";

import StsDownloadButton from "./StsDownloadButton.vue";

Expand All @@ -22,14 +21,8 @@ const FALLBACK_URL = "http://cow.com/direct_download";
const DOWNLOAD_ENDPOINT = "http://cow.com/prepare_download";
const STORAGE_REQUEST_ID = "moocow1235";

const { server, http } = useServerMock();

async function mountStsDownloadButtonWrapper(config) {
server.use(
http.get("/api/configuration", ({ response }) => {
return response(200).json(config);
})
);
setupMockConfig(config);

const pinia = createPinia();
const wrapper = mount(StsDownloadButton, {
Expand Down
7 changes: 4 additions & 3 deletions client/src/components/TagsMultiselect/StatelessTags.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { mount } from "@vue/test-utils";
import { useToast } from "composables/toast";
import { getLocalVue } from "tests/jest/helpers";
import { computed } from "vue";
import { getLocalVue, suppressBootstrapVueWarnings } from "tests/jest/helpers";

import { normalizeTag, useUserTagsStore } from "@/stores/userTagsStore";

Expand All @@ -19,10 +18,12 @@ const mountWithProps = (props) => {
});
};

suppressBootstrapVueWarnings();

jest.mock("@/stores/userTagsStore");
const onNewTagSeenMock = jest.fn((tag) => tag);
useUserTagsStore.mockReturnValue({
userTags: computed(() => autocompleteTags),
userTags: autocompleteTags,
onNewTagSeen: onNewTagSeenMock,
onTagUsed: jest.fn(),
onMultipleNewTagsSeen: jest.fn(),
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/TagsMultiselect/StatelessTags.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed, onMounted, ref } from "vue";

import { useToast } from "@/composables/toast";
Expand Down Expand Up @@ -36,7 +35,6 @@ const emit = defineEmits<{
}>();

const userTagsStore = useUserTagsStore();
const { userTags } = storeToRefs(userTagsStore);
const { warning } = useToast();

onMounted(() => {
Expand Down Expand Up @@ -110,7 +108,7 @@ function onTagClicked(tag: string) {
</div>

<HeadlessMultiselect
:options="userTags"
:options="userTagsStore.userTags"
:selected="props.value"
:placeholder="props.placeholder"
:validator="isValid"
Expand Down
29 changes: 22 additions & 7 deletions client/src/components/Tool/ToolCard.test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { mount } from "@vue/test-utils";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import flushPromises from "flush-promises";
import { createPinia } from "pinia";
import { useUserStore } from "stores/userStore";
import { getLocalVue } from "tests/jest/helpers";
import { setupMockConfig } from "tests/jest/mockConfig";

import { useServerMock } from "@/api/client/__mocks__";

import ToolCard from "./ToolCard";

const { server, http } = useServerMock();

jest.mock("@/api/schema");

jest.mock("@/composables/config", () => ({
useConfig: jest.fn(() => ({
config: { enable_tool_source_display: false },
isConfigLoaded: true,
})),
}));
const config = { enable_tool_source_display: false };
setupMockConfig(config);

const localVue = getLocalVue();

Expand All @@ -23,7 +25,15 @@ describe("ToolCard", () => {
let axiosMock;
let userStore;

beforeEach(() => {
beforeEach(async () => {
// some child component must be bypassing useConfig - so we need to explicitly
// stup the API endpoint also. If you can drop this without request problems in log,
// this hack can be removed.
server.use(
http.get("/api/configuration", ({ response }) => {
return response(200).json(config);
})
);
axiosMock = new MockAdapter(axios);
axiosMock.onGet(`/api/webhooks`).reply(200, []);

Expand All @@ -38,9 +48,12 @@ describe("ToolCard", () => {
sustainVersion: false,
options: {
id: "options.id",
name: "options.name",
version: "options.version",
versions: [],
sharable_url: "options.sharable_url",
help: "options.help",
help_format: "restructuredtext",
citations: false,
},
messageText: "messageText",
Expand All @@ -60,6 +73,7 @@ describe("ToolCard", () => {
is_admin: true,
preferences: {},
};
await flushPromises();
});

it("shows props", async () => {
Expand All @@ -81,5 +95,6 @@ describe("ToolCard", () => {
await wrapper.setProps({ disabled: true });
const backdropActive = wrapper.findAll(".portlet-backdrop");
expect(backdropActive.length).toBe(1);
await flushPromises();
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import "tests/jest/mockHelpPopovers";

import { mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { getLocalVue } from "tests/jest/helpers";
import { setupMockConfig } from "tests/jest/mockConfig";

import { useServerMock } from "@/api/client/__mocks__";
import { setupSelectableMock } from "@/components/ObjectStore/mockServices";
import { ROOT_COMPONENT } from "@/utils/navigation";

Expand All @@ -12,15 +14,9 @@ setupSelectableMock();

const localVue = getLocalVue(true);

const { server, http } = useServerMock();
setupMockConfig({});

function mountComponent() {
server.use(
http.get("/api/configuration", ({ response }) => {
return response(200).json({});
})
);

const wrapper = mount(ToolSelectPreferredObjectStore, {
propsData: { toolPreferredObjectStoreId: null },
localVue,
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/Toolshed/InstalledList/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div v-if="error" class="alert alert-danger" show>{{ error }}</div>
<div v-else>
<span v-if="loading">
<b-card>
<BCard>
<LoadingSpan message="Loading installed repository details" />
</b-card>
</BCard>
</span>
<div v-else>
<RepositoryDetails :repo="toolshedRepository" :toolshed-url="repo.tool_shed_url" />
Expand All @@ -14,6 +14,7 @@
</div>
</template>
<script>
import { BCard } from "bootstrap-vue";
import LoadingSpan from "components/LoadingSpan";
import { getAppRoot } from "onload/loadConfig";

Expand All @@ -23,6 +24,7 @@ import RepositoryDetails from "../RepositoryDetails/Index.vue";

export default {
components: {
BCard,
LoadingSpan,
RepositoryDetails,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { shallowMount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { createPinia } from "pinia";
import { getLocalVue } from "tests/jest/helpers";
import { getLocalVue, suppressDebugConsole } from "tests/jest/helpers";

import { HttpResponse, useServerMock } from "@/api/client/__mocks__";

Expand All @@ -10,6 +10,8 @@ import Index from "./Index.vue";
const { server, http } = useServerMock();

describe("RepositoryDetails", () => {
suppressDebugConsole(); // we issue a debug warning when a repo has no revisions

it("test repository details index", async () => {
server.use(
http.get("/api/configuration", ({ response }) => {
Expand Down
Loading
Loading