fix(webui): settings-s5c recheck: the status load says whether it painted the answer, and the result after an off says the list above is read again only then; a status read that answers 200 with null, an empty object or a page that is not JSON now says the list may be out of date, with Read again, instead of claiming the list is new (recheck P3); tests red on c47f9a3bd (#1873, lane settings-s5c)
This commit was merged in pull request #2011.
This commit is contained in:
1 parent
4d378fc38b
commit
ebfbdb13a0
2 files changed
+11
-7
No files matched your search
@@ -1501,9 +1501,9 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
const view = offView; if (!view) return;
|
||||
view.reread = 'reading'; paintOffResult();
|
||||
while (loading) await pause(50);
|
||||
const before = state; await load();
|
||||
const painted = await load();
|
||||
if (offView !== view) return;
|
||||
view.reread = state !== before ? 'ok' : 'failed'; paintOffResult();
|
||||
view.reread = painted ? 'ok' : 'failed'; paintOffResult();
|
||||
const box = $('proxy-setup-programs-result');
|
||||
if (fromButton || document.activeElement === document.body || !document.activeElement) (view.reread === 'failed' ? $('proxy-setup-programs-reread') : box)?.focus();
|
||||
}
|
||||
@@ -1666,11 +1666,13 @@ if (document.documentElement.hasAttribute('data-settings-proxy-document') && !lo
|
||||
document.dispatchEvent(new CustomEvent('mosaic-proxy-status', { detail: state }));
|
||||
focusStep();
|
||||
}
|
||||
// True once the answer is painted, so a caller can say the list on the page is the new one.
|
||||
async function load() {
|
||||
if (!enabled || loading) return; loading = true;
|
||||
try { state = await admin('status'); causeRound++; if (state.next?.[0] === 'accounts' && triageSet === null) await readTriage(); paint(); if (state.init.initialized) await accountsReady(); }
|
||||
if (!enabled || loading) return false; loading = true; let painted = false;
|
||||
try { state = await admin('status'); causeRound++; if (state.next?.[0] === 'accounts' && triageSet === null) await readTriage(); paint(); painted = true; if (state.init.initialized) await accountsReady(); }
|
||||
catch (error) { say(error.message, 'error'); }
|
||||
finally { loading = false; }
|
||||
return painted;
|
||||
}
|
||||
async function act(label, action) {
|
||||
if (!sendOk || state?.busy || chain?.running) return;
|
||||
|
||||
@@ -85,7 +85,7 @@ const stub = ({ owner = true, status = SERVICE_UP, admin = {} } = {}) => `(() =>
|
||||
if (at >= 0) {
|
||||
const name = path.slice(at + 13) + url.search; window.__admin.push(method + ' ' + name);
|
||||
if (method !== 'GET') window.__writes.push({ path, body: init.body ?? null });
|
||||
if (name === 'status') { const s = next(__s5c.status); return s.status ? json(s.body, s.status) : json(s); }
|
||||
if (name === 'status') { const s = next(__s5c.status); if (s === null || typeof s !== 'object') return json(s); if (typeof s.raw === 'string') return new Response(s.raw, { status: 200, headers: { 'content-type': 'text/html' } }); return s.status ? json(s.body, s.status) : json(s); }
|
||||
const a = next(__s5c.admin[method === 'GET' ? name : method + ' ' + name]);
|
||||
if (!a) return json({ error: 'fixture-unexpected-api' }, 403);
|
||||
if (a.throws) throw new TypeError('Failed to fetch');
|
||||
@@ -277,8 +277,9 @@ test('settings-s5c: focus goes to the result after a busy answer too', { timeout
|
||||
assert.equal(await b.evaluate('document.activeElement?.id'), 'proxy-setup-programs-result');
|
||||
});
|
||||
|
||||
test('settings-s5c: when the status read after an off fails, the result says the list may be out of date, and Read again reads it', { timeout: 90000 }, async t => {
|
||||
const down = { status: 503, body: { error: 'outcome-unknown' } };
|
||||
test('settings-s5c: when the status read after an off fails, or answers with no status, the result says the list may be out of date, and Read again reads it', { timeout: 180000 }, async t => {
|
||||
// A refusal, and three answers that are 200 but not a status: null, an empty object, a page that is not JSON.
|
||||
for (const down of [{ status: 503, body: { error: 'outcome-unknown' } }, null, {}, { raw: '<html><body>Gateway</body></html>' }]) {
|
||||
const { b, wait, click, admin } = await setup(t, { admin: { 'POST programs/off': { name: 'zeta-runner', results: [{ id: 'acme', outcome: 'failed:outcome-unknown' }], receipt: null } } });
|
||||
await wait(READY); await openAdvanced(b);
|
||||
await wait('document.querySelector("[data-program-off=zeta-runner]")');
|
||||
@@ -297,6 +298,7 @@ test('settings-s5c: when the status read after an off fails, the result says the
|
||||
assert.equal((await programs(b))[1].text, 'On in no organization. Off in Acme Studio and Lab Bench. Not known in Gamma Home: its list could not be read.');
|
||||
assert.equal(await b.evaluate('document.querySelector("#proxy-setup-programs-reread")'), null);
|
||||
assert.equal(await b.evaluate('document.activeElement?.id'), 'proxy-setup-programs-result');
|
||||
}
|
||||
});
|
||||
|
||||
test('settings-s5c: a status read that drops the program being asked about, or cannot list programs, drops the question and frees the buttons', { timeout: 90000 }, async t => {
|
||||
|
||||
Reference in new issue
Block a user