Skip to content

Commit 7370091

Browse files
author
Eva
committed
fix(workspaces): type Control Hub fixtures
1 parent b7f97ac commit 7370091

2 files changed

Lines changed: 23 additions & 12 deletions

File tree

ui/src/pages/plugin/workspace-view.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expectDefined } from "@openclaw/normalization-core";
12
import { render } from "lit";
23
import { afterEach, describe, expect, it, vi } from "vitest";
34
import type { GatewayBrowserClient } from "../../api/gateway.ts";
@@ -114,8 +115,11 @@ describe("renderWorkspace", () => {
114115
state.workspace = {
115116
...doc,
116117
tabs: [
117-
{ ...doc.tabs[0], createdBy: "user" },
118-
{ ...doc.tabs[2], createdBy: "agent:finance" },
118+
{ ...expectDefined(doc.tabs[0], "main workspace tab fixture"), createdBy: "user" },
119+
{
120+
...expectDefined(doc.tabs[2], "empty workspace tab fixture"),
121+
createdBy: "agent:finance",
122+
},
119123
],
120124
prefs: { tabOrder: ["main", "empty"] },
121125
};

ui/src/pages/teams/teams-portal.test.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,21 @@ import {
1212
renderTeamsPortal,
1313
TeamsPortalStore,
1414
type TeamsPortalGateway,
15+
type TeamsPortalSnapshot,
1516
} from "./teams-portal.ts";
1617

18+
type TeamsPortalGatewayMock = TeamsPortalGateway & {
19+
request: ReturnType<typeof vi.fn>;
20+
stop: ReturnType<typeof vi.fn>;
21+
};
22+
23+
type TeamsPortalPresenceParticipant = NonNullable<TeamsPortalSnapshot["presence"]>[number];
24+
25+
const portalPresence: TeamsPortalPresenceParticipant[] = [
26+
{ id: "ada", kind: "human", self: true },
27+
{ id: "review-agent", kind: "agent", self: false },
28+
];
29+
1730
function authenticatedSession(expiresAt = Date.now() + 60_000) {
1831
return {
1932
authenticated: true as const,
@@ -28,10 +41,7 @@ function tabResult(mode: "read" | "request" | "write" = "read") {
2841
workspaceId: "workspace-1",
2942
workspaceVersion: 8,
3043
capabilityMode: mode,
31-
presence: [
32-
{ id: "ada", kind: "human", self: true },
33-
{ id: "review-agent", kind: "agent", self: false },
34-
],
44+
presence: portalPresence,
3545
tab: {
3646
id: "tab-1",
3747
revision: 4,
@@ -43,10 +53,7 @@ function tabResult(mode: "read" | "request" | "write" = "read") {
4353
};
4454
}
4555

46-
function createGateway(response = tabResult()): TeamsPortalGateway & {
47-
request: ReturnType<typeof vi.fn>;
48-
stop: ReturnType<typeof vi.fn>;
49-
} {
56+
function createGateway(response = tabResult()): TeamsPortalGatewayMock {
5057
return {
5158
request: vi.fn(async () => response),
5259
stop: vi.fn(),
@@ -247,8 +254,8 @@ describe("Teams portal store", () => {
247254
const pendingPresence = new Promise<ReturnType<typeof tabResult>>((resolve) => {
248255
resolvePresence = resolve;
249256
});
250-
const gateway = {
251-
request: vi.fn((method: string) => {
257+
const gateway: TeamsPortalGatewayMock = {
258+
request: vi.fn((method?: string) => {
252259
if (method === "workspaces.tab.get") {
253260
tabReads += 1;
254261
return tabReads === 1 ? Promise.resolve(tabResult()) : pendingPresence;

0 commit comments

Comments
 (0)