Skip to content

Commit bcc08ae

Browse files
committed
test: cover save-script force retargeting
1 parent e2bb891 commit bcc08ae

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎src/daemon/handlers/__tests__/session-script-publication.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ test('no-clobber failure preserves bytes and armed state, then --force retries s
114114
expect(session.scriptRecordingState).toBe('published');
115115
});
116116

117+
test('retargeting without --force clears force authorization from the previous target', () => {
118+
const originalPath = path.join(root, 'original.ad');
119+
const retargetPath = path.join(root, 'retarget.ad');
120+
fs.writeFileSync(retargetPath, 'protected\n');
121+
const session = armedSession({
122+
saveScriptPath: originalPath,
123+
saveScriptForce: true,
124+
});
125+
store.set('authoring', session);
126+
127+
const response = handleSessionScriptPublication({
128+
req: request(retargetPath),
129+
sessionName: 'authoring',
130+
sessionStore: store,
131+
});
132+
133+
expect(response).toMatchObject({ ok: false, error: { retriable: true } });
134+
expect(fs.readFileSync(retargetPath, 'utf8')).toBe('protected\n');
135+
expect(session.scriptRecordingState).toBe('armed');
136+
expect(session.saveScriptPath).toBe(retargetPath);
137+
expect(session.saveScriptForce).toBeUndefined();
138+
});
139+
117140
test('refuses unarmed and repair-owned sessions before filesystem work', () => {
118141
const outputPath = path.join(root, 'missing', 'screen-x.ad');
119142
store.set('authoring', makeIosSession('authoring'));

0 commit comments

Comments
 (0)