group code popup
Sonarqube Scanner / Prepare environment (push) Successful in 6s
Sonarqube Scanner / Build and test (push) Successful in 27s
Sonarqube Scanner / SonarQube analysis (push) Failing after 1m14s
Sonarqube Scanner / Deploy to Server (push) Successful in 10s

This commit is contained in:
Florian Zumpe
2026-10-18 17:24:41 +02:00
parent 31768ae907
commit 0e4cdfbd54
18 changed files with 400 additions and 49 deletions
+22 -1
View File
@@ -41,7 +41,8 @@ async function harness(records = new Map()) {
const body = JSON.parse(options.body); calls.push({ url, body });
if (controls.offline) throw new TypeError('offline');
let status = 200, payload;
if (body.release) payload = { released: true };
if (body.heartbeat && !controls.locked) { status = 204; payload = {}; }
else if (body.release) payload = { released: true };
else if (controls.locked && !body.replace) { status = 423; payload = { details: { code: 'point-locked', replace: 'old-secret' } }; }
else payload = { token: 'our-secret', version: controls.version, mediaVersion: controls.mediaVersion, poi: structuredClone(poi) };
return { ok: status === 200, status, json: async () => payload };
@@ -131,3 +132,23 @@ test('offline drafts remain editable without claiming a server lock and a late l
assert.equal(await opening, null);
assert.equal(Object.keys(h.api.headersFor('/routes/7/pois/8')).length, 0);
});
test('only actual editor activity refreshes a point lock, while passive time and status checks do not', async () => {
const h = await harness();
await h.api.begin(7, h.poi);
await h.api.keepActive();
assert.equal(h.calls.filter(call => call.body.heartbeat).length, 0);
h.api.noteActivity(); await h.api.keepActive(); await h.api.keepActive();
assert.equal(h.calls.filter(call => call.body.heartbeat).length, 1);
assert.equal(h.api.headersFor('/routes/7/pois/8')['If-Poi-Match'], 'v1');
h.controls.offline = true;
h.api.noteActivity(); await h.api.keepActive();
h.controls.offline = false; await h.api.keepActive();
assert.equal(h.calls.filter(call => call.body.heartbeat).length, 3);
let lost = 0; h.context.document.addEventListener('wegwichtel:point-lock-lost', () => { lost += 1; });
h.controls.locked = true; h.api.noteActivity(); await h.api.keepActive();
assert.equal(lost, 1);
assert.equal(h.calls.at(-1).body.heartbeat, true);
assert.equal(h.calls.at(-1).body.replace, undefined);
});