fix(webui): sp17 review 2, a new step typed in the add form is not dropped by Save: the bar's Save with a typed new step says it is not added yet, keeps the form and puts the caret in its title, and an add form with nothing typed is closed and the rest saved; test types a new step and presses the bar's Save, sees the words and no write, then adds the step and sees all three in the write (red before: Save wrote without the new step and said Saved); the pack apply test waits for the autonomy read as well as the workflows read, as it answered later on a loaded host (#1873, lane sp17-workflow-clicks)
This commit was merged in pull request #1982.
This commit is contained in:
1 parent
24551c9eea
commit
6fe3625fae
3 files changed
+34
-1
No files matched your search
@@ -547,6 +547,7 @@
|
||||
// dropped when the answer redraws the form. Drawn off when busy; a held form (data-live-hold) is set here.
|
||||
const lockForms = off => document.querySelectorAll('#bus-view [data-wfg-page] :is([data-wfg-step-form],[data-wfg-meta-form])').forEach(f =>
|
||||
f.querySelectorAll('input[name="title"],textarea,select,[data-wfg-roles-pick]').forEach(c => { c.disabled = off; }));
|
||||
const toAddTitle = () => document.querySelector('#bus-view [data-wfg-page] [data-wfg-add-form] input[name="title"]')?.focus();
|
||||
// Put focus back in the step form's title after a refusal (the form may be a held node).
|
||||
const toTitle = () => { const f = stepFormEl()?.elements.title; if (f) { f.focus(); f.setSelectionRange(f.value.length, f.value.length); } };
|
||||
|
||||
@@ -618,6 +619,15 @@
|
||||
async function save({ org, name, scope, s, key }) {
|
||||
const d = drafts.get(key);
|
||||
if (!d || d.busy) return;
|
||||
// SP17 review: a new step typed in the add form is not saved over or dropped: Save says so and keeps the
|
||||
// form. An add form with nothing typed in it is closed and the rest is saved.
|
||||
if (d.edit?.mode === 'add') {
|
||||
if (d.edit.title.trim() || d.edit.roles.length) {
|
||||
d.atBar = false; d.status = `Not saved: new step ${d.edit.i + 1} is not added yet. Press Add step, or Cancel to drop it.`;
|
||||
say(d.status); paint(); return toAddTitle();
|
||||
}
|
||||
d.edit = null;
|
||||
}
|
||||
// SP17: the open step's edit goes in with the save; one the save check refuses stays in its form.
|
||||
const unfit = carry(d);
|
||||
d.atBar = false;
|
||||
|
||||
@@ -124,7 +124,8 @@ test('E2E6 P2-2: a pack apply re-reads the other sections and keeps its receipt'
|
||||
const before = { ...counts };
|
||||
await b.evaluate(`document.querySelector('[data-pack-apply]').click();true`);
|
||||
await waitFor(b, `/^Applied\\./.test(document.querySelector('[data-packs-status]')?.textContent??'')`, 'apply');
|
||||
for (let i = 0; i < 300 && counts.workflows === before.workflows; i++) await new Promise(r => setTimeout(r, 30));
|
||||
// Both reads are waited for: the autonomy read can answer after the workflows read on a loaded host.
|
||||
for (let i = 0; i < 300 && (counts.workflows === before.workflows || counts.autonomy === before.autonomy); i++) await new Promise(r => setTimeout(r, 30));
|
||||
assert.ok(counts.workflows > before.workflows, 'workflows read again after the apply');
|
||||
assert.ok(counts.autonomy > before.autonomy, 'autonomy read again after the apply');
|
||||
await b.evaluate(`new Promise(r=>setTimeout(()=>r(true),300))`);
|
||||
|
||||
@@ -975,3 +975,25 @@ test('SP17: while a Save is in flight the form takes no typing, and takes it aga
|
||||
assert.deepEqual(await b.evaluate(fields), [false, false, false], 'on again after a refusal');
|
||||
assert.equal(await b.evaluate(`document.querySelector('${form} input[name="title"]').value`), 'Ship again');
|
||||
});
|
||||
|
||||
// SP17 review 2 P2-1: a new step typed in the add form is not dropped by the bar's Save: Save says it is not
|
||||
// added yet and keeps the form; once added, Save sends it.
|
||||
test('SP17: the bar Save with a new step typed in the add form says so and keeps it, and saves it once added', { timeout: 60000 }, async t => {
|
||||
const { b, wait, st } = await setup(t, { path: '#/orgs/acme/workflows/change?project=site&step=1' });
|
||||
await retitle(b, wait, 1, 'Build it');
|
||||
await b.evaluate(press('[data-wfg-add]'));
|
||||
await wait(`!!document.querySelector('[data-wfg-add-form]')`, 'add form');
|
||||
await b.evaluate(fill('[data-wfg-add-form] input[name="title"]', 'Check'));
|
||||
await b.evaluate(`document.querySelector('[data-wfg-add-form] input[name="role"][value="human"]').click();true`);
|
||||
await b.evaluate(press('[data-wfg-bar] [data-wfg-save]'));
|
||||
await wait(`/new step 2 is not added yet/.test(${text('[data-wfg-bar] [data-wfg-status]')})`, 'refused in words');
|
||||
assert.equal(st.writes.length, 0, 'nothing written');
|
||||
assert.equal(await b.evaluate(`document.querySelector('[data-wfg-add-form] input[name="title"]')?.value`), 'Check', 'the typed step is kept');
|
||||
assert.equal(await b.evaluate(`document.activeElement === document.querySelector('[data-wfg-add-form] input[name="title"]')`), true, 'focus in the new step');
|
||||
assert.equal(await b.evaluate(`window.MosaicWorkflows.hasDraft()`), true);
|
||||
await b.evaluate(press('[data-wfg-add-step]'));
|
||||
await wait(`${titles}.length === 3`, 'step added');
|
||||
await b.evaluate(press('[data-wfg-save]'));
|
||||
await wait(`/Saved change\\./.test(${text('[data-wfg-status]')})`, 'saved');
|
||||
assert.deepEqual(st.writes.at(-1).args.workflow.steps.map(s => [s.title, s.roles]), [['Build it', ['coder']], ['Check', ['human']], ['Ship', ['human']]]);
|
||||
});
|
||||
Reference in new issue
Block a user