From f1afc57f451dbf636abca069631028d0d7507389 Mon Sep 17 00:00:00 2001 From: Marc Lorenz Date: Thu, 23 Apr 2026 14:19:09 +0200 Subject: [PATCH] add ErrorPopup component and export Co-Authored-By: Claude Sonnet 4.6 --- src/components/ErrorPopup.test.ts | 37 ++++++++++++++++++++ src/components/ErrorPopup.vue | 58 +++++++++++++++++++++++++++++++ src/index.ts | 1 + 3 files changed, 96 insertions(+) create mode 100644 src/components/ErrorPopup.test.ts create mode 100644 src/components/ErrorPopup.vue diff --git a/src/components/ErrorPopup.test.ts b/src/components/ErrorPopup.test.ts new file mode 100644 index 0000000..7e2cd7a --- /dev/null +++ b/src/components/ErrorPopup.test.ts @@ -0,0 +1,37 @@ +import { describe, it, expect } from "vitest"; +import { mount } from "@vue/test-utils"; +import ErrorPopup from "./ErrorPopup.vue"; + +describe("ErrorPopup", () => { + it("renders nothing when show is false", () => { + const w = mount(ErrorPopup, { props: { show: false, message: "error" } }); + expect(w.find("[class*=fixed]").exists()).toBe(false); + }); + + it("renders nothing when message is null even if show is true", () => { + const w = mount(ErrorPopup, { props: { show: true, message: null } }); + expect(w.find("[class*=fixed]").exists()).toBe(false); + }); + + it("renders popup when show is true and message is set", () => { + const w = mount(ErrorPopup, { props: { show: true, message: "Verbindung fehlgeschlagen" } }); + expect(w.text()).toContain("Verbindung fehlgeschlagen"); + }); + + it("emits close when backdrop is clicked", async () => { + const w = mount(ErrorPopup, { props: { show: true, message: "err" } }); + await w.find(".absolute.inset-0").trigger("click"); + expect(w.emitted("close")).toHaveLength(1); + }); + + it("emits close when OK button is clicked", async () => { + const w = mount(ErrorPopup, { props: { show: true, message: "err" } }); + await w.find("button").trigger("click"); + expect(w.emitted("close")).toHaveLength(1); + }); + + it("displays Verbindungsfehler heading", () => { + const w = mount(ErrorPopup, { props: { show: true, message: "x" } }); + expect(w.text()).toContain("Verbindungsfehler"); + }); +}); diff --git a/src/components/ErrorPopup.vue b/src/components/ErrorPopup.vue new file mode 100644 index 0000000..7088eb8 --- /dev/null +++ b/src/components/ErrorPopup.vue @@ -0,0 +1,58 @@ + + + diff --git a/src/index.ts b/src/index.ts index ae144a9..1e84313 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,3 @@ export { default as LimelightButton } from './components/LimelightButton.vue' +export { default as ErrorPopup } from './components/ErrorPopup.vue' export * from './utils/webviewer'