Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(extension): respect recording lock on camera toggle

Akshar Patel5ae4e94ea93c
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3fa00050e..8b749481a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -114,6 +114,9 @@ jobs:
bun test scripts/loops/profile.test.ts scripts/loops/lifecycle.test.ts
bun run tsc --noEmit --strict --jsx react-jsx --allowImportingTsExtensions --target ESNext --module ESNext --moduleResolution bundler --resolveJsonModule --types bun --skipLibCheck scripts/loops/*.ts
+ - name: Test Chrome extension
+ run: bun run --cwd apps/chrome-extension test
+
- name: Test render farm orchestration
run: |
bun test apps/render-farm
diff --git a/apps/chrome-extension/src/popup/components/camera-selector.test.tsx b/apps/chrome-extension/src/popup/components/camera-selector.test.tsx
new file mode 100644
index 000000000..d1c6f91b6
--- /dev/null
+++ b/apps/chrome-extension/src/popup/components/camera-selector.test.tsx
@@ -0,0 +1,38 @@
+import { renderToStaticMarkup } from "react-dom/server";
+import { describe, expect, it } from "vitest";
+import { CameraSelector } from "./camera-selector";
+
+const camera = { deviceId: "camera-1", label: "Camera", groupId: "group-1" };
+
+const renderStatusButton = (disabled: boolean, permissionGranted: boolean) => {
+ const markup = renderToStaticMarkup(
+ <CameraSelector
+ selectedCameraId={camera.deviceId}
+ availableCameras={permissionGranted ? [camera] : []}
+ permissionGranted={permissionGranted}
+ disabled={disabled}
+ onCameraChange={() => undefined}
+ onRefreshDevices={() => undefined}
+ onPermissionBlocked={() => undefined}
+ />,
+ );
+ return markup.match(/<button[^>]*aria-disabled="[^"]*"[^>]*>/)?.[0];
+};
+
+describe("camera selector", () => {
+ it.each([true, false])(
+ "disables the status button when the selector is disabled and permission is %s",
+ (permissionGranted) => {
+ const button = renderStatusButton(true, permissionGranted);
+
+ expect(button).toMatch(/\sdisabled=/);
+ expect(button).toMatch(/aria-disabled="true"/);
+ },
+ );
+
+ it("keeps the status button available when the selector is enabled", () => {
+ const button = renderStatusButton(false, true);
+ expect(button).not.toMatch(/\sdisabled=/);
+ expect(button).toMatch(/aria-disabled="false"/);
+ });
+});
diff --git a/apps/chrome-extension/src/popup/components/camera-selector.tsx b/apps/chrome-extension/src/popup/components/camera-selector.tsx
index 0d2eab167..69936bdb1 100644
--- a/apps/chrome-extension/src/popup/components/camera-selector.tsx
+++ b/apps/chrome-extension/src/popup/components/camera-selector.tsx
@@ -49,7 +49,8 @@ export const CameraSelector = ({
const hasAccess = permissionGranted || availableCameras.length > 0;
const shouldRequestPermission = !hasAccess;
- const statusPillDisabled = !shouldRequestPermission && !cameraEnabled;
+ const statusPillDisabled =
+ disabled || (!shouldRequestPermission && !cameraEnabled);
const currentValue = selectedCameraId ?? NO_CAMERA_VALUE;