@capybara-hq/testing 0.1.0-rc.41 → 0.1.0-rc.43

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.
@@ -121,6 +121,11 @@ export declare class FakeDialInMachine {
121
121
  private streamHandler;
122
122
  /** Leave every `stream-open` unanswered (a machine that never opens streams). */
123
123
  ignoreStreamOpens: boolean;
124
+ /**
125
+ * While set, each `stream-open` is answered only once this promise resolves (a machine slow to
126
+ * open its service): a test holds the kernel's stream open here.
127
+ */
128
+ streamOpenGate: Promise<void> | undefined;
124
129
  /** The ids of the `stream-open` frames received, in order. */
125
130
  readonly streamOpens: string[];
126
131
  /** The ids of the `stream-close` frames received, in order (also of streams never opened). */
@@ -169,6 +169,11 @@ export class FakeDialInMachine {
169
169
  streamHandler;
170
170
  /** Leave every `stream-open` unanswered (a machine that never opens streams). */
171
171
  ignoreStreamOpens = false;
172
+ /**
173
+ * While set, each `stream-open` is answered only once this promise resolves (a machine slow to
174
+ * open its service): a test holds the kernel's stream open here.
175
+ */
176
+ streamOpenGate;
172
177
  /** The ids of the `stream-open` frames received, in order. */
173
178
  streamOpens = [];
174
179
  /** The ids of the `stream-close` frames received, in order (also of streams never opened). */
@@ -335,8 +340,15 @@ export class FakeDialInMachine {
335
340
  }
336
341
  else if (frame.type === "stream-open" && frame.streamId !== undefined) {
337
342
  this.streamOpens.push(frame.streamId);
338
- if (!this.ignoreStreamOpens)
339
- this.openStream(frame.streamId, frame.body);
343
+ if (!this.ignoreStreamOpens) {
344
+ const streamId = frame.streamId;
345
+ const body = frame.body;
346
+ const gate = this.streamOpenGate;
347
+ if (gate === undefined)
348
+ this.openStream(streamId, body);
349
+ else
350
+ void gate.then(() => this.openStream(streamId, body));
351
+ }
340
352
  }
341
353
  else if (frame.type.startsWith("stream-") && frame.streamId !== undefined) {
342
354
  if (frame.type === "stream-close")
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export { type FakeSlackAck, type FakeSlackCall, type FakeSlackFailure, type Fake
23
23
  export { type FakeTelegramBot, type FakeTelegramCall, type FakeTelegramFailure, type FakeTelegramMessage, type FakeTelegramOptions, type FakeTelegramServer, findTelegramButton, startFakeTelegram, type TgChat, type TgUser, telegramCallback, telegramGroupMessage, telegramPrivateMessage, telegramWebhookHeaders, } from "./fake-telegram.js";
24
24
  export { FAKE_EXTENSIONS, type FakeExtensionName, fakeExtensionDir, fakeExtensionEntry, type PackedFixture, packFixture, } from "./fixtures.js";
25
25
  export { cardRecorded, cookieRequest, createAgent, createConversation, createLocalAccount, createOrg, enableModelProviders, eventsOf, joinOrg, type KernelApp, type KernelRequest, type KernelRequestOptions, type KernelResponse, login, pidOwningLocalPort, postMessage, sleep, startTestKernel, TEST_PASSWORD, type TestKernel, testKernelConfig, truncateTables, waitFor, waitForEvent, waitForTerminal, } from "./kernel-helpers.js";
26
+ export { type LoginSourceSeed, seedLoginSources } from "./login-sources.js";
26
27
  export { FAKE_PNG_BASE64, isPngBase64, pdfBase64, pdfSampleWord, redPngBase64, solidPngBase64, } from "./media-samples.js";
27
28
  export { type ConformanceTarget, checkDeclaredParameters, describeModelProviderConformance, MEDIA_SAMPLES, thinkingReplayParams, } from "./model-conformance.js";
28
29
  export { describePushProviderConformance, type PushConformanceTarget, type PushOutcome, type PushVendorRequest, } from "./push-conformance.js";
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ export { findSlackButton, signSlackWebhook, slackBlockAction, slackDmEvent, slac
23
23
  export { findTelegramButton, startFakeTelegram, telegramCallback, telegramGroupMessage, telegramPrivateMessage, telegramWebhookHeaders, } from "./fake-telegram.js";
24
24
  export { FAKE_EXTENSIONS, fakeExtensionDir, fakeExtensionEntry, packFixture, } from "./fixtures.js";
25
25
  export { cardRecorded, cookieRequest, createAgent, createConversation, createLocalAccount, createOrg, enableModelProviders, eventsOf, joinOrg, login, pidOwningLocalPort, postMessage, sleep, startTestKernel, TEST_PASSWORD, testKernelConfig, truncateTables, waitFor, waitForEvent, waitForTerminal, } from "./kernel-helpers.js";
26
+ export { seedLoginSources } from "./login-sources.js";
26
27
  export { FAKE_PNG_BASE64, isPngBase64, pdfBase64, pdfSampleWord, redPngBase64, solidPngBase64, } from "./media-samples.js";
27
28
  export { checkDeclaredParameters, describeModelProviderConformance, MEDIA_SAMPLES, thinkingReplayParams, } from "./model-conformance.js";
28
29
  export { describePushProviderConformance, } from "./push-conformance.js";
@@ -0,0 +1,12 @@
1
+ import { type KernelSchemaDb, type LoginSourceSettings } from "@capybara-hq/kernel";
2
+ /** One entry for {@link seedLoginSources}: only `plugin` is required. */
3
+ export type LoginSourceSeed = Pick<LoginSourceSettings, "plugin"> & Partial<LoginSourceSettings>;
4
+ /**
5
+ * Replaces the deployment's login sources (the `loginSources` deployment setting) with `entries`,
6
+ * in this order (the login page order). Defaults: `enabled: true`, `signUp: "link"` (an unlinked
7
+ * external account goes to the link page; pass `signUp: "create"` where a test signs up through a
8
+ * login source), no trusted tenants. It writes the row directly through `db` (any replica reads it
9
+ * at its next sign-in), without the admin checks: the extension need not be loaded or configured.
10
+ * The row references `accounts`, so `TRUNCATE capybara.accounts CASCADE` empties it: seed after.
11
+ */
12
+ export declare function seedLoginSources(db: KernelSchemaDb, entries: readonly LoginSourceSeed[]): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { writeLoginSources, } from "@capybara-hq/kernel";
2
+ /**
3
+ * Replaces the deployment's login sources (the `loginSources` deployment setting) with `entries`,
4
+ * in this order (the login page order). Defaults: `enabled: true`, `signUp: "link"` (an unlinked
5
+ * external account goes to the link page; pass `signUp: "create"` where a test signs up through a
6
+ * login source), no trusted tenants. It writes the row directly through `db` (any replica reads it
7
+ * at its next sign-in), without the admin checks: the extension need not be loaded or configured.
8
+ * The row references `accounts`, so `TRUNCATE capybara.accounts CASCADE` empties it: seed after.
9
+ */
10
+ export async function seedLoginSources(db, entries) {
11
+ await writeLoginSources(db, entries.map((e) => ({
12
+ plugin: e.plugin,
13
+ enabled: e.enabled ?? true,
14
+ signUp: e.signUp ?? "link",
15
+ trustedTenants: e.trustedTenants ?? [],
16
+ })), null);
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/testing",
3
- "version": "0.1.0-rc.41",
3
+ "version": "0.1.0-rc.43",
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,18 +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.90"
50
+ "@capybara-hq/kernel": "^0.1.0-rc.94"
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.72",
55
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.77",
56
56
  "@capybara-hq/plugin-client": "^0.1.0-rc.9"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "vitest": "^5.0.5",
60
- "@capybara-hq/plugin-tools": "^0.1.0-rc.25",
61
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.72"
60
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.77",
61
+ "@capybara-hq/plugin-tools": "^0.1.0-rc.25"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "@capybara-hq/plugin-tools": {