create-disposabl-app 0.18.1 → 0.19.1
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.
- package/dist/disposabl.js +1 -1
- package/dist/index.js +11 -4
- package/dist/templates/default/.github/scripts/release.sh +12 -6
- package/dist/templates/default/.github/workflows/pipeline.yml +1 -538
- package/dist/templates/default/apps/mobile/eas.json +3 -1
- package/dist/templates/default/apps/mobile/modules/storefront-observer/README.md +9 -0
- package/dist/templates/default/apps/mobile/modules/storefront-observer/expo-module.config.json +1 -0
- package/dist/templates/default/apps/mobile/modules/storefront-observer/ios/StorefrontObserver.podspec +15 -0
- package/dist/templates/default/apps/mobile/modules/storefront-observer/ios/StorefrontObserverModule.swift +59 -0
- package/dist/templates/default/apps/mobile/modules/storefront-observer/package.json +7 -0
- package/dist/templates/default/apps/mobile/scripts/play-aab.mjs +61 -15
- package/dist/templates/default/apps/mobile/scripts/verify-play-aab.mjs +1 -1
- package/dist/templates/default/apps/web/src/router/_authenticated/dashboard.api-keys.tsx +2 -1
- package/dist/templates/default/packages/disposabl-kit/client/lib/telemetry-lease.ts +8 -1
- package/dist/templates/default/packages/disposabl-kit/client/routes/pricing.tsx +53 -7
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/storefront-observer.ts +45 -0
- package/dist/templates/default/packages/disposabl-kit/mobile/billing/web-checkout.ts +39 -7
- package/dist/templates/default/packages/tests/android-failure-workflow.test.ts +10 -4
- package/dist/templates/default/packages/tests/billing-setup-hooks.test.ts +17 -6
- package/dist/templates/default/packages/tests/components/mobile-storefront-observer.test.mjs +241 -0
- package/dist/templates/default/packages/tests/mobile-storefront-observer.test.ts +22 -0
- package/dist/templates/default/packages/tests/package-release.test.ts +121 -0
- package/dist/templates/default/packages/tests/ui-telemetry-lease.test.ts +46 -0
- package/package.json +1 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { afterEach, expect, mock, test } from "bun:test";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { act, create } from "react-test-renderer";
|
|
4
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
5
|
+
const listeners = new Set();
|
|
6
|
+
let starts = 0,
|
|
7
|
+
stops = 0,
|
|
8
|
+
country = "USA",
|
|
9
|
+
current = true,
|
|
10
|
+
failStart = false,
|
|
11
|
+
missing = false,
|
|
12
|
+
pending,
|
|
13
|
+
startPending,
|
|
14
|
+
onStorefrontRead;
|
|
15
|
+
const link = {
|
|
16
|
+
url: `https://fixture.invalid/billing-login#${"A".repeat(43)}`,
|
|
17
|
+
userId: "owner",
|
|
18
|
+
};
|
|
19
|
+
const handoff = mock(async () => link);
|
|
20
|
+
const openURL = mock(async () => {});
|
|
21
|
+
const observer = {
|
|
22
|
+
addListener(_event, callback) {
|
|
23
|
+
listeners.add(callback);
|
|
24
|
+
return { remove: () => listeners.delete(callback) };
|
|
25
|
+
},
|
|
26
|
+
async start() {
|
|
27
|
+
starts++;
|
|
28
|
+
if (failStart) throw Error("unavailable");
|
|
29
|
+
return startPending ? await startPending : true;
|
|
30
|
+
},
|
|
31
|
+
async stop() {
|
|
32
|
+
stops++;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
mock.module("expo", () => ({
|
|
36
|
+
requireOptionalNativeModule: () => (missing ? null : observer),
|
|
37
|
+
}));
|
|
38
|
+
mock.module("expo-constants", () => ({ default: { expoConfig: {} } }));
|
|
39
|
+
mock.module("convex/server", () => ({
|
|
40
|
+
makeFunctionReference: () => "fixture",
|
|
41
|
+
}));
|
|
42
|
+
mock.module("convex/react", () => ({ useMutation: () => handoff }));
|
|
43
|
+
mock.module("react-native", () => ({
|
|
44
|
+
Platform: { OS: "ios" },
|
|
45
|
+
Linking: { openURL },
|
|
46
|
+
AppState: { addEventListener: () => ({ remove() {} }) },
|
|
47
|
+
}));
|
|
48
|
+
mock.module("../../../packages/disposabl-kit/mobile/billing/session", () => ({
|
|
49
|
+
billingSession: {
|
|
50
|
+
current: () => current,
|
|
51
|
+
beginTransaction: () => true,
|
|
52
|
+
endTransaction: () => {},
|
|
53
|
+
run: async (_id, _version, _key, fn) =>
|
|
54
|
+
fn({
|
|
55
|
+
canMakePayments: async () => true,
|
|
56
|
+
getStorefront: async () => {
|
|
57
|
+
const value = pending
|
|
58
|
+
? await pending
|
|
59
|
+
: country === "error"
|
|
60
|
+
? await Promise.reject(Error("unknown"))
|
|
61
|
+
: country
|
|
62
|
+
? { countryCode: country }
|
|
63
|
+
: null;
|
|
64
|
+
onStorefrontRead?.();
|
|
65
|
+
return value;
|
|
66
|
+
},
|
|
67
|
+
getCustomerInfo: async () => ({ activeSubscriptions: [] }),
|
|
68
|
+
getOfferings: async () => ({}),
|
|
69
|
+
getAppUserID: async () => "owner",
|
|
70
|
+
}),
|
|
71
|
+
},
|
|
72
|
+
}));
|
|
73
|
+
mock.module("../../../packages/disposabl-kit/mobile/billing/paywall", () => ({
|
|
74
|
+
monthlyOfferingId: "",
|
|
75
|
+
selectMonthlyOffering: () => ({}),
|
|
76
|
+
}));
|
|
77
|
+
mock.module("../../../packages/disposabl-kit/mobile/billing/topup", () => ({
|
|
78
|
+
matchingTopupRoute: () => false,
|
|
79
|
+
loadTopup: async () => null,
|
|
80
|
+
}));
|
|
81
|
+
const { useWebCheckout } =
|
|
82
|
+
await import("../../../packages/disposabl-kit/mobile/billing/web-checkout");
|
|
83
|
+
let renderer, result;
|
|
84
|
+
const version = { current: 1 };
|
|
85
|
+
const snapshot = async () => ({
|
|
86
|
+
customerId: "owner",
|
|
87
|
+
nativeSubscriptionsEnabled: true,
|
|
88
|
+
hasMonthlyPlan: false,
|
|
89
|
+
mobileWebCheckoutEnabled: true,
|
|
90
|
+
});
|
|
91
|
+
function Harness() {
|
|
92
|
+
result = useWebCheckout("owner", version, "key", "product", snapshot);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
async function mount() {
|
|
96
|
+
await act(async () => {
|
|
97
|
+
renderer = create(createElement(Harness));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async function change() {
|
|
101
|
+
await act(async () => {
|
|
102
|
+
for (const listener of [...listeners]) listener();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
afterEach(async () => {
|
|
106
|
+
await act(async () => renderer?.unmount());
|
|
107
|
+
starts = 0;
|
|
108
|
+
stops = 0;
|
|
109
|
+
country = "USA";
|
|
110
|
+
current = true;
|
|
111
|
+
failStart = false;
|
|
112
|
+
missing = false;
|
|
113
|
+
pending = undefined;
|
|
114
|
+
startPending = undefined;
|
|
115
|
+
onStorefrontRead = undefined;
|
|
116
|
+
handoff.mockReset().mockImplementation(async () => link);
|
|
117
|
+
openURL.mockClear();
|
|
118
|
+
listeners.clear();
|
|
119
|
+
});
|
|
120
|
+
test("active storefront changes and unknown/error fail closed", async () => {
|
|
121
|
+
await mount();
|
|
122
|
+
expect(result.available).toBe(true);
|
|
123
|
+
country = "CAN";
|
|
124
|
+
await change();
|
|
125
|
+
expect(result.available).toBe(false);
|
|
126
|
+
country = null;
|
|
127
|
+
await change();
|
|
128
|
+
expect(result.available).toBe(false);
|
|
129
|
+
country = "error";
|
|
130
|
+
await change();
|
|
131
|
+
expect(result.available).toBe(false);
|
|
132
|
+
country = "USA";
|
|
133
|
+
await change();
|
|
134
|
+
expect(result.available).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
test("event invalidates pending eligibility and stale session results", async () => {
|
|
137
|
+
await mount();
|
|
138
|
+
let finish;
|
|
139
|
+
pending = new Promise((resolve) => {
|
|
140
|
+
finish = resolve;
|
|
141
|
+
});
|
|
142
|
+
await act(async () => {
|
|
143
|
+
void result.refresh();
|
|
144
|
+
});
|
|
145
|
+
expect(result.available).toBe(false);
|
|
146
|
+
country = "CAN";
|
|
147
|
+
pending = undefined;
|
|
148
|
+
await change();
|
|
149
|
+
expect(result.available).toBe(false);
|
|
150
|
+
await act(async () => finish({ countryCode: "USA" }));
|
|
151
|
+
expect(result.available).toBe(false);
|
|
152
|
+
current = false;
|
|
153
|
+
country = "USA";
|
|
154
|
+
await change();
|
|
155
|
+
expect(result.available).toBe(false);
|
|
156
|
+
});
|
|
157
|
+
test("observer start failure and cleanup fail closed", async () => {
|
|
158
|
+
failStart = true;
|
|
159
|
+
await mount();
|
|
160
|
+
expect(result.available).toBe(false);
|
|
161
|
+
expect(starts).toBe(1);
|
|
162
|
+
await act(async () => renderer.unmount());
|
|
163
|
+
expect(listeners.size).toBe(0);
|
|
164
|
+
expect(stops).toBe(0);
|
|
165
|
+
});
|
|
166
|
+
test("multiple mounts retain observation until each is removed", async () => {
|
|
167
|
+
await mount();
|
|
168
|
+
let second;
|
|
169
|
+
await act(async () => {
|
|
170
|
+
second = create(createElement(Harness));
|
|
171
|
+
});
|
|
172
|
+
expect(starts).toBe(2);
|
|
173
|
+
await act(async () => renderer.unmount());
|
|
174
|
+
expect(stops).toBe(1);
|
|
175
|
+
expect(listeners.size).toBe(1);
|
|
176
|
+
await act(async () => second.unmount());
|
|
177
|
+
expect(stops).toBe(2);
|
|
178
|
+
expect(listeners.size).toBe(0);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("missing module and unmount during native start remain closed", async () => {
|
|
182
|
+
missing = true;
|
|
183
|
+
await mount();
|
|
184
|
+
expect(result.available).toBe(false);
|
|
185
|
+
expect(listeners.size).toBe(0);
|
|
186
|
+
await act(async () => renderer.unmount());
|
|
187
|
+
missing = false;
|
|
188
|
+
let finish;
|
|
189
|
+
startPending = new Promise((resolve) => {
|
|
190
|
+
finish = resolve;
|
|
191
|
+
});
|
|
192
|
+
await mount();
|
|
193
|
+
await act(async () => renderer.unmount());
|
|
194
|
+
await act(async () => finish(true));
|
|
195
|
+
expect(stops).toBe(1);
|
|
196
|
+
expect(listeners.size).toBe(0);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("an unchanged US storefront opens the validated handoff", async () => {
|
|
200
|
+
await mount();
|
|
201
|
+
let opened;
|
|
202
|
+
await act(async () => {
|
|
203
|
+
opened = await result.open();
|
|
204
|
+
});
|
|
205
|
+
expect(opened).toBe(true);
|
|
206
|
+
expect(openURL).toHaveBeenCalledWith(link.url);
|
|
207
|
+
expect(result.busy).toBe(false);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test("a change during the final storefront read cancels the handoff and clears busy", async () => {
|
|
211
|
+
await mount();
|
|
212
|
+
handoff.mockImplementationOnce(async () => {
|
|
213
|
+
onStorefrontRead = () => {
|
|
214
|
+
onStorefrontRead = undefined;
|
|
215
|
+
country = "CAN";
|
|
216
|
+
for (const listener of [...listeners]) listener();
|
|
217
|
+
};
|
|
218
|
+
return link;
|
|
219
|
+
});
|
|
220
|
+
let opened;
|
|
221
|
+
await act(async () => {
|
|
222
|
+
opened = await result.open();
|
|
223
|
+
});
|
|
224
|
+
expect(handoff).toHaveBeenCalledTimes(1);
|
|
225
|
+
expect(opened).toBe(false);
|
|
226
|
+
expect(openURL).not.toHaveBeenCalled();
|
|
227
|
+
expect(result.busy).toBe(false);
|
|
228
|
+
expect(result.available).toBe(false);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("a queued callback from a removed subscription is ignored", async () => {
|
|
232
|
+
const { observeStorefront } =
|
|
233
|
+
await import("../../../packages/disposabl-kit/mobile/billing/storefront-observer");
|
|
234
|
+
const changed = mock(() => {});
|
|
235
|
+
const subscription = observeStorefront(changed);
|
|
236
|
+
await subscription.ready;
|
|
237
|
+
const queued = [...listeners][0];
|
|
238
|
+
subscription.remove();
|
|
239
|
+
queued();
|
|
240
|
+
expect(changed).not.toHaveBeenCalled();
|
|
241
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
test("native storefront observation and eligibility races", () => {
|
|
7
|
+
const result = spawnSync(
|
|
8
|
+
process.execPath,
|
|
9
|
+
[
|
|
10
|
+
"test",
|
|
11
|
+
join(
|
|
12
|
+
import.meta.dirname,
|
|
13
|
+
"components/mobile-storefront-observer.test.mjs",
|
|
14
|
+
),
|
|
15
|
+
],
|
|
16
|
+
{
|
|
17
|
+
encoding: "utf8",
|
|
18
|
+
env: { ...process.env, E2E_TELEMETRY_DISABLED: "1", DO_NOT_TRACK: "1" },
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
22
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
copyFileSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
mkdtempSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
writeFileSync,
|
|
11
|
+
} from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
|
|
15
|
+
function release(options: {
|
|
16
|
+
prepared?: string;
|
|
17
|
+
available?: string;
|
|
18
|
+
failure?: boolean;
|
|
19
|
+
}) {
|
|
20
|
+
const directory = mkdtempSync(join(tmpdir(), "package-release-"));
|
|
21
|
+
try {
|
|
22
|
+
const bin = join(directory, "bin");
|
|
23
|
+
mkdirSync(bin);
|
|
24
|
+
mkdirSync(join(directory, "packages/sdk"), { recursive: true });
|
|
25
|
+
writeFileSync(
|
|
26
|
+
join(directory, "packages/sdk/package.json"),
|
|
27
|
+
JSON.stringify({ name: "@fixture/sdk", version: "1.0.0-development" }),
|
|
28
|
+
);
|
|
29
|
+
copyFileSync(
|
|
30
|
+
new URL("../../.github/scripts/release.sh", import.meta.url),
|
|
31
|
+
join(directory, "release.sh"),
|
|
32
|
+
);
|
|
33
|
+
const executable = (name: string, body: string) =>
|
|
34
|
+
writeFileSync(join(bin, name), `#!/bin/bash\nset -eu\n${body}\n`, {
|
|
35
|
+
mode: 0o755,
|
|
36
|
+
});
|
|
37
|
+
executable(
|
|
38
|
+
"bun",
|
|
39
|
+
`if [[ "$*" == 'run --cwd packages/sdk release' ]]; then
|
|
40
|
+
echo release >> calls
|
|
41
|
+
[[ "$FAIL_RELEASE" != true ]] || exit 1
|
|
42
|
+
if [[ -n "$PREPARED" ]]; then
|
|
43
|
+
printf '{"name":"@fixture/sdk","version":"%s"}' "$PREPARED" > packages/sdk/package.json
|
|
44
|
+
fi
|
|
45
|
+
fi`,
|
|
46
|
+
);
|
|
47
|
+
executable(
|
|
48
|
+
"npm",
|
|
49
|
+
`echo "npm $*" >> calls
|
|
50
|
+
[[ -n "$AVAILABLE" ]] || { echo 'E404 or registry unavailable' >&2; exit 1; }
|
|
51
|
+
printf '%s\\n' "$AVAILABLE"`,
|
|
52
|
+
);
|
|
53
|
+
executable(
|
|
54
|
+
"node",
|
|
55
|
+
`if [[ "$1" == -p ]]; then
|
|
56
|
+
if [[ "$2" == *.name ]]; then echo '@fixture/sdk';
|
|
57
|
+
else sed -E 's/.*"version":"([^"]+)".*/\\1/' packages/sdk/package.json; fi
|
|
58
|
+
else
|
|
59
|
+
printf '%s version=%s\\n' "$*" "$PUBLISHED_VERSION" >> calls
|
|
60
|
+
fi`,
|
|
61
|
+
);
|
|
62
|
+
const result = spawnSync("/bin/bash", ["release.sh", "package-release"], {
|
|
63
|
+
cwd: directory,
|
|
64
|
+
encoding: "utf8",
|
|
65
|
+
env: {
|
|
66
|
+
PATH: `${bin}:/usr/bin:/bin`,
|
|
67
|
+
NODE_ENV: "test",
|
|
68
|
+
PACKAGE: "sdk",
|
|
69
|
+
PUBLISHED_VERSION: "",
|
|
70
|
+
GH_TOKEN: "fixture-github-token",
|
|
71
|
+
PREPARED: options.prepared ?? "",
|
|
72
|
+
AVAILABLE: options.available ?? "",
|
|
73
|
+
FAIL_RELEASE: String(options.failure ?? false),
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
return { ...result, calls: readFileSync(join(directory, "calls"), "utf8") };
|
|
77
|
+
} finally {
|
|
78
|
+
rmSync(directory, { recursive: true, force: true });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
test("first publication runs before any registry lookup", () => {
|
|
83
|
+
const result = release({ prepared: "1.0.0", available: "1.0.0" });
|
|
84
|
+
assert.equal(result.status, 0, result.stderr);
|
|
85
|
+
assert.ok(
|
|
86
|
+
result.calls.indexOf("release\n") < result.calls.indexOf("npm view"),
|
|
87
|
+
);
|
|
88
|
+
assert.match(result.calls, /npm view @fixture\/sdk@1\.0\.0 version/);
|
|
89
|
+
assert.match(result.calls, /report typescript-sdk ready version=1\.0\.0/);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("no new release reports the existing public version", () => {
|
|
93
|
+
const result = release({ available: "1.2.3" });
|
|
94
|
+
assert.equal(result.status, 0, result.stderr);
|
|
95
|
+
assert.match(result.calls, /npm view @fixture\/sdk version/);
|
|
96
|
+
assert.match(result.calls, /ready version=1\.2\.3/);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("release authorization failure is a failed job, not a successful skip", () => {
|
|
100
|
+
const result = release({ failure: true });
|
|
101
|
+
assert.equal(result.status, 1);
|
|
102
|
+
assert.match(result.calls, /report typescript-sdk failed/);
|
|
103
|
+
assert.doesNotMatch(result.calls, /npm view| ready /);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("unavailable registry or no public version cannot report ready", () => {
|
|
107
|
+
for (const prepared of [undefined, "1.0.0"]) {
|
|
108
|
+
const result = release({ prepared });
|
|
109
|
+
assert.equal(result.status, 1);
|
|
110
|
+
assert.match(result.calls, /release\n/);
|
|
111
|
+
assert.match(result.calls, /availability could not be verified/);
|
|
112
|
+
assert.doesNotMatch(result.calls, / ready /);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("a mismatched registry version cannot report ready", () => {
|
|
117
|
+
const result = release({ prepared: "1.0.0", available: "0.9.0" });
|
|
118
|
+
assert.equal(result.status, 1);
|
|
119
|
+
assert.match(result.calls, /no matching published version/);
|
|
120
|
+
assert.doesNotMatch(result.calls, / ready /);
|
|
121
|
+
});
|
|
@@ -90,6 +90,28 @@ test("anonymous identity is forwarded for login but never reused across logout",
|
|
|
90
90
|
control.stop();
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
test("unauthorized bootstrap clears in-memory anonymous linkage", async () => {
|
|
94
|
+
const bodies: unknown[] = [];
|
|
95
|
+
const control = createTelemetryLeaseController({
|
|
96
|
+
origin: "http://local",
|
|
97
|
+
transport: async (_url, init) => {
|
|
98
|
+
bodies.push(JSON.parse(String(init?.body)));
|
|
99
|
+
return bodies.length === 2
|
|
100
|
+
? new Response(null, { status: 401 })
|
|
101
|
+
: reply();
|
|
102
|
+
},
|
|
103
|
+
adapter: { start() {}, stop() {} },
|
|
104
|
+
});
|
|
105
|
+
control.update({ enabled: true, token: null });
|
|
106
|
+
await tick();
|
|
107
|
+
control.update({ enabled: true, token: token("account") });
|
|
108
|
+
await tick();
|
|
109
|
+
control.update({ enabled: true, token: token("account") });
|
|
110
|
+
await tick();
|
|
111
|
+
assert.deepEqual(bodies, [{}, { anonymousId: id }, {}]);
|
|
112
|
+
control.stop();
|
|
113
|
+
});
|
|
114
|
+
|
|
93
115
|
test("disabled, malformed and unapproved bootstrap replies never start SDK", async () => {
|
|
94
116
|
for (const response of [
|
|
95
117
|
new Response(null, { status: 204 }),
|
|
@@ -244,6 +266,30 @@ test("a changed server identity restarts even during a same-session refresh", as
|
|
|
244
266
|
control.stop();
|
|
245
267
|
});
|
|
246
268
|
|
|
269
|
+
test("a reentrant opt-out while replacing an adapter cannot restart it", async () => {
|
|
270
|
+
let calls = 0;
|
|
271
|
+
const events: string[] = [];
|
|
272
|
+
let control!: ReturnType<typeof createTelemetryLeaseController>;
|
|
273
|
+
control = createTelemetryLeaseController({
|
|
274
|
+
origin: "http://local",
|
|
275
|
+
transport: async () =>
|
|
276
|
+
reply({ identified: true, distinctId: `identity-${++calls}` }),
|
|
277
|
+
adapter: {
|
|
278
|
+
start: () => events.push("start"),
|
|
279
|
+
stop: () => {
|
|
280
|
+
events.push("stop");
|
|
281
|
+
control.update({ enabled: false, token: token("same") });
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
control.update({ enabled: true, token: token("same") + "a" });
|
|
286
|
+
await tick();
|
|
287
|
+
control.update({ enabled: true, token: token("same") + "b" });
|
|
288
|
+
await tick();
|
|
289
|
+
assert.deepEqual(events, ["start", "stop"]);
|
|
290
|
+
control.stop();
|
|
291
|
+
});
|
|
292
|
+
|
|
247
293
|
test("transient bootstrap failure retries with capture off until a valid lease", async () => {
|
|
248
294
|
let calls = 0;
|
|
249
295
|
const events: string[] = [];
|