Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build:sidecar": "node ../../scripts/build-cap-muxer.mjs",
"preparescript": "node scripts/prepare.js",
"localdev": "dotenv -e ../../.env -- vinxi dev --port 3002",
"test": "vitest run",
"build": "vinxi build",
"tauri": "tauri",
"test:memory": "node scripts/desktop-memory-soak.js",
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk-embed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dist"
],
"scripts": {
"test": "vitest run",
"build": "tsup",
"typecheck": "tsc --noEmit"
},
Expand All @@ -39,6 +40,7 @@
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"tsup": "^8.0.0",
"typescript": "^5.7.3"
"typescript": "^5.7.3",
"vitest": "~2.1.9"
}
}
37 changes: 37 additions & 0 deletions packages/sdk-embed/src/vanilla/cap-embed.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { describe, expect, it } from "vitest";
import { createEmbedUrl } from "./cap-embed";

describe("createEmbedUrl", () => {
it("builds a default Cap embed URL with SDK and public-key markers", () => {
const url = new URL(
createEmbedUrl({ videoId: "video-123", publicKey: "pk_test" }),
);

expect(url.origin).toBe("https://cap.so");
expect(url.pathname).toBe("/embed/video-123");
expect(url.searchParams.get("sdk")).toBe("1");
expect(url.searchParams.get("pk")).toBe("pk_test");
});

it("includes autoplay and branding options when provided", () => {
const url = new URL(
createEmbedUrl({
videoId: "video-123",
publicKey: "pk_live",
apiBase: "https://app.example.com",
autoplay: true,
branding: {
logoUrl: "https://cdn.example.com/logo.png",
accentColor: "#ff00aa",
},
}),
);

expect(url.origin).toBe("https://app.example.com");
expect(url.searchParams.get("autoplay")).toBe("1");
expect(url.searchParams.get("logo")).toBe(
"https://cdn.example.com/logo.png",
);
expect(url.searchParams.get("accent")).toBe("#ff00aa");
});
});
4 changes: 3 additions & 1 deletion packages/sdk-recorder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dist"
],
"scripts": {
"test": "vitest run",
"build": "tsup",
"typecheck": "tsc --noEmit"
},
Expand All @@ -35,6 +36,7 @@
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"tsup": "^8.0.0",
"typescript": "^5.7.3"
"typescript": "^5.7.3",
"vitest": "~2.1.9"
}
}
25 changes: 25 additions & 0 deletions packages/sdk-recorder/src/core/mime-types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { getSupportedMimeType } from "./mime-types";

describe("getSupportedMimeType", () => {
afterEach(() => {
vi.unstubAllGlobals();
});

it("returns the first supported preferred MIME type", () => {
vi.stubGlobal("MediaRecorder", {
isTypeSupported: (mimeType: string) =>
mimeType === "video/webm;codecs=vp8,opus",
});

expect(getSupportedMimeType()).toBe("video/webm;codecs=vp8,opus");
});

it("returns an empty string when the browser supports none of the preferred types", () => {
vi.stubGlobal("MediaRecorder", {
isTypeSupported: () => false,
});

expect(getSupportedMimeType()).toBe("");
});
});
4 changes: 3 additions & 1 deletion packages/sdk-recorder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export class CapRecorder {
const set = this.listeners.get(event);
if (set) set.add(handler as EventHandler<keyof RecorderEventMap>);
return () => {
this.listeners.get(event)?.delete(handler);
this.listeners
.get(event)
?.delete(handler as EventHandler<keyof RecorderEventMap>);
};
}

