Open History to see the last commit
1import { DEFAULT_SERVER_SETTINGS, EnvironmentId, ProjectId } from "@t3tools/contracts";
2import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
3import { describe, expect, it } from "vite-plus/test";
4
5import { settingInheritanceLayers } from "./SettingInheritance";
6
7const environmentId = EnvironmentId.make("laptop");
8const projectId = ProjectId.make("project");
9
10describe("settingInheritanceLayers", () => {
11 it("shows the checkout's t3.json as a layer for file-backed keys", () => {
12 const file = { defaultThreadEnvMode: "worktree" as const };
13 const fromFile = settingInheritanceLayers(
14 {
15 environmentId,
16 label: "Laptop",
17 projectId,
18 ...resolveProjectSettings(DEFAULT_SERVER_SETTINGS, projectId, null, file),
19 },
20 DEFAULT_SERVER_SETTINGS,
21 "defaultThreadEnvMode",
22 );
23 expect(fromFile.map((layer) => [layer.label, layer.value, layer.effective])).toEqual([
24 ["Project", "Inherits", false],
25 ["Laptop", "Inherits", false],
26 ["t3.json", "New worktree", true],
27 ["Default", "Current checkout", false],
28 ]);
29 const settings = { ...DEFAULT_SERVER_SETTINGS, defaultThreadEnvMode: "local" as const };
30 const fromEnvironment = settingInheritanceLayers(
31 {
32 environmentId,
33 label: "Laptop",
34 projectId,
35 ...resolveProjectSettings(settings, projectId, null, file),
36 },
37 settings,
38 "defaultThreadEnvMode",
39 );
40 expect(fromEnvironment.map((layer) => [layer.value, layer.effective])).toEqual([
41 ["Inherits", false],
42 ["Current checkout", true],
43 ["Inherits", false],
44 ["Current checkout", false],
45 ]);
46 });
47});