Skip to content
Open
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
23 changes: 23 additions & 0 deletions apps/chrome-extension/src/shared/webrtc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,26 @@ describe("waitForIceGatheringComplete", () => {
);
});
});

describe("toSessionDescriptionInit", () => {
it("formats valid RTCSessionDescription to RTCSessionDescriptionInit", async () => {
const { toSessionDescriptionInit } = await import("./webrtc");
const desc = {
type: "offer" as RTCSdpType,
sdp: "v=0\r\no=- 123456 2 IN IP4 127.0.0.1\r\n",
toJSON: () => ({}),
};
expect(toSessionDescriptionInit(desc as RTCSessionDescription)).toEqual({
type: "offer",
sdp: "v=0\r\no=- 123456 2 IN IP4 127.0.0.1\r\n",
});
});

it("throws error when session description is null or undefined", async () => {

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 Test title overstates coverage

The test claims to cover both null and undefined, but its only invocation passes null; this makes the suite report an invalid-input case as covered when it is not exercised.

Suggested change
it("throws error when session description is null or undefined", async () => {
it("throws error when session description is null", async () => {
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/chrome-extension/src/shared/webrtc.test.ts
Line: 68

Comment:
**Test title overstates coverage**

The test claims to cover both `null` and `undefined`, but its only invocation passes `null`; this makes the suite report an invalid-input case as covered when it is not exercised.

```suggestion
	it("throws error when session description is null", async () => {
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

const { toSessionDescriptionInit } = await import("./webrtc");
expect(() => toSessionDescriptionInit(null)).toThrow(
"Missing session description",
);
});
});

31 changes: 31 additions & 0 deletions packages/recorder-core/__tests__/recorder-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,34 @@ describe("openShareUrlInNewTab", () => {
expect(openShareUrlInNewTab("")).toBe(false);
});
});

describe("detectRecordingModeFromTrack", () => {
it("returns null when track is null", async () => {
const { detectRecordingModeFromTrack } = await import(
"@cap/recorder-core/recorder-utils"
);
expect(detectRecordingModeFromTrack(null)).toBeNull();
});

it("detects fullscreen, window, and tab from track label heuristics", async () => {
const { detectRecordingModeFromTrack } = await import(
"@cap/recorder-core/recorder-utils"
);
const screenTrack = {
label: "Entire Screen 1",
getSettings: () => ({}),
} as unknown as MediaStreamTrack;
const windowTrack = {
label: "Application Window (Cap)",
getSettings: () => ({}),
} as unknown as MediaStreamTrack;
const tabTrack = {
label: "Browser Tab - YouTube",
getSettings: () => ({}),
} as unknown as MediaStreamTrack;

expect(detectRecordingModeFromTrack(screenTrack)).toBe("fullscreen");
expect(detectRecordingModeFromTrack(windowTrack)).toBe("window");
expect(detectRecordingModeFromTrack(tabTrack)).toBe("tab");
});
});