From 19b9bc2dbe1f99eb2886f5492141557983338c4e Mon Sep 17 00:00:00 2001 From: saphid <4596216+saphid@users.noreply.github.com> Date: Sun, 27 Sep 2026 17:43:49 +1000 Subject: [PATCH] E2E: follow background jobs for Flatpak installs The tabs UI (#4) runs Flatpak installs as server.start_job jobs, so a failed install answers 200 with a job id and reports the error on /api/job. The test now waits for the job instead of expecting an immediate 502. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/e2e/harness.py | 6 ++++++ tests/e2e/test_device.py | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/e2e/harness.py b/tests/e2e/harness.py index 9a0818d..1328f96 100644 --- a/tests/e2e/harness.py +++ b/tests/e2e/harness.py @@ -152,6 +152,12 @@ def ok(method, path, body=None, **kw): return out +def finished(started, timeout=60): + """Wait for a background job (server.start_job's {"job": id}); returns its final state.""" + return wait_for(lambda: (lambda j: j['done'] and j)(ok('GET', f"/api/job?id={started['job']}")), + timeout, f"job {started['job']}") + + def upload(path, mode, name=None): with open(path, 'rb') as f: data = f.read() diff --git a/tests/e2e/test_device.py b/tests/e2e/test_device.py index 5888ce0..e649e02 100644 --- a/tests/e2e/test_device.py +++ b/tests/e2e/test_device.py @@ -3,7 +3,7 @@ through the server against the fake Frame.""" import unittest import harness -from harness import api, ctl, launches, ok, state, wait_for +from harness import api, ctl, finished, launches, ok, state, wait_for harness.require() @@ -46,13 +46,14 @@ class Device(harness.FrameTestCase): self.assertEqual(state()['clipboard'], [text]) def test_flatpak_install_and_remove(self): - ok('POST', '/api/flatpak', {'id': 'org.videolan.VLC', 'action': 'install'}) + # Installs run as background jobs (server.start_job); uninstall answers at once. + job = finished(ok('POST', '/api/flatpak', {'id': 'org.videolan.VLC', 'action': 'install'})) + self.assertIsNone(job['error'], job) self.assertEqual([f['id'] for f in ok('GET', '/api/status')['flatpaks']], ['org.videolan.VLC']) ok('POST', '/api/flatpak', {'id': 'org.videolan.VLC', 'action': 'uninstall'}) self.assertEqual(state()['flatpaks'], []) - status, out, _ = api('POST', '/api/flatpak', {'id': 'org.example.missing', 'action': 'install'}) - self.assertEqual(status, 502) - self.assertIn('Nothing matches org.example.missing', out['error']) + job = finished(ok('POST', '/api/flatpak', {'id': 'org.example.missing', 'action': 'install'})) + self.assertIn('Nothing matches org.example.missing', job['error']) def test_desktop_capture(self): status, png, headers = api('GET', '/api/screenshot')