Skip to content

Commit 31a5b00

Browse files
committed
fix(web): brand environment ids in the New Chat grouping fixture
1 parent 16f0fbb commit 31a5b00

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

‎apps/web/src/hooks/useHandleNewThread.test.ts‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it, vi } from "vite-plus/test";
2-
import type { RuntimeMode } from "@t3tools/contracts";
2+
import { EnvironmentId, ProjectId, type RuntimeMode } from "@t3tools/contracts";
33

44
const testState = vi.hoisted(() => {
55
let completeProjectFileRead: (value: null) => void = () => undefined;
@@ -259,17 +259,31 @@ import { derivePhysicalProjectKey } from "../logicalProject";
259259
import { buildPhysicalToLogicalProjectKeyMap } from "../sidebarProjectGrouping";
260260
import { useNewThreadHandler } from "./useHandleNewThread";
261261

262+
const groupingSettings = {
263+
sidebarProjectGroupingMode: "repository" as const,
264+
sidebarProjectGroupingOverrides: {},
265+
};
266+
262267
/** Logical key New Chat should register: the group key from `buildProjectGroups`, not a re-derivation. */
263268
function expectedLogicalProjectKey(project: {
264269
environmentId: string;
265270
workspaceRoot: string;
266271
}): string {
267272
return (
268273
buildPhysicalToLogicalProjectKeyMap({
269-
projects: testState.projects,
270-
settings: {},
271-
primaryEnvironmentId: "environment-primary",
272-
}).get(derivePhysicalProjectKey(project)) ?? "remote-project"
274+
projects: testState.projects.map((entry) => ({
275+
...entry,
276+
id: ProjectId.make(entry.id),
277+
environmentId: EnvironmentId.make(entry.environmentId),
278+
})),
279+
settings: groupingSettings,
280+
primaryEnvironmentId: EnvironmentId.make("environment-primary"),
281+
}).get(
282+
derivePhysicalProjectKey({
283+
environmentId: EnvironmentId.make(project.environmentId),
284+
workspaceRoot: project.workspaceRoot,
285+
}),
286+
) ?? "remote-project"
273287
);
274288
}
275289

0 commit comments

Comments
 (0)