diff --git a/frontend/src/v2/layouts/AuthLayout.test.ts b/frontend/src/v2/layouts/AuthLayout.test.ts new file mode 100644 index 000000000..900521ca5 --- /dev/null +++ b/frontend/src/v2/layouts/AuthLayout.test.ts @@ -0,0 +1,49 @@ +import { mount } from "@vue/test-utils"; +import mitt from "mitt"; +import { createPinia, setActivePinia } from "pinia"; +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { nextTick } from "vue"; +import type { Events } from "@/types/emitter"; +import AuthLayout from "./AuthLayout.vue"; + +vi.mock("vue-i18n", () => ({ + useI18n: () => ({ t: (key: string) => key }), +})); + +vi.mock("@/v2/composables/useBreakpoint", () => ({ + installBreakpointAttribute: vi.fn(), +})); + +vi.mock("@/v2/composables/useInputModality", () => ({ + useInputModality: () => ({ install: vi.fn() }), +})); + +describe("AuthLayout", () => { + beforeEach(() => { + setActivePinia(createPinia()); + }); + + it("renders snackbar events from auth views", async () => { + const emitter = mitt(); + const wrapper = mount(AuthLayout, { + global: { + provide: { emitter }, + stubs: { + LanguageSelector: true, + RIcon: true, + RouterView: true, + VersionTag: true, + }, + }, + }); + + emitter.emit("snackbarShow", { + msg: "Unable to register user", + color: "error", + timeout: 0, + }); + await nextTick(); + + expect(wrapper.text()).toContain("Unable to register user"); + }); +}); diff --git a/frontend/src/v2/layouts/AuthLayout.vue b/frontend/src/v2/layouts/AuthLayout.vue index 3e1313a4b..f1346fdc9 100644 --- a/frontend/src/v2/layouts/AuthLayout.vue +++ b/frontend/src/v2/layouts/AuthLayout.vue @@ -3,6 +3,7 @@ // for the auth flows (Login / Register / ResetPassword / Setup). Bottom // corners hold the LanguageSelector (left) and VersionTag (right). import { onMounted } from "vue"; +import NotificationHost from "@/v2/components/Notifications/NotificationHost.vue"; import LanguageSelector from "@/v2/components/shared/LanguageSelector.vue"; import VersionTag from "@/v2/components/shared/VersionTag.vue"; import { installBreakpointAttribute } from "@/v2/composables/useBreakpoint"; @@ -32,6 +33,7 @@ onMounted(installInputModality); +