Fix auth notification rendering

This commit is contained in:
Florian Cullmann
2026-08-20 00:35:38 +02:00
parent 42e8043372
commit 325cfe0e13
2 changed files with 51 additions and 0 deletions

View File

@@ -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<Events>();
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");
});
});

View File

@@ -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);
</div>
<VersionTag class="r-v2-auth__version" />
</div>
<NotificationHost />
</div>
</template>