Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(layout): name the preset control, and say the saved layout survives

EtienneLescotf4cdafe2df2d
diff --git a/src/components/ai-edition/RightPanes.layout.test.tsx b/src/components/ai-edition/RightPanes.layout.test.tsx
index d55f5cec6..4056d13c1 100644
--- a/src/components/ai-edition/RightPanes.layout.test.tsx
+++ b/src/components/ai-edition/RightPanes.layout.test.tsx
@@ -1,8 +1,15 @@
// @vitest-environment jsdom
+// The layout preset is a global setting but the camera is per clip, so a project can
+// hold no camera at all (#248). These pin what the pane shows in that case: the
+// controls go dead, the preset reads "No Webcam", and — the part that is easy to break —
+// the saved preference is left untouched on disk and the help popover says so.
+
import "@testing-library/jest-dom";
import { cleanup, render, screen, within } from "@testing-library/react";
-import { afterEach, describe, expect, it } from "vitest";
+import userEvent from "@testing-library/user-event";
+import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { I18nProvider } from "@/contexts/I18nContext";
+import { LOCALE_STORAGE_KEY } from "@/i18n/config";
import { type AxcutDocument, createEmptyDocument } from "@/lib/ai-edition/schema";
import { useProjectStore } from "@/lib/ai-edition/store/projectStore";
import { LayoutPane } from "./RightPanes";
@@ -45,10 +52,12 @@ function seedProject(hasCamera: boolean): AxcutDocument {
};
}
-function renderLayout(document: AxcutDocument) {
+// `doc` rather than `document`: this is a jsdom file, and shadowing the global would
+// silently redirect any `document.querySelector` a later test adds.
+function renderLayout(doc: AxcutDocument) {
useProjectStore.setState({
- projectId: document.project.id,
- document,
+ projectId: doc.project.id,
+ document: doc,
revision: 1,
status: "ready",
});
@@ -59,17 +68,24 @@ function renderLayout(document: AxcutDocument) {
);
}
+beforeEach(() => {
+ // The assertions below are on English copy; without pinning they would ride on
+ // jsdom's implicit en-US and pass vacuously if the fallback ever changed.
+ localStorage.clear();
+ localStorage.setItem(LOCALE_STORAGE_KEY, "en");
+});
+
afterEach(() => {
cleanup();
+ localStorage.clear();
useProjectStore.getState().clear();
});
describe("LayoutPane camera availability", () => {
it("shows No webcam without overwriting the saved camera preset", () => {
- const document = seedProject(false);
- renderLayout(document);
+ renderLayout(seedProject(false));
- const preset = screen.getByRole("combobox");
+ const preset = screen.getByRole("combobox", { name: "Layout" });
expect(preset).toBeDisabled();
expect(preset).toHaveValue("no-webcam");
expect(useProjectStore.getState().document?.legacyEditor).toMatchObject({
@@ -83,10 +99,19 @@ describe("LayoutPane camera availability", () => {
expect(within(mirrorRow as HTMLElement).getByRole("button")).toBeDisabled();
});
- it("keeps the saved preset active when a timeline clip has a camera", () => {
+ it("tells the user the saved preset was kept rather than thrown away", async () => {
+ const user = userEvent.setup();
+ renderLayout(seedProject(false));
+
+ await user.click(screen.getByRole("button", { name: "Help" }));
+ expect(screen.getByRole("note")).toHaveTextContent(/saved layout is kept/i);
+ });
+
+ it("keeps the saved preset active when a timeline clip has a camera", async () => {
+ const user = userEvent.setup();
renderLayout(seedProject(true));
- const preset = screen.getByRole("combobox");
+ const preset = screen.getByRole("combobox", { name: "Layout" });
expect(preset).toBeEnabled();
expect(preset).toHaveValue("picture-in-picture");
expect(screen.getByText("Camera Shape")).toBeInTheDocument();
@@ -94,5 +119,9 @@ describe("LayoutPane camera availability", () => {
expect(screen.getByText("Webcam Size")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Rounded" })).toBeEnabled();
expect(screen.getByRole("slider")).toBeEnabled();
+
+ // The camera-less hint must not leak into the normal case.
+ await user.click(screen.getByRole("button", { name: "Help" }));
+ expect(screen.getByRole("note")).not.toHaveTextContent(/saved layout is kept/i);
});
});
diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.json
index 72f3883be..917a24d90 100644
--- a/src/i18n/locales/ar/settings.json
+++ b/src/i18n/locales/ar/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "تصغير عند التكبير",
"reactiveWebcamDescription": "تتقلص الكاميرا بسلاسة أثناء تكبير الفيديو حتى لا تعيق الرؤية.",
"help": "طريقة دمج كاميرا الويب مع الشاشة: صورة داخل صورة، أو تكديس عمودي، أو إطار مزدوج، وشكل القناع والحجم والانعكاس.",
+ "helpNoWebcam": "لا يحتوي هذا المشروع على كاميرا، لذلك فإن عناصر التحكم في التخطيط معطّلة ويعرض الإعداد المسبق «بدون كاميرا». يُحتفظ بالتخطيط المحفوظ لحين إضافة كاميرا.",
"shapes": {
"rectangle": "مستطيل",
"circle": "دائرة",
diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.json
index d6fa45887..00bc205be 100644
--- a/src/i18n/locales/en/settings.json
+++ b/src/i18n/locales/en/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "Shrink on Zoom",
"reactiveWebcamDescription": "Camera smoothly shrinks while the video is zoomed in, so it stays out of the way.",
"help": "How the webcam is composed with the screen: picture-in-picture, vertical stack, dual frame, mask shape, size, and mirroring.",
+ "helpNoWebcam": "This project has no camera, so the layout controls are off and the preset reads “No Webcam”. Your saved layout is kept for when a camera is added.",
"shapes": {
"rectangle": "Rect",
"circle": "Circle",
diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.json
index 71ba0b9d5..ae96ab53c 100644
--- a/src/i18n/locales/es/settings.json
+++ b/src/i18n/locales/es/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "Reducir al ampliar",
"reactiveWebcamDescription": "La cámara se reduce suavemente mientras el vídeo está ampliado, para no estorbar.",
"help": "Cómo se compone la webcam con la pantalla: imagen en imagen, pila vertical, marco doble, forma de máscara, tamaño y efecto espejo.",
+ "helpNoWebcam": "Este proyecto no tiene cámara, así que los controles de diseño están desactivados y el preajuste muestra «Sin cámara». Tu diseño guardado se conserva para cuando añadas una cámara.",
"shapes": {
"rectangle": "Rect.",
"circle": "Círculo",
diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.json
index e94b4f579..2b38cc4f9 100644
--- a/src/i18n/locales/fr/settings.json
+++ b/src/i18n/locales/fr/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "Réduire au zoom",
"reactiveWebcamDescription": "La caméra rétrécit doucement pendant le zoom, pour ne pas gêner.",
"help": "Composition de la webcam avec l'écran : incrustation, empilement vertical, double cadre, forme du masque, taille et effet miroir.",
+ "helpNoWebcam": "Ce projet n’a pas de caméra : les réglages de disposition sont désactivés et le préréglage affiche « Sans webcam ». Votre disposition enregistrée est conservée pour le jour où une caméra sera ajoutée.",
"shapes": {
"rectangle": "Rect.",
"circle": "Cercle",
diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.json
index 464adba34..797e0a213 100644
--- a/src/i18n/locales/it/settings.json
+++ b/src/i18n/locales/it/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "Riduci con lo zoom",
"reactiveWebcamDescription": "La webcam si riduce dolcemente durante lo zoom, così non intralcia.",
"help": "Come la webcam viene composta con lo schermo: picture-in-picture, pila verticale, doppio riquadro, forma della maschera, dimensione e effetto specchio.",
+ "helpNoWebcam": "Questo progetto non ha una webcam, quindi i controlli di layout sono disattivati e il preset mostra «Nessuna webcam». Il layout salvato viene conservato per quando aggiungerai una webcam.",
"shapes": {
"rectangle": "Rett.",
"circle": "Cerchio",
diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.json
index 386d51092..8cbce2715 100644
--- a/src/i18n/locales/ja-JP/settings.json
+++ b/src/i18n/locales/ja-JP/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "ズーム時に縮小",
"reactiveWebcamDescription": "ズーム中はカメラがスムーズに縮小し、邪魔になりません。",
"help": "ウェブカメラと画面の合成方法: ピクチャインピクチャ、縦積み、デュアルフレーム、マスク形状、サイズ、左右反転。",
+ "helpNoWebcam": "このプロジェクトにはカメラがないため、レイアウトの設定は無効で、プリセットは「Webカメラなし」と表示されます。保存されたレイアウトは、カメラを追加したときのために保持されます。",
"shapes": {
"rectangle": "長方形",
"circle": "円",
diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.json
index 24405508b..a986c2ee8 100644
--- a/src/i18n/locales/ko-KR/settings.json
+++ b/src/i18n/locales/ko-KR/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "확대 시 축소",
"reactiveWebcamDescription": "확대하는 동안 카메라가 부드럽게 작아져 방해되지 않습니다.",
"help": "웹캠과 화면을 합성하는 방식: PIP, 세로 배치, 이중 프레임, 마스크 모양, 크기, 좌우 반전.",
+ "helpNoWebcam": "이 프로젝트에는 카메라가 없어 레이아웃 설정이 비활성화되고 프리셋이 “웹캠 없음”으로 표시됩니다. 저장된 레이아웃은 카메라를 추가할 때를 위해 유지됩니다.",
"shapes": {
"rectangle": "직사각형",
"circle": "원형",
diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.json
index c3eebc6da..203846fcb 100644
--- a/src/i18n/locales/pt-BR/settings.json
+++ b/src/i18n/locales/pt-BR/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "Encolher ao ampliar",
"reactiveWebcamDescription": "A câmera diminui suavemente enquanto o vídeo está ampliado, para não atrapalhar.",
"help": "Como a webcam é composta com a tela: picture-in-picture, pilha vertical, quadro duplo, formato da máscara, tamanho e espelhamento.",
+ "helpNoWebcam": "Este projeto não tem câmera, então os controles de layout estão desativados e a predefinição mostra “Sem Webcam”. Seu layout salvo é mantido para quando você adicionar uma câmera.",
"shapes": {
"rectangle": "Ret.",
"circle": "Círculo",
diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.json
index ad63e276d..70acfb8ab 100644
--- a/src/i18n/locales/ru/settings.json
+++ b/src/i18n/locales/ru/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "Уменьшать при зуме",
"reactiveWebcamDescription": "Камера плавно уменьшается во время приближения, чтобы не мешать.",
"help": "Как камера совмещается с экраном: «картинка в картинке», вертикальная стопка, двойной кадр, форма маски, размер и зеркальное отражение.",
+ "helpNoWebcam": "В этом проекте нет камеры, поэтому настройки компоновки отключены, а пресет показывает «Без веб-камеры». Сохранённая компоновка останется на случай, если вы добавите камеру.",
"shapes": {
"rectangle": "Прямоуг.",
"circle": "Круг",
diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.json
index d397e65a3..565eb982c 100644
--- a/src/i18n/locales/tr/settings.json
+++ b/src/i18n/locales/tr/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "Yakınlaştırınca küçült",
"reactiveWebcamDescription": "Video yakınlaştırıldığında kamera yumuşakça küçülür, böylece yoldan çekilir.",
"help": "Web kamerasının ekranla birleştirilme biçimi: resim içinde resim, dikey yığın, çift çerçeve, maske şekli, boyut ve aynalama.",
+ "helpNoWebcam": "Bu projede kamera yok; bu yüzden yerleşim denetimleri kapalı ve ön ayar “Web kamerası yok” gösteriyor. Kaydettiğiniz yerleşim, bir kamera eklediğinizde kullanılmak üzere korunur.",
"shapes": {
"rectangle": "Dikdörtgen",
"circle": "Daire",
diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.json
index fcaa03388..b5f02ea6c 100644
--- a/src/i18n/locales/vi/settings.json
+++ b/src/i18n/locales/vi/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "Thu nhỏ khi phóng to",
"reactiveWebcamDescription": "Camera thu nhỏ mượt mà khi video được phóng to, để không che khuất.",
"help": "Cách ghép webcam với màn hình: hình trong hình, xếp dọc, khung đôi, hình dạng mặt nạ, kích thước và lật gương.",
+ "helpNoWebcam": "Dự án này không có camera nên các tùy chọn bố cục bị tắt và thiết lập sẵn hiển thị “Không có webcam”. Bố cục đã lưu của bạn vẫn được giữ lại cho khi bạn thêm camera.",
"shapes": {
"rectangle": "Chữ nhật",
"circle": "Tròn",
diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.json
index 013b5e6d1..e2e05ebb1 100644
--- a/src/i18n/locales/zh-CN/settings.json
+++ b/src/i18n/locales/zh-CN/settings.json
@@ -53,6 +53,7 @@
"reactiveWebcam": "缩放时缩小",
"reactiveWebcamDescription": "放大视频时摄像头会平滑缩小,以免遮挡内容。",
"help": "摄像头与屏幕的合成方式:画中画、垂直堆叠、双画面、遮罩形状、大小和镜像。",
+ "helpNoWebcam": "此项目没有摄像头,因此布局控件已禁用,预设显示为“无摄像头”。你保存的布局会保留,以便添加摄像头后使用。",
"shapes": {
"rectangle": "矩形",
"circle": "圆形",
diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.json
index 82b1d76c9..5dd728b4e 100644
--- a/src/i18n/locales/zh-TW/settings.json
+++ b/src/i18n/locales/zh-TW/settings.json
@@ -54,6 +54,7 @@
"reactiveWebcam": "縮放時縮小",
"reactiveWebcamDescription": "放大影片時鏡頭會平滑縮小,以免遮擋內容。",
"help": "攝影機與螢幕的合成方式:子母畫面、垂直堆疊、雙畫面、遮罩形狀、大小與鏡像。",
+ "helpNoWebcam": "此專案沒有攝影機,因此版面配置控制項已停用,預設顯示為「無網路攝影機」。你儲存的版面配置會保留,以便新增攝影機後使用。",
"shapes": {
"rectangle": "矩形",
"circle": "圓形",