Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/components/CompletionVideo.test.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -87,3 +87,29 @@ describe("motion", () => {
expect(v).toHaveAttribute("controls");
});
});

describe("when the video cannot be loaded", () => {
const open = () => {
const r = render(<CompletionVideo run={run()} />);
r.rerender(<CompletionVideo run={run({ status: "succeeded" })} />);
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();
});
});
9 changes: 8 additions & 1 deletion src/components/CompletionVideo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <p role="alert" className="mg-pop-err">영상을 불러오지 못했습니다.</p>;
return <video src={COMPLETION_VIDEO_SRC} controls autoPlay={!prefersReducedMotion()} muted playsInline aria-label="이전 완료 영상" onError={() => setFailed(true)} />;
}

export function CompletionVideo({ run }: { run?: Run }) {
const [open, setOpen] = useState(false);
const seen = useRef<{ id?: string; status?: string }>({});
Expand Down Expand Up @@ -60,7 +67,7 @@ export function CompletionVideo({ run }: { run?: Run }) {
닫기
</button>
</header>
<video src={COMPLETION_VIDEO_SRC} controls autoPlay={!prefersReducedMotion()} muted playsInline aria-label="이전 완료 영상" />
<PopupVideo />
</div>
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3309,5 +3309,6 @@
"차단됨: {0} (RBAC: 샌드박스 계정 권한 밖)": "ブロック: {0} (RBAC: サンドボックスアカウントの権限外)",
"차단됨: {0} (RBAC: Pod 생성 권한 없음)": "ブロック: {0} (RBAC: Pod の作成権限なし)",
"차단됨: {0} (Pod Security: 노드 네트워크·파일시스템을 쓰는 Pod 금지)": "ブロック: {0} (Pod Security: ノードのネットワークとファイルシステムを使う Pod は禁止)",
"차단됨: {0} (NetworkPolicy: 샌드박스 밖으로 나가는 연결 차단)": "ブロック: {0} (NetworkPolicy: サンドボックス外への接続をブロック)"
"차단됨: {0} (NetworkPolicy: 샌드박스 밖으로 나가는 연결 차단)": "ブロック: {0} (NetworkPolicy: サンドボックス外への接続をブロック)",
"영상을 불러오지 못했습니다.": "動画を読み込めませんでした。"
}
14 changes: 10 additions & 4 deletions src/styles/migrate.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,13 @@
/* the video popup of a finished migration */
.mg-video-bar { display: flex; justify-content: flex-end; }
.mg-pop-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.mg-pop { background: var(--canvas); border: 1px solid var(--card-line); border-radius: var(--r-card); width: min(960px, 100%); max-height: 100%; padding: var(--sp-md); display: grid; gap: var(--sp-md); outline: none; }
.mg-pop header { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-md); }
.mg-pop h2 { margin: 0; font-size: 18px; }
.mg-pop video { width: 100%; max-height: calc(100vh - 160px); background: #000; border-radius: var(--r-control); }
/* the video fills the popup: no white frame around it. The title stays for screen readers, the close button sits on the video. */
.mg-pop { position: relative; width: min(960px, 100%); max-height: 100%; outline: none; }
.mg-pop header { position: absolute; top: var(--sp-sm); right: var(--sp-sm); z-index: 1; }
.mg-pop h2 { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mg-pop header .btn { background: rgba(0, 0, 0, 0.55); color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.mg-pop header .btn:hover { background: rgba(0, 0, 0, 0.75); }
/* the console's focus ring is dark and would vanish on the video */
.mg-pop header .btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.mg-pop-err { margin: 0; padding: 96px 24px; background: #000; color: #fff; text-align: center; border-radius: var(--r-card); }
.mg-pop video { display: block; width: 100%; max-height: calc(100vh - 48px); background: #000; border-radius: var(--r-card); }