This commit is contained in:
@@ -140,6 +140,35 @@ test('portal helper reports a notify fallback as ready', async () => {
|
||||
assert.equal((await grant).backend, 'portal-notify');
|
||||
});
|
||||
|
||||
test('Grant desktop starts a fresh helper and asks GNOME instead of restoring a share', async () => {
|
||||
let env;
|
||||
const child = helper();
|
||||
const input = new PortalInputBackend({ spawnImpl: (_cmd, _args, opts) => { env = opts.env; return child; } });
|
||||
const grant = input.grant({ persist: false, mode: 'act' });
|
||||
assert.equal(env.JARVIS_CU_PERSIST, '0');
|
||||
assert.equal(env.JARVIS_CU_MODE, 'act');
|
||||
const source = await import('node:fs/promises').then((fs) => fs.readFile(new URL('../computer-use/py/portal_remote_desktop.py', import.meta.url), 'utf8'));
|
||||
assert.match(source, /PERSIST_MODE = 2 if PERSIST else 0/);
|
||||
assert.match(source, /request\(screencast, 'SelectSources', '\(oa\{sv\}\)', \(session,/);
|
||||
assert.match(source, /results = request\(remote, 'Start'/);
|
||||
input.revoke();
|
||||
await assert.rejects(grant, /revoked/);
|
||||
});
|
||||
|
||||
test('revoke then Grant desktop starts a new portal helper', async () => {
|
||||
const children = [];
|
||||
const input = new PortalInputBackend({ spawnImpl: () => { const child = helper(); children.push(child); return child; } });
|
||||
const first = input.grant({ persist: false });
|
||||
children[0].stdout.emit('data', '{"type":"ready","backend":"portal-ei","screen":true}\n');
|
||||
await first;
|
||||
input.revoke();
|
||||
assert.equal(children[0].killed, true);
|
||||
const second = input.grant({ persist: false });
|
||||
assert.equal(children.length, 2);
|
||||
children[1].stdout.emit('data', '{"type":"ready","backend":"portal-ei","screen":true}\n');
|
||||
assert.equal((await second).screen, true);
|
||||
});
|
||||
|
||||
test('portal helper returns a PipeWire frame without ending the grant', async () => {
|
||||
const child = helper(); let written = '';
|
||||
child.stdin.write = (chunk) => { written += String(chunk); };
|
||||
|
||||
Reference in New Issue
Block a user