diff --git a/src/components/CompletionVideo.test.tsx b/src/components/CompletionVideo.test.tsx
index 758e8c7..07370f2 100644
--- a/src/components/CompletionVideo.test.tsx
+++ b/src/components/CompletionVideo.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, render, screen } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { fakeRun } from "../api/fakes";
import type { Run } from "../api/types";
@@ -87,3 +87,29 @@ describe("motion", () => {
expect(v).toHaveAttribute("controls");
});
});
+
+describe("when the video cannot be loaded", () => {
+ const open = () => {
+ const r = render();
+ r.rerender();
+ return r;
+ };
+
+ it("says so instead of leaving a blank box, and keeps the close button", async () => {
+ open();
+ fireEvent.error(screen.getByRole("dialog").querySelector("video")!);
+ expect(screen.getByRole("alert")).toHaveTextContent("영상을 불러오지 못했습니다.");
+ expect(screen.getByRole("dialog").querySelector("video")).toBeNull();
+ await userEvent.click(screen.getByRole("button", { name: "닫기" }));
+ expect(screen.queryByRole("dialog")).toBeNull();
+ });
+
+ it("tries the video again the next time it is opened", async () => {
+ open();
+ fireEvent.error(screen.getByRole("dialog").querySelector("video")!);
+ await userEvent.click(screen.getByRole("button", { name: "닫기" }));
+ await userEvent.click(screen.getByRole("button", { name: /완료 영상 보기/ }));
+ expect(screen.queryByRole("alert")).toBeNull();
+ expect(screen.getByRole("dialog").querySelector("video")).not.toBeNull();
+ });
+});
diff --git a/src/components/CompletionVideo.tsx b/src/components/CompletionVideo.tsx
index b3612a7..47bae4b 100644
--- a/src/components/CompletionVideo.tsx
+++ b/src/components/CompletionVideo.tsx
@@ -15,6 +15,13 @@ export function justSucceeded(prev: { id?: string; status?: string }, run?: Pick
/** The person asked the system to reduce motion: the video then waits for them to press play. */
export const prefersReducedMotion = (): boolean => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
+/** The video, or the reason there is none: the popup has no visible title or frame to show that it failed. Mounted per opening, so a failure does not stick. */
+function PopupVideo() {
+ const [failed, setFailed] = useState(false);
+ if (failed) return
영상을 불러오지 못했습니다.
;
+ return