yaver-feedback-react-native 0.9.0 → 0.9.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.
- package/README.md +102 -1
- package/app.plugin.js +126 -9
- package/dist/AuthOverlay.d.ts +1 -14
- package/dist/AuthOverlay.js +9 -62
- package/dist/BlackBox.js +9 -1
- package/dist/DeployPanel.js +65 -0
- package/dist/Discovery.js +13 -8
- package/dist/DogfoodRuntime.d.ts +124 -0
- package/dist/DogfoodRuntime.js +273 -0
- package/dist/FeedbackModal.js +505 -65
- package/dist/LoginScreen.d.ts +1 -5
- package/dist/LoginScreen.js +2 -6
- package/dist/MachinePickerScreen.d.ts +1 -3
- package/dist/MachinePickerScreen.js +6 -18
- package/dist/P2PClient.d.ts +178 -2
- package/dist/P2PClient.js +493 -3
- package/dist/P2PDogfoodDriver.d.ts +12 -0
- package/dist/P2PDogfoodDriver.js +118 -0
- package/dist/PairDeviceModal.d.ts +2 -3
- package/dist/ShakeDetector.js +2 -0
- package/dist/VibeChatScreen.d.ts +11 -1
- package/dist/VibeChatScreen.js +200 -41
- package/dist/YaverFeedback.d.ts +132 -0
- package/dist/YaverFeedback.js +633 -65
- package/dist/YaverModeBadge.d.ts +22 -0
- package/dist/YaverModeBadge.js +219 -0
- package/dist/__tests__/AuthDevices.test.js +1 -48
- package/dist/__tests__/BlackBox.relayPassword.test.d.ts +1 -0
- package/dist/__tests__/BlackBox.relayPassword.test.js +105 -0
- package/dist/__tests__/BlackBoxAutoStart.test.d.ts +1 -0
- package/dist/__tests__/BlackBoxAutoStart.test.js +91 -0
- package/dist/__tests__/BlackBoxAutoStartColdStart.test.d.ts +1 -0
- package/dist/__tests__/BlackBoxAutoStartColdStart.test.js +156 -0
- package/dist/__tests__/BrowserLaneIcon.test.d.ts +3 -0
- package/dist/__tests__/BrowserLaneIcon.test.js +80 -0
- package/dist/__tests__/DogfoodRuntime.test.d.ts +1 -0
- package/dist/__tests__/DogfoodRuntime.test.js +116 -0
- package/dist/__tests__/P2PClient.test.js +2 -2
- package/dist/__tests__/P2PDogfoodDriver.test.d.ts +1 -0
- package/dist/__tests__/P2PDogfoodDriver.test.js +64 -0
- package/dist/__tests__/ReportIdentity.test.d.ts +25 -0
- package/dist/__tests__/ReportIdentity.test.js +180 -0
- package/dist/__tests__/SDKToken.test.js +1 -1
- package/dist/__tests__/ShakeToggle.test.d.ts +1 -0
- package/dist/__tests__/ShakeToggle.test.js +121 -0
- package/dist/__tests__/YaverFeedback.test.js +13 -3
- package/dist/__tests__/deviceDogfood.test.d.ts +1 -0
- package/dist/__tests__/deviceDogfood.test.js +86 -0
- package/dist/__tests__/dogfoodPolicy.test.d.ts +1 -0
- package/dist/__tests__/dogfoodPolicy.test.js +33 -0
- package/dist/__tests__/pickTargetDevice.test.d.ts +1 -0
- package/dist/__tests__/pickTargetDevice.test.js +89 -0
- package/dist/__tests__/reloadActions.test.d.ts +1 -0
- package/dist/__tests__/reloadActions.test.js +129 -0
- package/dist/__tests__/reloadActionsParity.test.d.ts +1 -0
- package/dist/__tests__/reloadActionsParity.test.js +42 -0
- package/dist/__tests__/types.test.js +5 -5
- package/dist/_core/ansi.d.ts +117 -0
- package/dist/_core/ansi.js +468 -0
- package/dist/_core/ansi.test.d.ts +1 -0
- package/dist/_core/ansi.test.js +225 -0
- package/dist/_core/buildFeedbackPrompt.d.ts +4 -9
- package/dist/_core/buildFeedbackPrompt.js +18 -72
- package/dist/_core/constants.d.ts +19 -6
- package/dist/_core/constants.js +20 -7
- package/dist/_core/device.d.ts +1 -5
- package/dist/_core/device.js +5 -14
- package/dist/_core/endpoints.d.ts +0 -7
- package/dist/_core/endpoints.js +0 -7
- package/dist/_core/index.d.ts +4 -0
- package/dist/_core/index.js +4 -0
- package/dist/_core/remoteless.d.ts +44 -0
- package/dist/_core/remoteless.js +75 -0
- package/dist/_core/trace.d.ts +47 -0
- package/dist/_core/trace.js +38 -0
- package/dist/_core/trace.test.d.ts +1 -0
- package/dist/_core/trace.test.js +60 -0
- package/dist/auth.d.ts +3 -60
- package/dist/auth.js +6 -88
- package/dist/deviceDogfood.d.ts +53 -0
- package/dist/deviceDogfood.js +137 -0
- package/dist/dogfoodPolicy.d.ts +25 -0
- package/dist/dogfoodPolicy.js +24 -0
- package/dist/index.d.ts +17 -4
- package/dist/index.js +33 -7
- package/dist/reloadActions.d.ts +88 -0
- package/dist/reloadActions.js +200 -0
- package/dist/storeShots.d.ts +67 -0
- package/dist/storeShots.js +137 -0
- package/dist/types.d.ts +208 -8
- package/package.json +13 -4
- package/src/AuthOverlay.tsx +20 -106
- package/src/BlackBox.ts +10 -1
- package/src/DeployPanel.tsx +74 -0
- package/src/Discovery.ts +13 -8
- package/src/DogfoodRuntime.ts +373 -0
- package/src/FeedbackModal.tsx +619 -79
- package/src/LoginScreen.tsx +2 -22
- package/src/MachinePickerScreen.tsx +6 -21
- package/src/P2PClient.ts +580 -4
- package/src/P2PDogfoodDriver.ts +132 -0
- package/src/PairDeviceModal.tsx +2 -3
- package/src/ShakeDetector.ts +1 -0
- package/src/VibeChatScreen.tsx +232 -42
- package/src/YaverFeedback.ts +631 -68
- package/src/YaverModeBadge.tsx +234 -0
- package/src/__tests__/AuthDevices.test.ts +1 -52
- package/src/__tests__/BlackBox.relayPassword.test.ts +129 -0
- package/src/__tests__/BlackBoxAutoStart.test.ts +111 -0
- package/src/__tests__/BlackBoxAutoStartColdStart.test.ts +191 -0
- package/src/__tests__/BrowserLaneIcon.test.ts +85 -0
- package/src/__tests__/DogfoodRuntime.test.ts +135 -0
- package/src/__tests__/P2PClient.test.ts +2 -2
- package/src/__tests__/P2PDogfoodDriver.test.ts +80 -0
- package/src/__tests__/ReportIdentity.test.ts +212 -0
- package/src/__tests__/SDKToken.test.ts +1 -1
- package/src/__tests__/ShakeToggle.test.ts +153 -0
- package/src/__tests__/YaverFeedback.test.ts +15 -3
- package/src/__tests__/deviceDogfood.test.ts +77 -0
- package/src/__tests__/dogfoodPolicy.test.ts +34 -0
- package/src/__tests__/pickTargetDevice.test.ts +101 -0
- package/src/__tests__/reloadActions.test.ts +171 -0
- package/src/__tests__/reloadActionsParity.test.ts +49 -0
- package/src/__tests__/types.test.ts +5 -5
- package/src/_core/ansi.test.ts +250 -0
- package/src/_core/ansi.ts +475 -0
- package/src/_core/buildFeedbackPrompt.ts +18 -95
- package/src/_core/constants.ts +20 -6
- package/src/_core/device.ts +5 -16
- package/src/_core/endpoints.ts +0 -7
- package/src/_core/index.ts +4 -0
- package/src/_core/remoteless.ts +110 -0
- package/src/_core/trace.test.ts +58 -0
- package/src/_core/trace.ts +75 -0
- package/src/auth.ts +7 -156
- package/src/deviceDogfood.ts +171 -0
- package/src/dogfoodPolicy.ts +40 -0
- package/src/index.ts +61 -11
- package/src/reloadActions.ts +273 -0
- package/src/storeShots.ts +189 -0
- package/src/types.ts +209 -8
- package/dist/GuestOnboardingScreen.d.ts +0 -8
- package/dist/GuestOnboardingScreen.js +0 -282
- package/src/GuestOnboardingScreen.tsx +0 -307
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// BlackBox auto-start on a COLD start — the case that decides whether Hermes
|
|
2
|
+
// hot reload works at all.
|
|
3
|
+
//
|
|
4
|
+
// The command channel that carries the agent's `reload_bundle` is BlackBox's
|
|
5
|
+
// SSE stream. If BlackBox never starts, a fix pushed from the dev machine has
|
|
6
|
+
// nowhere to land and the phone just sits there.
|
|
7
|
+
//
|
|
8
|
+
// Auto-start used to be a single 500ms timeout gated on `agentUrl && token`.
|
|
9
|
+
// A real app passes NEITHER to init() — they're restored from storage — so on
|
|
10
|
+
// a cold start the sequence is:
|
|
11
|
+
//
|
|
12
|
+
// init() -> void hydrateSession()
|
|
13
|
+
// -> AsyncStorage read (token)
|
|
14
|
+
// -> AsyncStorage read (deviceId)
|
|
15
|
+
// -> await discoverAgent() <- Convex round trip + LAN probe
|
|
16
|
+
//
|
|
17
|
+
// which does not complete in 500ms. The one-shot check found no agentUrl, gave
|
|
18
|
+
// up, and hot reload was silently dead until the user shook the device and
|
|
19
|
+
// drove discovery by hand. These tests pin the retry that fixes it, and the
|
|
20
|
+
// bounds that keep it from becoming a forever-poll or a 401 storm.
|
|
21
|
+
|
|
22
|
+
import { BlackBox } from '../BlackBox';
|
|
23
|
+
import { YaverFeedback } from '../YaverFeedback';
|
|
24
|
+
|
|
25
|
+
jest.mock('react-native', () => ({
|
|
26
|
+
Platform: { OS: 'ios' },
|
|
27
|
+
DeviceEventEmitter: { emit: jest.fn(), addListener: jest.fn() },
|
|
28
|
+
NativeModules: {},
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
jest.mock('../ShakeDetector', () => ({
|
|
32
|
+
ShakeDetector: jest.fn().mockImplementation(() => ({
|
|
33
|
+
start: jest.fn(),
|
|
34
|
+
stop: jest.fn(),
|
|
35
|
+
})),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
// Discovery is the slow step we're modelling. Resolves only after the test
|
|
39
|
+
// flips `discovered`, standing in for "the Convex round trip finally landed".
|
|
40
|
+
let discovered: string | null = null;
|
|
41
|
+
jest.mock('../Discovery', () => ({
|
|
42
|
+
YaverDiscovery: {
|
|
43
|
+
discover: jest.fn(() =>
|
|
44
|
+
Promise.resolve(discovered ? { url: discovered } : null),
|
|
45
|
+
),
|
|
46
|
+
},
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
// The token cache hydrateSession() reads.
|
|
50
|
+
let storedToken: string | null = null;
|
|
51
|
+
jest.mock('../auth', () => ({
|
|
52
|
+
...jest.requireActual('../auth'),
|
|
53
|
+
getToken: jest.fn(() => Promise.resolve(storedToken)),
|
|
54
|
+
getSelectedDeviceId: jest.fn(() => Promise.resolve(null)),
|
|
55
|
+
configureAuthEndpoints: jest.fn(),
|
|
56
|
+
setStrictNativeAuth: jest.fn(),
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
jest.useFakeTimers();
|
|
60
|
+
|
|
61
|
+
const mockFetch = jest.fn(() =>
|
|
62
|
+
Promise.resolve({ ok: true, json: () => Promise.resolve({}), body: null }),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
class MockAbortController {
|
|
66
|
+
signal = { aborted: false };
|
|
67
|
+
abort = jest.fn();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// fetch and AbortController are process-globals, not per-file module state:
|
|
71
|
+
// jest gives each test FILE its own module registry but they share one worker
|
|
72
|
+
// process. Assigning them at module scope (as the sibling auto-start suite
|
|
73
|
+
// does) leaves them mocked for every file that runs afterwards in the same
|
|
74
|
+
// worker. Save and restore instead, so this suite can't be the reason some
|
|
75
|
+
// unrelated file sees a stubbed fetch.
|
|
76
|
+
const realFetch = global.fetch;
|
|
77
|
+
const realAbortController = global.AbortController;
|
|
78
|
+
|
|
79
|
+
beforeAll(() => {
|
|
80
|
+
global.fetch = mockFetch as any;
|
|
81
|
+
global.AbortController = MockAbortController as any;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
afterAll(() => {
|
|
85
|
+
global.fetch = realFetch;
|
|
86
|
+
global.AbortController = realAbortController;
|
|
87
|
+
// Leave no timer chain behind for the next file in this worker.
|
|
88
|
+
YaverFeedback.destroy();
|
|
89
|
+
jest.useRealTimers();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
jest.clearAllMocks();
|
|
94
|
+
discovered = null;
|
|
95
|
+
storedToken = null;
|
|
96
|
+
YaverFeedback.destroy();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
afterEach(() => {
|
|
100
|
+
BlackBox.stop();
|
|
101
|
+
YaverFeedback.destroy();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('BlackBox auto-start on a cold start', () => {
|
|
105
|
+
it('starts once discovery resolves well after the old 500ms window', async () => {
|
|
106
|
+
const startSpy = jest.spyOn(BlackBox, 'start').mockImplementation(() => {});
|
|
107
|
+
storedToken = 'tok-from-storage';
|
|
108
|
+
|
|
109
|
+
// Nothing passed in — the real cold-start shape.
|
|
110
|
+
YaverFeedback.init({ trigger: 'shake', blackBox: { appName: 'talos-mobile' } });
|
|
111
|
+
|
|
112
|
+
// The window the old implementation checked, and only that window.
|
|
113
|
+
await jest.advanceTimersByTimeAsync(600);
|
|
114
|
+
expect(startSpy).not.toHaveBeenCalled();
|
|
115
|
+
|
|
116
|
+
// Discovery lands late, as it does on a real cold, off-LAN start.
|
|
117
|
+
discovered = 'http://10.0.0.5:18080';
|
|
118
|
+
await jest.advanceTimersByTimeAsync(4000);
|
|
119
|
+
|
|
120
|
+
expect(startSpy).toHaveBeenCalledWith(
|
|
121
|
+
expect.objectContaining({ appName: 'talos-mobile' }),
|
|
122
|
+
);
|
|
123
|
+
startSpy.mockRestore();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('never starts without a token, however long it waits', async () => {
|
|
127
|
+
// The guard that matters: starting tokenless makes the SSE channel 401 and
|
|
128
|
+
// retry with backoff — the string-concat + JSON-parse loop that SIGSEGV'd
|
|
129
|
+
// Hermes on iOS 18.3.1. Retrying must not erode it.
|
|
130
|
+
const startSpy = jest.spyOn(BlackBox, 'start').mockImplementation(() => {});
|
|
131
|
+
storedToken = null;
|
|
132
|
+
discovered = 'http://10.0.0.5:18080';
|
|
133
|
+
|
|
134
|
+
YaverFeedback.init({ trigger: 'shake' });
|
|
135
|
+
await jest.advanceTimersByTimeAsync(90_000);
|
|
136
|
+
|
|
137
|
+
expect(startSpy).not.toHaveBeenCalled();
|
|
138
|
+
startSpy.mockRestore();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('gives up rather than polling forever', async () => {
|
|
142
|
+
const startSpy = jest.spyOn(BlackBox, 'start').mockImplementation(() => {});
|
|
143
|
+
storedToken = null;
|
|
144
|
+
|
|
145
|
+
YaverFeedback.init({ trigger: 'shake' });
|
|
146
|
+
// Past the ~60s bound.
|
|
147
|
+
await jest.advanceTimersByTimeAsync(90_000);
|
|
148
|
+
|
|
149
|
+
// Credentials arrive after the window closed — the poll is done.
|
|
150
|
+
storedToken = 'late';
|
|
151
|
+
discovered = 'http://10.0.0.5:18080';
|
|
152
|
+
await jest.advanceTimersByTimeAsync(10_000);
|
|
153
|
+
|
|
154
|
+
expect(startSpy).not.toHaveBeenCalled();
|
|
155
|
+
startSpy.mockRestore();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('signing in re-arms after the bound has passed', async () => {
|
|
159
|
+
// Giving up is only acceptable because this path exists: a user who signs
|
|
160
|
+
// in later gets the channel without restarting the app.
|
|
161
|
+
const startSpy = jest.spyOn(BlackBox, 'start').mockImplementation(() => {});
|
|
162
|
+
|
|
163
|
+
YaverFeedback.init({ trigger: 'shake' });
|
|
164
|
+
await jest.advanceTimersByTimeAsync(90_000);
|
|
165
|
+
expect(startSpy).not.toHaveBeenCalled();
|
|
166
|
+
|
|
167
|
+
discovered = 'http://10.0.0.5:18080';
|
|
168
|
+
await YaverFeedback.setAuthToken('tok-from-login');
|
|
169
|
+
await jest.advanceTimersByTimeAsync(2000);
|
|
170
|
+
|
|
171
|
+
expect(startSpy).toHaveBeenCalled();
|
|
172
|
+
startSpy.mockRestore();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('destroy() cancels a pending retry', async () => {
|
|
176
|
+
// A retry chain firing against a torn-down config would start the recorder
|
|
177
|
+
// for an SDK the host believes is off.
|
|
178
|
+
const startSpy = jest.spyOn(BlackBox, 'start').mockImplementation(() => {});
|
|
179
|
+
storedToken = 'tok';
|
|
180
|
+
|
|
181
|
+
YaverFeedback.init({ trigger: 'shake' });
|
|
182
|
+
await jest.advanceTimersByTimeAsync(600);
|
|
183
|
+
|
|
184
|
+
YaverFeedback.destroy();
|
|
185
|
+
discovered = 'http://10.0.0.5:18080';
|
|
186
|
+
await jest.advanceTimersByTimeAsync(10_000);
|
|
187
|
+
|
|
188
|
+
expect(startSpy).not.toHaveBeenCalled();
|
|
189
|
+
startSpy.mockRestore();
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-lane DOM icon (feedback-sdk-lanes audit 2026-07-28). RN-web inside
|
|
3
|
+
* Yaver's fullScreen preview WebView: native shake can't fire and the container
|
|
4
|
+
* overlay is occluded, so the SDK mounts an occlusion-proof DOM icon. Node env,
|
|
5
|
+
* so we stub Platform.OS='web' + a minimal DOM.
|
|
6
|
+
*/
|
|
7
|
+
jest.mock('react-native', () => ({
|
|
8
|
+
Platform: { OS: 'web' },
|
|
9
|
+
NativeModules: {},
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
// Minimal DOM stub — enough for mountBrowserLaneIcon's createElement/appendChild.
|
|
13
|
+
function installFakeDom() {
|
|
14
|
+
const els: Record<string, any> = {};
|
|
15
|
+
const makeEl = () => ({
|
|
16
|
+
id: '',
|
|
17
|
+
textContent: '',
|
|
18
|
+
title: '',
|
|
19
|
+
style: {} as Record<string, string>,
|
|
20
|
+
_handlers: {} as Record<string, unknown>,
|
|
21
|
+
setAttribute() {},
|
|
22
|
+
setPointerCapture() {},
|
|
23
|
+
releasePointerCapture() {},
|
|
24
|
+
getBoundingClientRect: () => ({ left: 0, top: 0, width: 44, height: 44 }),
|
|
25
|
+
addEventListener(k: string, fn: unknown) { this._handlers[k] = fn; },
|
|
26
|
+
});
|
|
27
|
+
(globalThis as any).window = {
|
|
28
|
+
innerWidth: 390, innerHeight: 844,
|
|
29
|
+
addEventListener() {},
|
|
30
|
+
__yaverLane: 'browser',
|
|
31
|
+
};
|
|
32
|
+
(globalThis as any).localStorage = { getItem: () => null, setItem() {} };
|
|
33
|
+
(globalThis as any).document = {
|
|
34
|
+
body: { appendChild(el: any) { els[el.id] = el; } },
|
|
35
|
+
getElementById: (id: string) => els[id] || null,
|
|
36
|
+
createElement: () => makeEl(),
|
|
37
|
+
};
|
|
38
|
+
return { els };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe('RN SDK browser-lane icon', () => {
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
delete (globalThis as any).window;
|
|
44
|
+
delete (globalThis as any).document;
|
|
45
|
+
delete (globalThis as any).localStorage;
|
|
46
|
+
jest.resetModules();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('detectWebLane reads window.__yaverLane on web', () => {
|
|
50
|
+
installFakeDom();
|
|
51
|
+
const { YaverFeedback } = require('../YaverFeedback');
|
|
52
|
+
expect(YaverFeedback.detectWebLane()).toBe('browser');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('mounts a fixed, max-z-index, draggable DOM icon in the browser lane', () => {
|
|
56
|
+
const { els } = installFakeDom();
|
|
57
|
+
const { YaverFeedback } = require('../YaverFeedback');
|
|
58
|
+
YaverFeedback.mountBrowserLaneIcon();
|
|
59
|
+
const btn = els['yaver-feedback-btn'];
|
|
60
|
+
expect(btn).toBeTruthy();
|
|
61
|
+
expect(btn.textContent).toBe('Y');
|
|
62
|
+
expect(btn.style.cssText).toContain('position:fixed');
|
|
63
|
+
expect(btn.style.cssText).toContain('z-index:99999');
|
|
64
|
+
// Draggable: pointer handlers wired.
|
|
65
|
+
expect(typeof btn._handlers['pointerdown']).toBe('function');
|
|
66
|
+
expect(typeof btn._handlers['pointerup']).toBe('function');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('is idempotent — a second mount does not stack a second icon', () => {
|
|
70
|
+
const { els } = installFakeDom();
|
|
71
|
+
const { YaverFeedback } = require('../YaverFeedback');
|
|
72
|
+
YaverFeedback.mountBrowserLaneIcon();
|
|
73
|
+
const first = els['yaver-feedback-btn'];
|
|
74
|
+
YaverFeedback.mountBrowserLaneIcon();
|
|
75
|
+
expect(els['yaver-feedback-btn']).toBe(first);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('no-ops when not in a browser lane', () => {
|
|
79
|
+
const { els } = installFakeDom();
|
|
80
|
+
(globalThis as any).window.__yaverLane = undefined;
|
|
81
|
+
const { YaverFeedback } = require('../YaverFeedback');
|
|
82
|
+
YaverFeedback.mountBrowserLaneIcon();
|
|
83
|
+
expect(els['yaver-feedback-btn']).toBeUndefined();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DogfoodController,
|
|
3
|
+
DogfoodRuntimeError,
|
|
4
|
+
defaultDogfoodLane,
|
|
5
|
+
dogfoodLaneOptions,
|
|
6
|
+
dogfoodLogLinesFromDevEvent,
|
|
7
|
+
validateDogfoodProject,
|
|
8
|
+
type DogfoodDriver,
|
|
9
|
+
type DogfoodProject,
|
|
10
|
+
} from '../DogfoodRuntime';
|
|
11
|
+
|
|
12
|
+
const expo: DogfoodProject = {
|
|
13
|
+
name: 'Example', workDir: '/workspace/example', framework: 'expo', lane: 'browser',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('DogfoodController', () => {
|
|
17
|
+
test('does no work before the explicit trigger', () => {
|
|
18
|
+
const driver: DogfoodDriver = { start: jest.fn(async () => ({ lane: 'browser' as const })) };
|
|
19
|
+
const controller = new DogfoodController(expo, driver);
|
|
20
|
+
expect(driver.start).not.toHaveBeenCalled();
|
|
21
|
+
expect(controller.snapshot().phase).toBe('idle');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('preserves raw npm output and hands a live session to the host', async () => {
|
|
25
|
+
const stop = jest.fn();
|
|
26
|
+
const closeLogs = jest.fn();
|
|
27
|
+
const controller = new DogfoodController(expo, {
|
|
28
|
+
async start(ctx) {
|
|
29
|
+
ctx.registerCleanup(stop, 'session');
|
|
30
|
+
ctx.registerCleanup(closeLogs, 'transient');
|
|
31
|
+
ctx.log('$ npm install --legacy-peer-deps');
|
|
32
|
+
ctx.log('npm warn deprecated example@1.0.0');
|
|
33
|
+
return { lane: 'browser', sessionId: 's1', url: 'http://agent/dev/' };
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await controller.trigger();
|
|
38
|
+
expect(controller.snapshot().logs.map((line) => line.text)).toEqual([
|
|
39
|
+
'$ npm install --legacy-peer-deps',
|
|
40
|
+
'npm warn deprecated example@1.0.0',
|
|
41
|
+
]);
|
|
42
|
+
expect(await controller.handoff()).toMatchObject({ sessionId: 's1' });
|
|
43
|
+
expect(closeLogs).toHaveBeenCalledTimes(1);
|
|
44
|
+
expect(stop).not.toHaveBeenCalled();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('cleans a partial session before exposing a structured failure', async () => {
|
|
48
|
+
const stop = jest.fn();
|
|
49
|
+
const controller = new DogfoodController(expo, {
|
|
50
|
+
async start(ctx) {
|
|
51
|
+
ctx.registerCleanup(stop);
|
|
52
|
+
throw new DogfoodRuntimeError({
|
|
53
|
+
code: 'DOGFOOD_RENDER_FAILED', error: 'Metro exited', remedy: 'Fix Metro and retry.', retryable: true,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
await expect(controller.trigger()).rejects.toThrow('Metro exited');
|
|
58
|
+
expect(stop).toHaveBeenCalledTimes(1);
|
|
59
|
+
expect(controller.snapshot()).toMatchObject({ phase: 'failed', failure: { code: 'DOGFOOD_RENDER_FAILED' } });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('an obsolete attempt cannot clean up the replacement attempt', async () => {
|
|
63
|
+
let releaseFirst!: () => void;
|
|
64
|
+
const firstGate = new Promise<void>((resolve) => { releaseFirst = resolve; });
|
|
65
|
+
let firstStarted!: () => void;
|
|
66
|
+
const firstStartedGate = new Promise<void>((resolve) => { firstStarted = resolve; });
|
|
67
|
+
const stopFirst = jest.fn();
|
|
68
|
+
const stopSecond = jest.fn();
|
|
69
|
+
let starts = 0;
|
|
70
|
+
const controller = new DogfoodController(expo, {
|
|
71
|
+
async start(ctx) {
|
|
72
|
+
starts += 1;
|
|
73
|
+
if (starts === 1) {
|
|
74
|
+
ctx.registerCleanup(stopFirst);
|
|
75
|
+
firstStarted();
|
|
76
|
+
await firstGate;
|
|
77
|
+
return { lane: 'browser', sessionId: 'old' };
|
|
78
|
+
}
|
|
79
|
+
ctx.registerCleanup(stopSecond);
|
|
80
|
+
return { lane: 'browser', sessionId: 'new' };
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const old = controller.trigger();
|
|
85
|
+
await firstStartedGate;
|
|
86
|
+
await controller.stop();
|
|
87
|
+
await expect(controller.trigger()).resolves.toMatchObject({ sessionId: 'new' });
|
|
88
|
+
releaseFirst();
|
|
89
|
+
await expect(old).rejects.toMatchObject({ failure: { code: 'DOGFOOD_ATTEMPT_REPLACED' } });
|
|
90
|
+
expect(stopFirst).toHaveBeenCalledTimes(1);
|
|
91
|
+
expect(stopSecond).not.toHaveBeenCalled();
|
|
92
|
+
await controller.stop();
|
|
93
|
+
expect(stopSecond).toHaveBeenCalledTimes(1);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('Dogfood lanes and console events', () => {
|
|
98
|
+
test('Flutter is first-class on browser but cannot be mislabeled Hermes', () => {
|
|
99
|
+
expect(validateDogfoodProject({ ...expo, framework: 'flutter', lane: 'browser' })).toBeNull();
|
|
100
|
+
expect(validateDogfoodProject({ ...expo, framework: 'flutter', lane: 'hermes' })?.code)
|
|
101
|
+
.toBe('DOGFOOD_HERMES_FRAMEWORK_UNSUPPORTED');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('uses one three-lane matrix with browser default for React Native and Flutter', () => {
|
|
105
|
+
const rn = dogfoodLaneOptions('expo', { nativeRuntimeAvailable: true });
|
|
106
|
+
expect(defaultDogfoodLane('expo')).toBe('browser');
|
|
107
|
+
expect(rn.map((option) => [option.lane, option.supported])).toEqual([
|
|
108
|
+
['browser', true], ['hermes', true], ['webrtc', true],
|
|
109
|
+
]);
|
|
110
|
+
const flutter = dogfoodLaneOptions('flutter', { nativeRuntimeAvailable: true });
|
|
111
|
+
expect(defaultDogfoodLane('flutter')).toBe('browser');
|
|
112
|
+
expect(flutter.find((option) => option.lane === 'hermes')?.supported).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('keeps Yaver self-development on the same RN three-lane contract', () => {
|
|
116
|
+
const options = dogfoodLaneOptions('expo', { nativeRuntimeAvailable: true, selfDevelopment: true });
|
|
117
|
+
expect(options).toHaveLength(3);
|
|
118
|
+
expect(options.find((option) => option.lane === 'hermes')).toMatchObject({ supported: true });
|
|
119
|
+
expect(options.find((option) => option.lane === 'webrtc')).toMatchObject({ supported: true });
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('native-only projects use WebRTC rather than fake browser or Hermes lanes', () => {
|
|
123
|
+
const swift = dogfoodLaneOptions('swift', { nativeRuntimeAvailable: true });
|
|
124
|
+
expect(swift.map((option) => [option.lane, option.supported])).toEqual([
|
|
125
|
+
['browser', false], ['hermes', false], ['webrtc', true],
|
|
126
|
+
]);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('reads raw and replayed package-manager logs from /dev/events', () => {
|
|
130
|
+
expect(dogfoodLogLinesFromDevEvent({ type: 'log', logLine: '$ npm ci\u001b[0m' }))
|
|
131
|
+
.toEqual(['$ npm ci\u001b[0m']);
|
|
132
|
+
expect(dogfoodLogLinesFromDevEvent({ type: 'snapshot', snapshot: { recentLogs: ['npm warn x', 'Metro ready'] } }))
|
|
133
|
+
.toEqual(['npm warn x', 'Metro ready']);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -159,7 +159,7 @@ describe('P2PClient', () => {
|
|
|
159
159
|
const bundle = {
|
|
160
160
|
metadata: {
|
|
161
161
|
timestamp: '2026-03-24T00:00:00Z',
|
|
162
|
-
|
|
162
|
+
deviceInfo: {
|
|
163
163
|
platform: 'ios',
|
|
164
164
|
osVersion: '18.0',
|
|
165
165
|
model: 'iPhone 16',
|
|
@@ -191,7 +191,7 @@ describe('P2PClient', () => {
|
|
|
191
191
|
const bundle = {
|
|
192
192
|
metadata: {
|
|
193
193
|
timestamp: '2026-03-24T00:00:00Z',
|
|
194
|
-
|
|
194
|
+
deviceInfo: { platform: 'ios', osVersion: '18', model: 'iPhone', screenWidth: 393, screenHeight: 852 },
|
|
195
195
|
app: {},
|
|
196
196
|
},
|
|
197
197
|
screenshots: [],
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { DogfoodController } from '../DogfoodRuntime';
|
|
2
|
+
import { createP2PDogfoodDriver } from '../P2PDogfoodDriver';
|
|
3
|
+
import type { P2PClient } from '../P2PClient';
|
|
4
|
+
|
|
5
|
+
describe('createP2PDogfoodDriver', () => {
|
|
6
|
+
it('keeps the browser lane compiling until the ordinary Projects status reports a URL', async () => {
|
|
7
|
+
const stop = jest.fn(async () => {});
|
|
8
|
+
const status = jest.fn()
|
|
9
|
+
.mockResolvedValueOnce({ building: true, framework: 'flutter' })
|
|
10
|
+
.mockResolvedValueOnce({ running: true, serving: true, framework: 'flutter', bundleUrl: '/dev/' });
|
|
11
|
+
const client = {
|
|
12
|
+
subscribeDogfoodDevEvents: (onEvent: (event: unknown) => void) => {
|
|
13
|
+
onEvent({ type: 'log', logLine: '$ flutter run -d web-server' });
|
|
14
|
+
return jest.fn();
|
|
15
|
+
},
|
|
16
|
+
startDogfoodDevServer: jest.fn(async () => ({ starting: true, framework: 'flutter' })),
|
|
17
|
+
getDogfoodDevServerStatus: status,
|
|
18
|
+
stopDogfoodDevServer: stop,
|
|
19
|
+
resolveDogfoodUrl: (path: string) => `http://agent.test${path}`,
|
|
20
|
+
} as unknown as P2PClient;
|
|
21
|
+
const snapshots: string[][] = [];
|
|
22
|
+
const controller = new DogfoodController(
|
|
23
|
+
{ name: 'Flutter app', framework: 'flutter', workDir: '/workspace/app', lane: 'browser' },
|
|
24
|
+
createP2PDogfoodDriver(client, { pollIntervalMs: 1, startupTimeoutMs: 100 }),
|
|
25
|
+
{ onChange: (snapshot) => snapshots.push(snapshot.logs.map((line) => line.text)) },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const result = await controller.trigger();
|
|
29
|
+
|
|
30
|
+
expect(result.url).toBe('http://agent.test/dev/');
|
|
31
|
+
expect(status).toHaveBeenCalledTimes(2);
|
|
32
|
+
expect(snapshots.flat()).toContain('$ flutter run -d web-server');
|
|
33
|
+
expect(stop).not.toHaveBeenCalled();
|
|
34
|
+
await controller.stop();
|
|
35
|
+
expect(stop).toHaveBeenCalledTimes(1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('starts and cleans up an available native WebRTC runtime', async () => {
|
|
39
|
+
const closeRuntime = jest.fn(async () => {});
|
|
40
|
+
const client = {
|
|
41
|
+
subscribeDogfoodDevEvents: () => jest.fn(),
|
|
42
|
+
getDogfoodRemoteRuntimeCapabilities: jest.fn(async () => ({
|
|
43
|
+
targets: [
|
|
44
|
+
{ id: 'browser-window', label: 'Browser', enabled: true },
|
|
45
|
+
{ id: 'ios-simulator', label: 'iPhone simulator', enabled: true },
|
|
46
|
+
],
|
|
47
|
+
})),
|
|
48
|
+
startDogfoodRemoteRuntime: jest.fn(async () => ({
|
|
49
|
+
id: 'runtime-1', status: 'starting', targetId: 'ios-simulator',
|
|
50
|
+
})),
|
|
51
|
+
stopDogfoodRemoteRuntime: closeRuntime,
|
|
52
|
+
} as unknown as P2PClient;
|
|
53
|
+
const controller = new DogfoodController(
|
|
54
|
+
{ name: 'Native app', framework: 'flutter', workDir: '/workspace/app', lane: 'webrtc' },
|
|
55
|
+
createP2PDogfoodDriver(client),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
await expect(controller.trigger()).resolves.toMatchObject({ lane: 'webrtc', sessionId: 'runtime-1' });
|
|
59
|
+
expect(closeRuntime).not.toHaveBeenCalled();
|
|
60
|
+
await controller.stop();
|
|
61
|
+
expect(closeRuntime).toHaveBeenCalledWith('runtime-1');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('delivers Hermes without stopping an unrelated dev server on exit', async () => {
|
|
65
|
+
const stop = jest.fn(async () => {});
|
|
66
|
+
const client = {
|
|
67
|
+
subscribeDogfoodDevEvents: () => jest.fn(),
|
|
68
|
+
startDogfoodDevServer: jest.fn(async () => ({ running: true, framework: 'expo', workDir: '/workspace/app' })),
|
|
69
|
+
stopDogfoodDevServer: stop,
|
|
70
|
+
} as unknown as P2PClient;
|
|
71
|
+
const controller = new DogfoodController(
|
|
72
|
+
{ name: 'RN app', framework: 'expo', workDir: '/workspace/app', lane: 'hermes' },
|
|
73
|
+
createP2PDogfoodDriver(client),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
await expect(controller.trigger()).resolves.toMatchObject({ lane: 'hermes', metadata: { delivered: true } });
|
|
77
|
+
await controller.stop();
|
|
78
|
+
expect(stop).not.toHaveBeenCalled();
|
|
79
|
+
});
|
|
80
|
+
});
|