Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,3 +48,50 @@ test('click-triggered session capture uses the low-latency hide pause', async ()
|
||||
refocus: false,
|
||||
});
|
||||
});
|
||||
|
||||
test('click-triggered session capture prefers the cached frame when ready', async () => {
|
||||
const service = makeService();
|
||||
service.settings.get = (key) => {
|
||||
if (key === 'capture.mode') return 'fullscreen';
|
||||
if (key === 'capture.delayMs') return 0;
|
||||
if (key === 'capture.clickMarker') return true;
|
||||
if (key === 'capture.clickMarkerColor') return '#E5484D';
|
||||
if (key === 'editor.focusedViewDefaultForNewSteps') return false;
|
||||
return null;
|
||||
};
|
||||
service.session = { guideId: 'guide-2', paused: false, count: 0, intervalSec: 0 };
|
||||
service.captureCache = {
|
||||
mode: 'fullscreen',
|
||||
png: Buffer.from('cached-png'),
|
||||
size: { width: 120, height: 80 },
|
||||
display: { bounds: { x: 10, y: 20, width: 120, height: 80 } },
|
||||
cursor: { x: 70, y: 40 },
|
||||
capturedAt: Date.now(),
|
||||
};
|
||||
|
||||
let shootCalled = false;
|
||||
service.shoot = async () => {
|
||||
shootCalled = true;
|
||||
throw new Error('fresh shot should not run when cache is ready');
|
||||
};
|
||||
|
||||
const added = [];
|
||||
service.store.addStep = (guideId, fields, png, size) => {
|
||||
added.push({ guideId, fields, png, size });
|
||||
return { stepId: 'step-2', ...fields };
|
||||
};
|
||||
service.notify = (channel, payload) => {
|
||||
added.push({ channel, payload });
|
||||
};
|
||||
|
||||
const result = await service.sessionCapture('click');
|
||||
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(shootCalled, false);
|
||||
assert.equal(service.session.count, 1);
|
||||
assert.equal(added[0].guideId, 'guide-2');
|
||||
assert.deepEqual(added[0].png, Buffer.from('cached-png'));
|
||||
assert.deepEqual(added[0].size, { width: 120, height: 80 });
|
||||
assert.equal(added[0].fields.annotations.length, 1);
|
||||
assert.equal(added[0].fields.annotations[0].type, 'oval');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user