@capybara-hq/testing 0.1.0-rc.13 → 0.1.0-rc.14

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.
@@ -18,9 +18,11 @@
18
18
  * | `fake-dep-provider` / `fake-dep-requirer` | a dependency pair on `counter@1` (the requirer's plugin.json depends on the provider) |
19
19
  * | `fake-im` | a whole IM platform for `startFakeChannelServer`: `channel@1` (cards, edits, threads, webhook inbound), `identity-source@1`, `directory@1` (org config `url` of a directory book) and tool `post_announcement` (default policy ask, posts to the platform); deployment config `platformUrl`, `tenant`, `clientId`, secret `clientSecret`. Its `src/index.ts` also exports `makeFakeImChannel`, `fakeImIdentitySource`, `fakeImDirectory` for test extensions that need one part |
20
20
  * | `fake-web` / `fake-web-2` | `web-search@1` and `web-fetch@1`, scripted by a prefix of the query or of the fetched URL's path (`error:<kind>`, `throw:`, `hang:`, `redirect:<url>`, `junk:`, `empty:`, `big:<n>`; see `makeFakeWeb`); results name the provider; org config secret `token`, `configured()` iff it is set (throws for `throw:configured`); calls recorded on `globalThis.__fakeWeb` (`fakeWebProbe`) |
21
+ * | `fake-client` | client extension (`permissions.client`, no extension point): components `hud` (`conversation.properties.section`, server view with `data`), `brand` (`shell.brand`, renders `builtin` in `data-testid="fake-client-brand"`), `empty` (`conversation.empty`), `frame` (`conversation.composer.frame`) and `fx` (`shell.overlay`); `client/styles/fake.css` (outline-color on `button.primary` and the composer's buttons, `--cx-fake-client-run` while `run=running`); an `events` listener storing the last event type; theme `fake`; `suggestedAppearance` = theme `fake` + `shell.brand` -> `brand` |
22
+ * | `fake-client-broken` | client code that throws: component `boom` (render), a `run.started` events listener, and a `conversation.empty` replacement (render) |
21
23
  * | `fake-config-form` | display name 表单样例 / Form sample; no extension point: an openai-compatible-shaped deployment config (endpoints with a preset menu, an API key per endpoint in the secret record `apiKeys`, model rows, advanced fields, localized custom issues) carrying the config form hints of the extension config forms spec §6, for the web form e2e |
22
24
  */
23
- export declare const FAKE_EXTENSIONS: readonly ["fake-connector", "fake-openapi", "fake-object-store", "fake-tools-ui", "fake-storage-user", "fake-embed", "fake-bootstrap-a", "fake-bootstrap-b", "fake-dep-provider", "fake-dep-requirer", "fake-im", "fake-web", "fake-web-2", "fake-config-form"];
25
+ export declare const FAKE_EXTENSIONS: readonly ["fake-connector", "fake-openapi", "fake-object-store", "fake-tools-ui", "fake-storage-user", "fake-embed", "fake-bootstrap-a", "fake-bootstrap-b", "fake-dep-provider", "fake-dep-requirer", "fake-im", "fake-web", "fake-web-2", "fake-config-form", "fake-client", "fake-client-broken"];
24
26
  /**
25
27
  * Fake plugins without an extension (declarative: they live in `fixtures/plugins/<name>`, same
26
28
  * pack layout).
package/dist/fixtures.js CHANGED
@@ -21,6 +21,8 @@ import { fileURLToPath } from "node:url";
21
21
  * | `fake-dep-provider` / `fake-dep-requirer` | a dependency pair on `counter@1` (the requirer's plugin.json depends on the provider) |
22
22
  * | `fake-im` | a whole IM platform for `startFakeChannelServer`: `channel@1` (cards, edits, threads, webhook inbound), `identity-source@1`, `directory@1` (org config `url` of a directory book) and tool `post_announcement` (default policy ask, posts to the platform); deployment config `platformUrl`, `tenant`, `clientId`, secret `clientSecret`. Its `src/index.ts` also exports `makeFakeImChannel`, `fakeImIdentitySource`, `fakeImDirectory` for test extensions that need one part |
23
23
  * | `fake-web` / `fake-web-2` | `web-search@1` and `web-fetch@1`, scripted by a prefix of the query or of the fetched URL's path (`error:<kind>`, `throw:`, `hang:`, `redirect:<url>`, `junk:`, `empty:`, `big:<n>`; see `makeFakeWeb`); results name the provider; org config secret `token`, `configured()` iff it is set (throws for `throw:configured`); calls recorded on `globalThis.__fakeWeb` (`fakeWebProbe`) |
24
+ * | `fake-client` | client extension (`permissions.client`, no extension point): components `hud` (`conversation.properties.section`, server view with `data`), `brand` (`shell.brand`, renders `builtin` in `data-testid="fake-client-brand"`), `empty` (`conversation.empty`), `frame` (`conversation.composer.frame`) and `fx` (`shell.overlay`); `client/styles/fake.css` (outline-color on `button.primary` and the composer's buttons, `--cx-fake-client-run` while `run=running`); an `events` listener storing the last event type; theme `fake`; `suggestedAppearance` = theme `fake` + `shell.brand` -> `brand` |
25
+ * | `fake-client-broken` | client code that throws: component `boom` (render), a `run.started` events listener, and a `conversation.empty` replacement (render) |
24
26
  * | `fake-config-form` | display name 表单样例 / Form sample; no extension point: an openai-compatible-shaped deployment config (endpoints with a preset menu, an API key per endpoint in the secret record `apiKeys`, model rows, advanced fields, localized custom issues) carrying the config form hints of the extension config forms spec §6, for the web form e2e |
25
27
  */
26
28
  export const FAKE_EXTENSIONS = [
@@ -38,6 +40,8 @@ export const FAKE_EXTENSIONS = [
38
40
  "fake-web",
39
41
  "fake-web-2",
40
42
  "fake-config-form",
43
+ "fake-client",
44
+ "fake-client-broken",
41
45
  ];
42
46
  /**
43
47
  * Fake plugins without an extension (declarative: they live in `fixtures/plugins/<name>`, same
@@ -0,0 +1,11 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "name": "fake-client",
4
+ "version": "0.1.0",
5
+ "publisher": "Capybara",
6
+ "description": "Test fake: client extension components in five slots, CSS decoration, an events listener and a suggested appearance",
7
+ "suggestedAppearance": {
8
+ "theme": "fake",
9
+ "replacements": { "shell.brand": "brand" }
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ [data-cap-part~="button.primary"] {
2
+ outline-color: rgb(1, 2, 3);
3
+ }
4
+
5
+ [data-cap-part~="composer"] [data-cap-part~="button"] {
6
+ outline-color: rgb(1, 2, 3);
7
+ }
8
+
9
+ [data-cap-state~="run=running"] {
10
+ --cx-fake-client-run: 1;
11
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@capybara-hq/test-plugin-fake-client",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "Test fake: client extension components in five slots, CSS decoration, an events listener and a suggested appearance",
6
+ "license": "Apache-2.0",
7
+ "type": "module",
8
+ "dependencies": {
9
+ "@capybara-hq/plugin-client": "^0.1.0-rc.0",
10
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.0"
11
+ }
12
+ }
@@ -0,0 +1,51 @@
1
+ import {
2
+ defineClientExtension,
3
+ defineComponent,
4
+ useClientStorage,
5
+ useView,
6
+ } from "@capybara-hq/plugin-client";
7
+
8
+ const Hud = () => {
9
+ // useView() is the view state ({ view, status, retry }); the server view's data is on `view`
10
+ const { view } = useView();
11
+ const data = view?.data as { n?: number } | undefined;
12
+ return <span data-testid="fake-client-hud">{`hud ${data?.n ?? "-"}`}</span>;
13
+ };
14
+
15
+ const Brand = ({ builtin }: { builtin: unknown }) => (
16
+ <span data-testid="fake-client-brand">{builtin as never}</span>
17
+ );
18
+
19
+ const Empty = ({ greeting }: { greeting: string }) => (
20
+ <p data-testid="fake-client-empty">{greeting}</p>
21
+ );
22
+
23
+ const Frame = ({ children }: { children?: unknown }) => (
24
+ <div data-testid="fake-client-frame">{children as never}</div>
25
+ );
26
+
27
+ const Fx = () => {
28
+ const storage = useClientStorage();
29
+ return <i data-testid="fake-client-fx" data-last={storage.get("last") ?? ""} />;
30
+ };
31
+
32
+ export default defineClientExtension({
33
+ name: "fake-client",
34
+ components: {
35
+ hud: defineComponent("conversation.properties.section", Hud),
36
+ brand: defineComponent("shell.brand", Brand),
37
+ empty: defineComponent("conversation.empty", Empty),
38
+ frame: defineComponent("conversation.composer.frame", Frame),
39
+ fx: defineComponent("shell.overlay", Fx),
40
+ },
41
+ events: {
42
+ "run.started": (e, api) => api.storage.set("last", e.type),
43
+ "run.finished": (e, api) => api.storage.set("last", e.type),
44
+ "run.failed": (e, api) => api.storage.set("last", e.type),
45
+ "message.sent": (e, api) => api.storage.set("last", e.type),
46
+ "message.received": (e, api) => api.storage.set("last", e.type),
47
+ "tool.started": (e, api) => api.storage.set("last", e.type),
48
+ "tool.finished": (e, api) => api.storage.set("last", e.type),
49
+ "approval.requested": (e, api) => api.storage.set("last", e.type),
50
+ },
51
+ });
@@ -0,0 +1,43 @@
1
+ import { defineExtension, type UiView } from "@capybara-hq/plugin-sdk";
2
+
3
+ const t = (zh: string, en: string) => ({ zh, en });
4
+
5
+ /**
6
+ * Test fake of a client extension (client extensions spec §5): one component in each of
7
+ * `conversation.properties.section` (`hud`, server view answering `data: { n: 1 }`), `shell.brand`
8
+ * (`brand`), `conversation.empty` (`empty`), `conversation.composer.frame` (`frame`) and
9
+ * `shell.overlay` (`fx`). The browser side is `src/client.tsx` (components and an `events`
10
+ * listener), `client/styles/fake.css` decorates by part and state, and the theme `fake` is the
11
+ * plugin's `suggestedAppearance` together with `shell.brand` -> `brand`.
12
+ */
13
+ export default defineExtension({
14
+ name: "fake-client",
15
+ version: "0.1.0",
16
+ sdk: "^0.1.0-rc.0",
17
+ provides: [],
18
+ ui: [
19
+ {
20
+ id: "hud",
21
+ title: t("状态", "Status"),
22
+ slot: "conversation.properties.section",
23
+ kind: "component",
24
+ },
25
+ { id: "brand", title: t("品牌", "Brand"), slot: "shell.brand", kind: "component" },
26
+ { id: "empty", title: t("问候", "Greeting"), slot: "conversation.empty", kind: "component" },
27
+ {
28
+ id: "frame",
29
+ title: t("边框", "Frame"),
30
+ slot: "conversation.composer.frame",
31
+ kind: "component",
32
+ },
33
+ { id: "fx", title: t("特效", "Effects"), slot: "shell.overlay", kind: "component" },
34
+ ],
35
+ permissions: {
36
+ client: true,
37
+ ui: { components: ["hud", "brand", "empty", "frame", "fx"] },
38
+ },
39
+ setup(ctx) {
40
+ const withData = (n: number): UiView => ({ blocks: [], data: { n } });
41
+ ctx.ui.view("hud", async () => withData(1));
42
+ },
43
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": { "en": "Fake client", "zh": "客户端样例" },
3
+ "schemes": {
4
+ "light": {
5
+ "color": { "accent": "#1F5FBF", "on-accent": "#FFFFFF" }
6
+ },
7
+ "dark": {
8
+ "color": { "accent": "#8FB8FF", "on-accent": "#0B1220" }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "name": "fake-client-broken",
4
+ "version": "0.1.0",
5
+ "publisher": "Capybara",
6
+ "description": "Test fake: client code that throws (a component, an events listener and a conversation.empty replacement)"
7
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@capybara-hq/test-plugin-fake-client-broken",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "Test fake: client code that throws (a component, an events listener and a conversation.empty replacement)",
6
+ "license": "Apache-2.0",
7
+ "type": "module",
8
+ "dependencies": {
9
+ "@capybara-hq/plugin-client": "^0.1.0-rc.0",
10
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.0"
11
+ }
12
+ }
@@ -0,0 +1,22 @@
1
+ import { defineClientExtension, defineComponent } from "@capybara-hq/plugin-client";
2
+
3
+ const Boom = (): never => {
4
+ throw new Error("fake-client-broken: boom");
5
+ };
6
+
7
+ const Empty = (): never => {
8
+ throw new Error("fake-client-broken: empty");
9
+ };
10
+
11
+ export default defineClientExtension({
12
+ name: "fake-client-broken",
13
+ components: {
14
+ boom: defineComponent("conversation.properties.section", Boom),
15
+ empty: defineComponent("conversation.empty", Empty),
16
+ },
17
+ events: {
18
+ "run.started": () => {
19
+ throw new Error("fake-client-broken: run.started");
20
+ },
21
+ },
22
+ });
@@ -0,0 +1,27 @@
1
+ import { defineExtension } from "@capybara-hq/plugin-sdk";
2
+
3
+ const t = (zh: string, en: string) => ({ zh, en });
4
+
5
+ /**
6
+ * Test fake of a client extension whose browser code is broken, for the host's isolation (error
7
+ * boundaries, the crash budget, safe mode): component `boom` (`conversation.properties.section`)
8
+ * throws on render, the module-level `events` listener throws on `run.started`, and `empty`
9
+ * (`conversation.empty`) throws on render. No server side beyond the declarations.
10
+ */
11
+ export default defineExtension({
12
+ name: "fake-client-broken",
13
+ version: "0.1.0",
14
+ sdk: "^0.1.0-rc.0",
15
+ provides: [],
16
+ ui: [
17
+ {
18
+ id: "boom",
19
+ title: t("崩溃", "Boom"),
20
+ slot: "conversation.properties.section",
21
+ kind: "component",
22
+ },
23
+ { id: "empty", title: t("问候", "Greeting"), slot: "conversation.empty", kind: "component" },
24
+ ],
25
+ permissions: { client: true, ui: { components: ["boom", "empty"] } },
26
+ setup() {},
27
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/testing",
3
- "version": "0.1.0-rc.13",
3
+ "version": "0.1.0-rc.14",
4
4
  "description": "Test helpers for Capybara: test containers, dual-replica harness and fake third-party servers",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -47,17 +47,18 @@
47
47
  "tsx": "^4.23.15",
48
48
  "ws": "^8.22.0",
49
49
  "zod": "^4.6.7",
50
- "@capybara-hq/kernel": "^0.1.0-rc.14"
50
+ "@capybara-hq/kernel": "^0.1.0-rc.15"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/pg": "^8.23.1",
54
54
  "@types/ws": "^8.18.2",
55
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.10"
55
+ "@capybara-hq/plugin-client": "^0.1.0-rc.1",
56
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.11"
56
57
  },
57
58
  "peerDependencies": {
58
59
  "vitest": "^5.0.5",
59
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.10",
60
- "@capybara-hq/plugin-tools": "^0.1.0-rc.11"
60
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.11",
61
+ "@capybara-hq/plugin-tools": "^0.1.0-rc.12"
61
62
  },
62
63
  "peerDependenciesMeta": {
63
64
  "@capybara-hq/plugin-tools": {