-
Notifications
You must be signed in to change notification settings - Fork 105
fix(layout): show no-webcam for camera-less projects #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
EtienneLescot
merged 4 commits into
getopenscreen:main
from
arhxam:codex/camera-less-layout-state
Aug 20, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bb85707
fix(layout): show no-webcam for camera-less projects
arhxam 6361f35
test(layout): cover camera-dependent controls
arhxam a55602d
refactor(layout): give the effective-preset rule one home
EtienneLescot 583fe51
fix(layout): name the preset control, and say the saved layout survives
EtienneLescot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| // @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 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"; | ||
|
|
||
| function seedProject(hasCamera: boolean): AxcutDocument { | ||
| const base = createEmptyDocument({ projectId: "project_layout", title: "Layout" }); | ||
| return { | ||
| ...base, | ||
| assets: [ | ||
| { | ||
| id: "asset_1", | ||
| kind: "video", | ||
| label: "screen.webm", | ||
| originalPath: "/tmp/screen.webm", | ||
| durationSec: 10, | ||
| video: { codec: "unknown", width: 1920, height: 1080, fps: 30 }, | ||
| cameraTrack: hasCamera | ||
| ? { sourcePath: "/tmp/camera.webm", startMs: 0, offsetMs: 0, visible: true } | ||
| : null, | ||
| }, | ||
| ], | ||
| project: { ...base.project, primaryAssetId: "asset_1" }, | ||
| timeline: { | ||
| ...base.timeline, | ||
| clips: [ | ||
| { | ||
| id: "clip_1", | ||
| assetId: "asset_1", | ||
| sourceStartSec: 0, | ||
| sourceEndSec: 10, | ||
| timelineStartSec: 0, | ||
| timelineEndSec: 10, | ||
| wordRefs: [], | ||
| origin: "user", | ||
| reason: "test", | ||
| }, | ||
| ], | ||
| }, | ||
| legacyEditor: { webcamLayoutPreset: "picture-in-picture" }, | ||
| }; | ||
| } | ||
|
|
||
| // `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: doc.project.id, | ||
| document: doc, | ||
| revision: 1, | ||
| status: "ready", | ||
| }); | ||
| return render( | ||
| <I18nProvider> | ||
| <LayoutPane /> | ||
| </I18nProvider>, | ||
| ); | ||
| } | ||
|
|
||
| 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", () => { | ||
| renderLayout(seedProject(false)); | ||
|
|
||
| const preset = screen.getByRole("combobox", { name: "Layout" }); | ||
| expect(preset).toBeDisabled(); | ||
| expect(preset).toHaveValue("no-webcam"); | ||
| expect(useProjectStore.getState().document?.legacyEditor).toMatchObject({ | ||
| webcamLayoutPreset: "picture-in-picture", | ||
| }); | ||
| expect(screen.queryByText("Camera Shape")).not.toBeInTheDocument(); | ||
| expect(screen.queryByText("Shrink on Zoom")).not.toBeInTheDocument(); | ||
| expect(screen.queryByText("Webcam Size")).not.toBeInTheDocument(); | ||
| const mirrorRow = screen.getByText("Mirror Webcam").closest("div"); | ||
| expect(mirrorRow).not.toBeNull(); | ||
| expect(within(mirrorRow as HTMLElement).getByRole("button")).toBeDisabled(); | ||
| }); | ||
|
|
||
| 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", { name: "Layout" }); | ||
| expect(preset).toBeEnabled(); | ||
| expect(preset).toHaveValue("picture-in-picture"); | ||
| expect(screen.getByText("Camera Shape")).toBeInTheDocument(); | ||
| expect(screen.getByText("Shrink on Zoom")).toBeInTheDocument(); | ||
| 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); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.