Skip to content

Commit bdda746

Browse files
committed
test(integration): run the raw file push from inside the claiming workspace
#3345's coverage rule pairs the routed session with the workspace that took the claim. The raw push request carried a temp cwd, so it routed under another workspace, and the open session's claim no longer covered it. Running it from a directory of the checkout reproduces the real CLI owner shape the client calls above already form, and keeps the relative payload resolution the test is for. Probe evidence at the pre-fix commit: the push refused with DEVICE_CLAIM_LIVE_OWNER naming the checkout workspace.
1 parent 744f211 commit bdda746

1 file changed

Lines changed: 44 additions & 30 deletions

File tree

‎test/integration/provider-scenarios/android-lifecycle.test.ts‎

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -442,36 +442,50 @@ async function runAndroidSetupAndInstallWorkflow(
442442
}),
443443
'utf8',
444444
);
445-
const filePush = await daemon.callCommand(
446-
'push',
447-
['com.example.demo', './payload.json'],
448-
selection,
449-
{
450-
meta: { cwd: tempRoot },
451-
},
452-
);
453-
assert.equal(filePush.json.result.data.package, 'com.example.demo');
454-
assert.equal(filePush.json.result.data.action, 'com.example.demo.FILE_PUSH');
455-
assert.equal(filePush.json.result.data.extrasCount, 1);
456-
457-
const bracePayloadPath = path.join(tempRoot, '{payload}.json');
458-
fs.writeFileSync(
459-
bracePayloadPath,
460-
JSON.stringify({
461-
action: 'com.example.demo.BRACE_PUSH',
462-
extras: { source: 'brace-file' },
463-
}),
464-
'utf8',
465-
);
466-
const braceFilePush = await daemon.callCommand(
467-
'push',
468-
['com.example.demo', './{payload}.json'],
469-
selection,
470-
{ meta: { cwd: tempRoot } },
471-
);
472-
assert.equal(braceFilePush.json.result.data.package, 'com.example.demo');
473-
assert.equal(braceFilePush.json.result.data.action, 'com.example.demo.BRACE_PUSH');
474-
assert.equal(braceFilePush.json.result.data.extrasCount, 1);
445+
// #3345: a raw request routes to the implicit session of the workspace its `cwd` sits in,
446+
// and a claim covers only the session-and-workspace pair that took it. The client calls
447+
// above sent no cwd, so the open claimed this process's own workspace (the checkout) at
448+
// the `default` address. This push joins that address the way `--session` does and runs
449+
// from a directory inside the checkout: the canonical scope root is the worktree root from
450+
// either directory, so coverage holds the way it holds for a real CLI owner, and the
451+
// relative payload still resolves against `cwd`. A cwd in another workspace would refuse
452+
// even under the same session name — that is the copyable-address rule.
453+
fs.mkdirSync(path.join(process.cwd(), '.tmp'), { recursive: true });
454+
const callerWorkspace = fs.mkdtempSync(path.join(process.cwd(), '.tmp', 'push-'));
455+
try {
456+
fs.cpSync(pushPayloadPath, path.join(callerWorkspace, 'payload.json'));
457+
const filePush = await daemon.callCommand(
458+
'push',
459+
['com.example.demo', './payload.json'],
460+
selection,
461+
{ meta: { cwd: callerWorkspace, sessionExplicit: true } },
462+
);
463+
assert.equal(filePush.json.result.data.package, 'com.example.demo');
464+
assert.equal(filePush.json.result.data.action, 'com.example.demo.FILE_PUSH');
465+
assert.equal(filePush.json.result.data.extrasCount, 1);
466+
467+
const bracePayloadPath = path.join(tempRoot, '{payload}.json');
468+
fs.writeFileSync(
469+
bracePayloadPath,
470+
JSON.stringify({
471+
action: 'com.example.demo.BRACE_PUSH',
472+
extras: { source: 'brace-file' },
473+
}),
474+
'utf8',
475+
);
476+
fs.cpSync(bracePayloadPath, path.join(callerWorkspace, '{payload}.json'));
477+
const braceFilePush = await daemon.callCommand(
478+
'push',
479+
['com.example.demo', './{payload}.json'],
480+
selection,
481+
{ meta: { cwd: callerWorkspace, sessionExplicit: true } },
482+
);
483+
assert.equal(braceFilePush.json.result.data.package, 'com.example.demo');
484+
assert.equal(braceFilePush.json.result.data.action, 'com.example.demo.BRACE_PUSH');
485+
assert.equal(braceFilePush.json.result.data.extrasCount, 1);
486+
} finally {
487+
fs.rmSync(callerWorkspace, { recursive: true, force: true });
488+
}
475489

476490
const clipboard = await client.command.clipboard({ action: 'read', ...selection });
477491
if (clipboard.action !== 'read') throw new Error('expected clipboard read result');

0 commit comments

Comments
 (0)