diff --git a/tests/unit/components/AppHeader.spec.ts b/tests/unit/components/AppHeader.spec.ts index db39b9b4..afb1bf8d 100644 --- a/tests/unit/components/AppHeader.spec.ts +++ b/tests/unit/components/AppHeader.spec.ts @@ -1,17 +1,14 @@ import AppHeader from "@/components/AppHeader.vue"; import { mountSuspended } from "@nuxt/test-utils/runtime"; import { waitFor } from "@testing-library/vue"; -import { mockVersions } from "../mocks/mockPinia"; const stubs = { CIcon: true, }; -const versionTooltipContent = `Model version: ${mockVersions.daedalusModel} \nR API version: ${mockVersions.daedalusApi} \nWeb app version: ${mockVersions.daedalusWebApp}`; - describe("app header", () => { it('emits "toggleSidebarVisibility" event when CHeaderToggler is clicked', async () => { - const component = await mountSuspended(AppHeader, { global: { stubs }, props: { versionTooltipContent } }); + const component = await mountSuspended(AppHeader, { global: { stubs } }); await component.findComponent({ name: "CHeaderToggler" }).vm.$emit("click"); expect(component.emitted()).toHaveProperty("toggleSidebarVisibility"); @@ -21,7 +18,7 @@ describe("app header", () => { const addEventListenerSpy = vi.spyOn(window, "addEventListener"); const removeEventListenerSpy = vi.spyOn(window, "removeEventListener"); - const component = await mountSuspended(AppHeader, { global: { stubs }, props: { versionTooltipContent } }); + const component = await mountSuspended(AppHeader, { global: { stubs } }); expect(addEventListenerSpy).toHaveBeenCalledWith("scroll", expect.any(Function)); const header = component.findComponent({ name: "CHeader" }); @@ -44,20 +41,17 @@ describe("app header", () => { removeEventListenerSpy.mockRestore(); }); - it("should render logo and include information about the version numbers", async () => { + it("should render logo", async () => { const component = await mountSuspended(AppHeader, { - props: { versionTooltipContent }, global: { stubs }, }); await waitFor(() => { - const logoTitleAttribute = component + const logoSrcAttribute = component .find(`[data-testid="ji-logo-header"]`) .attributes() - .title; - expect(logoTitleAttribute).toContain("Model version: 1.2.3"); - expect(logoTitleAttribute).toContain("R API version: 4.5.6"); - expect(logoTitleAttribute).toContain("Web app version: 7.8.9"); + .src; + expect(logoSrcAttribute).toContain("IMPERIAL_JAMEEL_INSTITUTE"); }); }); }); diff --git a/tests/unit/components/SideBar.spec.ts b/tests/unit/components/SideBar.spec.ts index f2ee3717..b073a91f 100644 --- a/tests/unit/components/SideBar.spec.ts +++ b/tests/unit/components/SideBar.spec.ts @@ -1,6 +1,6 @@ import type { VueWrapper } from "@vue/test-utils"; import SideBar from "@/components/SideBar.vue"; -import { mockPinia, mockVersions } from "@/tests/unit/mocks/mockPinia"; +import { mockPinia } from "@/tests/unit/mocks/mockPinia"; import { mountSuspended } from "@nuxt/test-utils/runtime"; import { waitFor } from "@testing-library/vue"; @@ -13,7 +13,6 @@ const mockCSidebarPageloadBehavior = async (coreuiSidebar: VueWrapper) => { coreuiSidebar.vm.$emit("hide"); }; -const versionTooltipContent = `Model version: ${mockVersions.daedalusModel} \nR API version: ${mockVersions.daedalusApi} \nWeb app version: ${mockVersions.daedalusWebApp}`; describe("sidebar", () => { describe('when the "visible" prop is initialized as false', () => { describe("on smaller devices", () => { @@ -23,7 +22,7 @@ describe("sidebar", () => { it('starts as hidden, and can be opened by setting "visible" prop', async () => { const component = await mountSuspended(SideBar, { - props: { visible: false, versionTooltipContent }, + props: { visible: false }, global: { stubs, plugins }, }); const coreuiSidebar = component.findComponent({ name: "CSidebar" }); @@ -38,20 +37,18 @@ describe("sidebar", () => { expect(coreuiSidebar.props("unfoldable")).toBe(false); }); - it("should render logo and include information about the version numbers", async () => { + it("should render logo", async () => { const component = await mountSuspended(SideBar, { - props: { visible: false, versionTooltipContent }, + props: { visible: false }, global: { stubs, plugins }, }); await waitFor(() => { - const logoTitleAttribute = component + const logoSrcAttribute = component .find(`[data-testid="ji-logo-sidebar"]`) .attributes() - .title; - expect(logoTitleAttribute).toContain("Model version: 1.2.3"); - expect(logoTitleAttribute).toContain("R API version: 4.5.6"); - expect(logoTitleAttribute).toContain("Web app version: 7.8.9"); + .src; + expect(logoSrcAttribute).toContain("IMPERIAL_JAMEEL_INSTITUTE"); }); }); }); @@ -63,7 +60,6 @@ describe("sidebar", () => { it("starts as shown", async () => { const component = await mountSuspended(SideBar, { - props: { visible: false, versionTooltipContent }, global: { stubs, plugins }, }); const coreuiSidebar = component.findComponent({ name: "CSidebar" }); @@ -75,7 +71,6 @@ describe("sidebar", () => { it("renders the text and href for nav items", async () => { const component = await mountSuspended(SideBar, { - props: { visible: false, versionTooltipContent }, global: { stubs, plugins }, }); const coreuiSidebar = component.findComponent({ name: "CSidebar" }); diff --git a/tests/unit/pages/About.spec.ts b/tests/unit/pages/About.spec.ts index c70e244d..4a9a7176 100644 --- a/tests/unit/pages/About.spec.ts +++ b/tests/unit/pages/About.spec.ts @@ -1,7 +1,7 @@ import About from "@/pages/about.vue"; import { mountSuspended } from "@nuxt/test-utils/runtime"; import { describe, expect, it } from "vitest"; -import { countryAndPathogenParams, mockedMetadata, mockPinia } from "../mocks/mockPinia"; +import { countryAndPathogenParams, mockedMetadata, mockPinia, mockVersions } from "../mocks/mockPinia"; describe("about page", () => { it("should render about with correct metadata info", async () => { @@ -9,6 +9,7 @@ describe("about page", () => { const numberOfCountries = countryAndPathogenParams.find(p => p.id === "country")!.options!.length; const component = await mountSuspended(About, { global: { plugins: [mockPinia({ metadata: { ...mockedMetadata, parameters: countryAndPathogenParams as any }, + versions: mockVersions, })] } }); const text = component.text(); @@ -19,5 +20,8 @@ describe("about page", () => { for (const estimate of mockedMetadata.results.time_series_groups) { expect(text).toContain(estimate.label); } + expect(text).toContain("Model version: 1.2.3"); + expect(text).toContain("R API version: 4.5.6"); + expect(text).toContain("Web app version: 7.8.9"); }); });