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

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/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.42",
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.92"
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",
56
- "@capybara-hq/plugin-client": "^0.1.0-rc.9"
55
+ "@capybara-hq/plugin-client": "^0.1.0-rc.9",
56
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.75"
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.75",
61
+ "@capybara-hq/plugin-tools": "^0.1.0-rc.25"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "@capybara-hq/plugin-tools": {