Expand Down
4 changes: 3 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
".": "./src/index.ts"
},
"scripts": {
"test": "vitest run",
"typecheck": "tsc -b",
"build": "tsdown"
},
Expand All @@ -16,7 +17,8 @@
"react-dom": "^19.1.1",
"react-router-dom": "^6.18.0",
"tsconfig": "workspace:*",
"typescript": "^5.8.3"
"typescript": "^5.8.3",
"vitest": "~2.1.9"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.485.0",
Expand Down
56 changes: 56 additions & 0 deletions packages/utils/src/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { describe, expect, it } from "vitest";
import {
calculateStrokeDashoffset,
classNames,
getDisplayProgress,
getProgressCircleConfig,
isEmailAllowedByRestriction,
uuidFormat,
uuidParse,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing vitest.config.ts across new packages

None of the four new packages (@cap/utils, @cap/sdk-embed, @cap/sdk-recorder, @cap/web-domain) ship a vitest.config.ts. Vitest will fall back to its built-in defaults, which works here because all test imports use relative paths and no DOM environment is required. However, without an explicit config the tsconfig path aliases (if any are added later) won't be resolved, and the test environment can't be pinned — making the setup fragile as coverage grows. The existing apps/desktop/vitest.config.ts is a handy reference for what a minimal config looks like.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/utils/src/helpers.test.ts
Line: 1-9

Comment:
**Missing `vitest.config.ts` across new packages**

None of the four new packages (`@cap/utils`, `@cap/sdk-embed`, `@cap/sdk-recorder`, `@cap/web-domain`) ship a `vitest.config.ts`. Vitest will fall back to its built-in defaults, which works here because all test imports use relative paths and no DOM environment is required. However, without an explicit config the `tsconfig` path aliases (if any are added later) won't be resolved, and the test environment can't be pinned — making the setup fragile as coverage grows. The existing `apps/desktop/vitest.config.ts` is a handy reference for what a minimal config looks like.

How can I resolve this? If you propose a fix, please make it concise.

} from "./helpers";

describe("helpers", () => {
it("merges conditional class names and resolves Tailwind conflicts", () => {
expect(classNames("p-2", false && "hidden", "p-4", ["text-sm"])).toBe(
"p-4 text-sm",
);
});

it("round-trips UUIDs between dashed and compact forms", () => {
const dashed = "123e4567-e89b-12d3-a456-426614174000";
const compact = "123e4567e89b12d3a456426614174000";

expect(uuidParse(dashed)).toBe(compact);
expect(uuidFormat(compact)).toBe(dashed);
});

it("keeps zero upload progress as the displayed progress", () => {
expect(getDisplayProgress(0, 75)).toBe(0);
expect(getDisplayProgress(undefined, 75)).toBe(75);
});

it("calculates circular progress stroke offsets", () => {
const { circumference } = getProgressCircleConfig();

expect(calculateStrokeDashoffset(0, circumference)).toBe(circumference);
expect(calculateStrokeDashoffset(100, circumference)).toBe(0);
});

it("allows exact emails and domain restrictions case-insensitively", () => {
expect(
isEmailAllowedByRestriction(
"Founders@Cap.so",
"team@example.com, cap.so",
),
).toBe(true);
expect(
isEmailAllowedByRestriction(
"team@example.com",
"team@example.com, cap.so",
),
).toBe(true);
expect(
isEmailAllowedByRestriction("team@other.com", "team@example.com, cap.so"),
).toBe(false);
});
});
4 changes: 3 additions & 1 deletion packages/web-domain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"main": "./dist/index.js"
},
"scripts": {
"test": "vitest run",
"build": "tsdown",
"generate-openapi": "node scripts/generate-openapi.ts"
},
Expand All @@ -18,6 +19,7 @@
"effect": "^3.18.4"
},
"devDependencies": {
"@effect/platform-node": "^0.98.3"
"@effect/platform-node": "^0.98.3",
"vitest": "~2.1.9"
}
}
28 changes: 28 additions & 0 deletions packages/web-domain/src/Policy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Cause, Effect, Option } from "effect";
import { describe, expect, it } from "vitest";
import { publicPolicy, withPublicPolicy } from "./Policy";

describe("publicPolicy", () => {
it("allows an effect when the public predicate succeeds", async () => {
const result = await Effect.runPromise(
Effect.succeed("allowed").pipe(
withPublicPolicy(
publicPolicy((user) => Effect.succeed(Option.isNone(user))),
),
),
);

expect(result).toBe("allowed");
});

it("fails with PolicyDeniedError when the public predicate denies access", async () => {
const exit = await Effect.runPromiseExit(
publicPolicy(() => Effect.succeed(false)),
);

expect(exit._tag).toBe("Failure");
if (exit._tag === "Failure") {
expect(Cause.pretty(exit.cause)).toContain("PolicyDenied");
}
});
});
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.