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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading