Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
test(web): add effective video rules unit coverage
Richie McIlroy18d6145eb2e8
diff --git a/apps/web/__tests__/unit/effective-video-rules.test.ts b/apps/web/__tests__/unit/effective-video-rules.test.tsnew file mode 100644index 000000000..838dcc183--- /dev/null+++ b/apps/web/__tests__/unit/effective-video-rules.test.ts@@ -0,0 +1,84 @@+import { resolveEffectiveVideoRules } from "@cap/web-backend";+import { describe, expect, it } from "vitest";++describe("resolveEffectiveVideoRules", () => {+ it("uses space-disabled settings over video and organization settings", () => {+ const rules = resolveEffectiveVideoRules({+ videoSettings: { disableComments: false },+ organizationSettings: { disableComments: false },+ spaces: [+ {+ id: "space-1",+ name: "Design",+ settings: { disableComments: true },+ },+ ],+ });++ expect(rules.settings.disableComments).toBe(true);+ expect(rules.inheritedSettings.disableComments).toEqual([+ { id: "space-1", name: "Design" },+ ]);+ });++ it("keeps the inherited setting disabled when multiple spaces conflict", () => {+ const rules = resolveEffectiveVideoRules({+ videoSettings: { disableTranscript: false },+ organizationSettings: { disableTranscript: false },+ spaces: [+ {+ id: "space-1",+ name: "Design",+ settings: { disableTranscript: false },+ },+ {+ id: "space-2",+ name: "Legal",+ settings: { disableTranscript: true },+ },+ ],+ });++ expect(rules.settings.disableTranscript).toBe(true);+ expect(rules.inheritedSettings.disableTranscript).toEqual([+ { id: "space-2", name: "Legal" },+ ]);+ });++ it("uses video settings before organization settings when there is no space rule", () => {+ const rules = resolveEffectiveVideoRules({+ videoSettings: { disableCaptions: false },+ organizationSettings: { disableCaptions: true },+ spaces: [],+ });++ expect(rules.settings.disableCaptions).toBe(false);+ expect(rules.inheritedSettings.disableCaptions).toBeUndefined();+ });++ it("uses organization settings when video settings are unset", () => {+ const rules = resolveEffectiveVideoRules({+ videoSettings: {},+ organizationSettings: { disableSummary: true },+ spaces: [],+ });++ expect(rules.settings.disableSummary).toBe(true);+ });++ it("reports inherited password sources", () => {+ const rules = resolveEffectiveVideoRules({+ videoSettings: {},+ organizationSettings: {},+ spaces: [+ { id: "space-1", name: "Design", hasPassword: true },+ { id: "space-2", name: "Marketing", hasPassword: false },+ ],+ });++ expect(rules.hasInheritedPassword).toBe(true);+ expect(rules.inheritedPasswordSources).toEqual([+ { id: "space-1", name: "Design" },+ ]);+ });+});