Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

browserProfile.test.ts

44 lines1.3 KB

1import { describe, expect, it } from "@effect/vitest";
2​
3import {
4 BUILT_IN_BROWSER_PROFILES,
5 DEFAULT_BROWSER_PROFILE_ID,
6 INCOGNITO_BROWSER_PROFILE_ID,
7 findBrowserProfile,
8 resolveBrowserProfiles,
9 type BrowserProfile,
10} from "./browserProfile.ts";
11​
12const work: BrowserProfile = { id: "profile-work", name: "Work", kind: "persistent" };
13​
14describe("resolveBrowserProfiles", () => {
15 it("drops stored entries that collide with a built-in id", () => {
16 const resolved = resolveBrowserProfiles([
17 { id: DEFAULT_BROWSER_PROFILE_ID, name: "Hijacked", kind: "persistent" },
18 { id: INCOGNITO_BROWSER_PROFILE_ID, name: "Not incognito", kind: "persistent" },
19 work,
20 ]);
21​
22 expect(resolved).toEqual([...BUILT_IN_BROWSER_PROFILES, work]);
23 });
24​
25 it("keeps incognito ephemeral", () => {
26 const incognito = findBrowserProfile(resolveBrowserProfiles([]), INCOGNITO_BROWSER_PROFILE_ID);
27​
28 expect(incognito?.kind).toBe("incognito");
29 });
30});
31​
32describe("resolveBrowserProfiles normalization", () => {
33 it("reports a custom incognito profile as persistent", () => {
34 const resolved = resolveBrowserProfiles([
35 { id: "throwaway", name: "Throwaway", kind: "incognito" },
36 ]);
37​
38 expect(resolved.find((profile) => profile.id === "throwaway")).toEqual({
39 id: "throwaway",
40 name: "Throwaway",
41 kind: "persistent",
42 });
43 });
44});