Update InstalledList Index test for GComponents

- Add GLink import and proper component stubbing
- Change from findAll("a") to findAllComponents(GLink)
- Update loading message check to use LoadingSpan stub
- Verify Tool Shed field in component data instead of DOM
This commit is contained in:
Alireza Heidari
2026-02-06 09:55:02 +01:00
parent 57affb5f20
commit 88d331b879
@@ -3,6 +3,7 @@ import { mount } from "@vue/test-utils";
import { describe, expect, it, vi } from "vitest";
import Index from "./Index.vue";
import GLink from "@/components/BaseComponents/GLink.vue";
vi.mock("app");
vi.mock("onload/loadConfig", () => ({
@@ -42,20 +43,22 @@ describe("InstalledList", () => {
},
stubs: {
RepositoryDetails: true,
GLink,
LoadingSpan: true,
},
localVue,
});
expect(wrapper.find(".loading-message").text()).toBe("Loading installed repositories...");
expect(wrapper.find("loadingspan-stub").attributes("message")).toBe("Loading installed repositories");
await wrapper.vm.$nextTick();
expect(wrapper.find(".installed-message").text()).toBe("2 repositories installed on this instance.");
const names = wrapper.findAll(".name");
expect(names.length).toBe(2);
expect(names.at(0).text()).toBe("name_0");
expect(names.at(1).text()).toBe("name_1");
const links = wrapper.findAll("a");
const links = wrapper.findAllComponents(GLink);
expect(links.length).toBe(3);
const badge = links.at(1).find(".badge");
expect(badge.text()).toBe("Newer version available!");
expect(wrapper.find('th[role="columnheader"][aria-colindex="3"] > div').text()).toBe("Tool Shed");
expect(wrapper.vm.fields.some((field) => field.key === "tool_shed")).toBe(true);
});
});