@crazx/dsh-client-test-runtime 0.1.5-alpha.1.zw.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,83 @@
1
+ /** Test double for the `settings` Remote namespace a bench's plugins inject. */
2
+ import { vi } from 'vitest';
3
+ /** The minimum a scripted namespace view carries for the double's own bookkeeping. */
4
+ export interface ScriptedNamespace {
5
+ /** Namespace key the write addresses. */
6
+ ns: string;
7
+ }
8
+ /** One scripted `settings` namespace face plus the controls a bench drives it with. */
9
+ export interface ScriptedSettingsRemote<View extends ScriptedNamespace> {
10
+ /**
11
+ * The namespace face handed to `TestRemote` as `settings`. A plugin injecting
12
+ * `remote.settings` unparks on it, which is what most benches need; the
13
+ * describe answer is the same one the shared mirror would read.
14
+ */
15
+ settings: {
16
+ describe(): Promise<{
17
+ ok: true;
18
+ value: {
19
+ writable: boolean;
20
+ hasDocument: boolean;
21
+ namespaces: readonly View[];
22
+ };
23
+ }>;
24
+ update(ns: string, patch: unknown, expectedRevision: number | undefined): Promise<{
25
+ ok: true;
26
+ value: View;
27
+ } | {
28
+ ok: false;
29
+ error: {
30
+ code: string;
31
+ message: string;
32
+ details: object;
33
+ };
34
+ }>;
35
+ replace(ns: string, section: unknown, expectedRevision: number | undefined): Promise<{
36
+ ok: true;
37
+ value: View;
38
+ } | {
39
+ ok: false;
40
+ error: {
41
+ code: string;
42
+ message: string;
43
+ details: object;
44
+ };
45
+ }>;
46
+ mutate(ns: string, ops: unknown, expectedRevision: number | undefined): Promise<{
47
+ ok: true;
48
+ value: View;
49
+ } | {
50
+ ok: false;
51
+ error: {
52
+ code: string;
53
+ message: string;
54
+ details: object;
55
+ };
56
+ }>;
57
+ };
58
+ /** Spy behind `settings.update`, for argument assertions. */
59
+ update: ReturnType<typeof vi.fn>;
60
+ /** Spy behind `settings.replace`, for argument assertions. */
61
+ replace: ReturnType<typeof vi.fn>;
62
+ /** Spy behind `settings.mutate`, for argument assertions. */
63
+ mutate: ReturnType<typeof vi.fn>;
64
+ /**
65
+ * Replace what the next describe answers with, as a Host commit would.
66
+ * @param namespaces - the namespace views to serve from now on.
67
+ */
68
+ publish(namespaces: readonly View[]): void;
69
+ }
70
+ /**
71
+ * Build a scripted `settings` Remote namespace for a bench. Each write answers
72
+ * with the addressed namespace unchanged, so a bench that only needs its
73
+ * plugins to activate scripts nothing; one asserting a write reads the
74
+ * corresponding spy or replaces the face.
75
+ * @param namespaces - namespace views the first describe answers with.
76
+ * @param options - deployment facts the describe answer reports.
77
+ * @returns the face and its controls.
78
+ */
79
+ export declare function scriptedSettingsRemote<View extends ScriptedNamespace>(namespaces?: readonly View[], options?: {
80
+ writable?: boolean;
81
+ hasDocument?: boolean;
82
+ }): ScriptedSettingsRemote<View>;
83
+ //# sourceMappingURL=settings-remote.d.ts.map
@@ -0,0 +1,29 @@
1
+ /** Test double for the client settings-scope seam. */
2
+ import { vi } from 'vitest';
3
+ import type { SettingsScope, SettingsScopeSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client';
4
+ /** Handle over one stubbed scope: the scope, its write spy, and publication controls. */
5
+ export interface StubSettingsScope<T> {
6
+ /** The scope face handed to the service under test. */
7
+ scope: SettingsScope<T>;
8
+ /** Spy behind `scope.set`; resolves immediately. */
9
+ set: ReturnType<typeof vi.fn>;
10
+ /** Spy behind `scope.mutate`; resolves immediately. */
11
+ mutate: ReturnType<typeof vi.fn>;
12
+ /** Spy behind `scope.unset`; resolves immediately. */
13
+ unset: ReturnType<typeof vi.fn>;
14
+ /** @returns how many listeners are currently subscribed (disposal assertions). */
15
+ listenerCount(): number;
16
+ /**
17
+ * Replace part of the snapshot and notify subscribers, as a Host
18
+ * acceptance would.
19
+ * @param next - snapshot fields to replace.
20
+ */
21
+ publish(next: Partial<SettingsScopeSnapshot<T>>): void;
22
+ }
23
+ /**
24
+ * Build an in-memory settings scope for service specs: starts in the host
25
+ * loading state, records writes, and lets the test publish Host acceptances.
26
+ * @returns the stub handle.
27
+ */
28
+ export declare function stubSettingsScope<T>(): StubSettingsScope<T>;
29
+ //# sourceMappingURL=settings-scope.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { SnapshotSerializer } from 'vitest';
2
+ /**
3
+ * The serializer plugin. Matches DOM elements whose subtree carries a scoped
4
+ * class or svg internals; serializes a normalized clone, which no longer
5
+ * matches, so printing falls through to the built-in DOM element serializer.
6
+ */
7
+ export declare const domSnapshotSerializer: SnapshotSerializer;
8
+ /**
9
+ * Register {@link domSnapshotSerializer} with vitest's expect (idempotent).
10
+ * SlotTestRuntime.create() calls this; specs that snapshot DOM outside the
11
+ * runtime import and call it themselves.
12
+ */
13
+ export declare function registerDomSnapshotSerializer(): void;
14
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Test double of the locale lookup chain: a translate stub over plain
3
+ * dictionaries, mirroring LocaleRuntime's resolution order (first dictionary
4
+ * that owns the key wins, then the key itself stays visible) and its
5
+ * `{name}` template interpolation. Specs stub the framework-injected `t`
6
+ * seat with `makeTranslate(zh, commonZh)` instead of re-implementing the
7
+ * chain per suite.
8
+ */
9
+ /**
10
+ * Build a translate stub resolving through `dicts` in order (namespace
11
+ * first, then the shared common vocabulary), falling back to the key.
12
+ * @param dicts - dictionaries consulted in order.
13
+ * @returns the translate function (assignable to any `XxxProps['t']` seat).
14
+ */
15
+ export declare function makeTranslate(...dicts: readonly Record<string, string>[]): (key: string, params?: Record<string, unknown>) => string;
16
+ //# sourceMappingURL=translate.d.ts.map
@@ -0,0 +1,89 @@
1
+ import type { IWorkspaces, WorkspaceId, WorkspaceSnapshot, WorkspaceView } from '@deepseek-ai/dsh-api-workspace-controller/client';
2
+ import type { SessionId } from '@deepseek-ai/dsh-session/types';
3
+ import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
4
+ import type { FixtureSnapshot, Stabilizer } from './fixtures.ts';
5
+ /** Writable test representation of the immutable Workspace Controller snapshot. */
6
+ type WorkspaceFixtureSnapshot = FixtureSnapshot<WorkspaceSnapshot>;
7
+ /** Callable command names on the production Workspace Controller face. */
8
+ type WorkspaceAction = {
9
+ [Key in keyof IWorkspaces]: IWorkspaces[Key] extends (...args: never[]) => unknown ? Key : never;
10
+ }[keyof IWorkspaces];
11
+ /** Test replacement retaining one Controller command's parameters and result. */
12
+ type WorkspaceStub<Key extends WorkspaceAction> = (...args: Parameters<IWorkspaces[Key]>) => ReturnType<IWorkspaces[Key]>;
13
+ /**
14
+ * Workspaces test double. Implements the same IWorkspaces face features
15
+ * receive as `ctx.workspaces`, so a production face change breaks this
16
+ * double at compile time. Every action records into {@link
17
+ * TestWorkspaces.calls}; defaults are inert echoes — feature tests needing
18
+ * richer behavior replace them via {@link TestWorkspaces.stub}.
19
+ */
20
+ export declare class TestWorkspaces implements IWorkspaces {
21
+ private readonly stabilize;
22
+ /** The useWorkspaces standard feed. */
23
+ readonly list: SnapshotStore<WorkspaceFixtureSnapshot>;
24
+ /** Calls observed on the action face, newest last. */
25
+ readonly calls: {
26
+ method: string;
27
+ args: unknown[];
28
+ }[];
29
+ /** Replaceable action seat: feature tests may stub richer behavior. */
30
+ private readonly stubs;
31
+ /**
32
+ * @param stabilize - the owning runtime's act wrapper.
33
+ */
34
+ constructor(stabilize: Stabilizer);
35
+ /**
36
+ * Update the workspace list state through an immer draft.
37
+ * @param mutate - draft mutator.
38
+ */
39
+ update(mutate: (draft: WorkspaceFixtureSnapshot) => void): Promise<void>;
40
+ /**
41
+ * Replace an action's behavior (the recorded call is still appended first).
42
+ * @param method - Controller action name (e.g. 'create').
43
+ * @param impl - replacement behavior.
44
+ */
45
+ stub<Key extends WorkspaceAction>(method: Key, impl: WorkspaceStub<Key>): void;
46
+ /**
47
+ * Create a Workspace (recorded). The default echoes a view derived from
48
+ * the input; stub for failure or list-coupled flows.
49
+ * @param input - the Host create payload.
50
+ * @returns the created Workspace view.
51
+ */
52
+ create(input: {
53
+ path: string;
54
+ }): Promise<WorkspaceView>;
55
+ /**
56
+ * Rename a Workspace (recorded). The default echoes a minimal view.
57
+ * @param workspaceId - target workspace.
58
+ * @param title - new title.
59
+ * @returns the updated view.
60
+ */
61
+ rename(workspaceId: WorkspaceId, title: string): Promise<WorkspaceView>;
62
+ /**
63
+ * Delete a Workspace (recorded; default no-op).
64
+ * @param workspaceId - target workspace.
65
+ */
66
+ delete(workspaceId: WorkspaceId): Promise<void>;
67
+ /**
68
+ * Move a Workspace in display order (recorded; default no-op).
69
+ * @param workspaceId - Workspace to move.
70
+ * @param beforeWorkspaceId - Anchor; omitted appends.
71
+ */
72
+ insertBefore(workspaceId: WorkspaceId, beforeWorkspaceId?: WorkspaceId): Promise<void>;
73
+ /**
74
+ * Move an accounted session (recorded). The default echoes a minimal view.
75
+ * @param workspaceId - target workspace.
76
+ * @param sessionId - session to move.
77
+ * @param beforeSessionId - anchor; omitted appends.
78
+ * @returns the updated view.
79
+ */
80
+ insertSessionBefore(workspaceId: WorkspaceId, sessionId: SessionId, beforeSessionId?: SessionId): Promise<WorkspaceView>;
81
+ /**
82
+ * Archive a session (recorded). The default mirrors the production face's
83
+ * observable effect: the id joins the list state's archive set.
84
+ * @param sessionId - session to archive.
85
+ */
86
+ archiveSession(sessionId: SessionId): Promise<void>;
87
+ }
88
+ export {};
89
+ //# sourceMappingURL=workspaces.d.ts.map
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@crazx/dsh-client-test-runtime",
3
+ "description": "jsdom slot test runtime: real Cordis Context + SlotRegistry + UI renderer with test-owned session/workspace doubles for feature specs",
4
+ "version": "0.1.5-alpha.1.zw.3",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/aka-danielZhang/deepseek-harness.git",
11
+ "directory": "packages/test-support/client-runtime"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./src/*": "./src/*",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "license": "MIT",
25
+ "dependencies": {
26
+ "@testing-library/dom": "^10.4.1",
27
+ "@testing-library/react": "^16.3.2",
28
+ "vitest": "^4.1.8"
29
+ },
30
+ "peerDependencies": {
31
+ "@deepseek-ai/dsh-api-session-controller": "npm:@crazx/dsh-api-session-controller@0.1.5-alpha.1.zw.3",
32
+ "@deepseek-ai/dsh-api-workspace-controller": "^0.1.5-alpha.1",
33
+ "@deepseek-ai/dsh-attachment": "^0.1.5-alpha.1",
34
+ "@deepseek-ai/dsh-client-connection": "^0.1.5-alpha.1",
35
+ "@deepseek-ai/dsh-client-store": "^0.1.5-alpha.1",
36
+ "@deepseek-ai/dsh-client-ui-chat": "^0.1.5-alpha.1",
37
+ "@deepseek-ai/dsh-client-ui-conversation": "npm:@crazx/dsh-client-ui-conversation@0.1.5-alpha.1.zw.3",
38
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.1.5-alpha.1",
39
+ "@deepseek-ai/dsh-client-ui-session": "^0.1.5-alpha.1",
40
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.5-alpha.1",
41
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.5-alpha.1",
42
+ "@deepseek-ai/dsh-session": "^0.1.5-alpha.1",
43
+ "@deepseek-ai/dsh-subagent": "^0.1.5-alpha.1",
44
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.5-alpha.1",
45
+ "@deepseek-ai/cordis": "^4.0.2",
46
+ "react": "^18.2.0",
47
+ "react-dom": "^18.2.0"
48
+ },
49
+ "devDependencies": {
50
+ "@deepseek-ai/dsh-api-session-controller": "npm:@crazx/dsh-api-session-controller@0.1.5-alpha.1.zw.3",
51
+ "@deepseek-ai/dsh-api-workspace-controller": "^0.1.5-alpha.1",
52
+ "@deepseek-ai/dsh-attachment": "^0.1.5-alpha.1",
53
+ "@deepseek-ai/dsh-client-connection": "^0.1.5-alpha.1",
54
+ "@deepseek-ai/dsh-client-store": "^0.1.5-alpha.1",
55
+ "@deepseek-ai/dsh-client-ui-chat": "^0.1.5-alpha.1",
56
+ "@deepseek-ai/dsh-client-ui-conversation": "npm:@crazx/dsh-client-ui-conversation@0.1.5-alpha.1.zw.3",
57
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.1.5-alpha.1",
58
+ "@deepseek-ai/dsh-client-ui-session": "^0.1.5-alpha.1",
59
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.5-alpha.1",
60
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.5-alpha.1",
61
+ "@deepseek-ai/dsh-session": "^0.1.5-alpha.1",
62
+ "@deepseek-ai/dsh-subagent": "^0.1.5-alpha.1",
63
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.5-alpha.1",
64
+ "@types/react": "~18.3.1",
65
+ "@types/react-dom": "~18.3.0",
66
+ "@deepseek-ai/cordis": "^4.0.2",
67
+ "react": "^18.2.0",
68
+ "react-dom": "^18.2.0"
69
+ },
70
+ "files": [
71
+ "lib/index.js",
72
+ "lib/types/**/*.d.ts"
73
+ ]
74
+ }