diff --git a/docs/TEST_INTEGRITY.md b/docs/TEST_INTEGRITY.md index 12aa8aa..2236954 100644 --- a/docs/TEST_INTEGRITY.md +++ b/docs/TEST_INTEGRITY.md @@ -2573,7 +2573,7 @@ test_integrity_note: - id: SCN-console-priority-preview-invalidates-on-newer-evidence given: "A task priority preview and unsent priority and reason values are created from task evidence revision N" when: "A separate confirmed sample API action advances that task to authoritative revision N+1, then the reader refreshes again after navigating away and back" - then: "The revision N token, preview, and confirmation control remain absent; revision N+1 is visible, the unsent values remain intact and editable across both refreshes, and a new preview is bound to N+1" + then: "The revision N token, preview, and confirmation control remain absent; revision N+1 is visible, the unsent values remain intact and editable across both refreshes, a new preview is bound to N+1, and that current preview survives another unchanged refresh" - id: SCN-console-current-preview-and-draft-survive-unchanged-refresh given: "A task has an active priority preview and unsent priority and reason values bound to its current evidence revision" when: "Console refresh returns the same task revision" diff --git a/scripts/test-dashboard-demo.mjs b/scripts/test-dashboard-demo.mjs index d6ec93c..a54771c 100644 --- a/scripts/test-dashboard-demo.mjs +++ b/scripts/test-dashboard-demo.mjs @@ -343,30 +343,33 @@ try { await selectView(stalePage, 'work'); await stalePage.locator('#refresh-console').click(); await stalePage.locator('#live-refresh-status[data-generation="3"]').waitFor(); - assert.equal(Number(await refreshedForm.getAttribute('data-revision')), revisionN1); - assert.equal(await refreshedTicket.locator('.priority').textContent(), 'low'); - assert.equal(await refreshedForm.getAttribute('data-preview-token'), null); - assert.equal(await refreshedForm.locator('[data-priority-preview]').isVisible(), false); - assert.equal(await refreshedForm.locator('[data-priority-confirm]').count(), 0); - assert.equal(await refreshedForm.locator('[name="priority"]').inputValue(), 'urgent'); - assert.equal(await refreshedForm.locator('[name="reason"]').inputValue(), 'Review this change against the current task evidence.'); - assert.equal(await refreshedForm.locator('[name="priority"]').isDisabled(), false); - assert.equal(await refreshedForm.locator('[name="reason"]').isDisabled(), false); - await refreshedTicket.locator('.priority-change > summary').click(); - await refreshedForm.getByRole('button', { name: 'Review change', exact: true }).click(); - await refreshedForm.locator('[data-priority-confirm]').waitFor(); - assert.equal(await refreshedForm.locator('[data-priority-preview]').locator('dd').nth(2).innerText(), String(revisionN1)); - assert.notEqual(await refreshedForm.getAttribute('data-preview-token'), staleToken, + const preservedForm = stalePage.locator('.priority-change-form[data-task-id="API-08"]'); + const preservedTicket = preservedForm.locator('xpath=../..'); + assert.equal(Number(await preservedForm.getAttribute('data-revision')), revisionN1); + assert.equal(await preservedTicket.locator('.priority').textContent(), 'low'); + assert.equal(await preservedForm.getAttribute('data-preview-token'), null); + assert.equal(await preservedForm.locator('[data-priority-preview]').isVisible(), false); + assert.equal(await preservedForm.locator('[data-priority-confirm]').count(), 0); + assert.equal(await preservedForm.locator('[name="priority"]').inputValue(), 'urgent'); + assert.equal(await preservedForm.locator('[name="reason"]').inputValue(), 'Review this change against the current task evidence.'); + assert.equal(await preservedForm.locator('[name="priority"]').isDisabled(), false); + assert.equal(await preservedForm.locator('[name="reason"]').isDisabled(), false); + await preservedTicket.locator('.priority-change > summary').click(); + await preservedForm.getByRole('button', { name: 'Review change', exact: true }).click(); + await preservedForm.locator('[data-priority-confirm]').waitFor(); + assert.equal(await preservedForm.locator('[data-priority-preview]').locator('dd').nth(2).innerText(), String(revisionN1)); + assert.notEqual(await preservedForm.getAttribute('data-preview-token'), staleToken, 'a current preview must be regenerated from revision N+1'); - const currentToken = await refreshedForm.getAttribute('data-preview-token'); + const currentToken = await preservedForm.getAttribute('data-preview-token'); await stalePage.locator('#refresh-console').click(); await stalePage.locator('#live-refresh-status[data-generation="4"]').waitFor(); - assert.equal(await refreshedForm.getAttribute('data-preview-token'), currentToken, + const currentForm = stalePage.locator('.priority-change-form[data-task-id="API-08"]'); + assert.equal(await currentForm.getAttribute('data-preview-token'), currentToken, 'unchanged current evidence must retain its active preview'); - assert.equal(await refreshedForm.locator('[data-priority-preview]').isVisible(), true); - assert.equal(await refreshedForm.locator('[data-priority-confirm]').isVisible(), true); - assert.equal(await refreshedForm.locator('[name="priority"]').inputValue(), 'urgent'); - assert.equal(await refreshedForm.locator('[name="reason"]').inputValue(), 'Review this change against the current task evidence.'); + assert.equal(await currentForm.locator('[data-priority-preview]').isVisible(), true); + assert.equal(await currentForm.locator('[data-priority-confirm]').isVisible(), true); + assert.equal(await currentForm.locator('[name="priority"]').inputValue(), 'urgent'); + assert.equal(await currentForm.locator('[name="reason"]').inputValue(), 'Review this change against the current task evidence.'); await stalePage.close(); assert.deepEqual(errors, []); assert.deepEqual(apiRequests, [], 'demo must never contact live project APIs'); diff --git a/test/fleet/console-view-navigation.test.mjs b/test/fleet/console-view-navigation.test.mjs index 96d216a..9594334 100644 --- a/test/fleet/console-view-navigation.test.mjs +++ b/test/fleet/console-view-navigation.test.mjs @@ -129,21 +129,31 @@ test('SCN-console-priority-preview-invalidates-on-newer-evidence: refresh preser await page.locator('.console-rail a[href="#work"]').click(); await page.locator('#refresh-console').click(); await page.locator('#live-refresh-status[data-generation="3"]').waitFor(); - assert.equal(Number(await form.getAttribute('data-revision')), revisionN1); - assert.equal(await ticket.locator('.priority').textContent(), 'low'); - assert.equal(await form.getAttribute('data-preview-token'), null); - assert.equal(await form.locator('[data-priority-preview]').isVisible(), false); - assert.equal(await form.locator('[data-priority-confirm]').count(), 0); - assert.equal(await form.locator('[name="priority"]').inputValue(), 'urgent'); - assert.equal(await form.locator('[name="reason"]').inputValue(), 'Preserve this unsent explanation across a newer task revision.'); - assert.equal(await form.locator('[name="priority"]').isDisabled(), false); - assert.equal(await form.locator('[name="reason"]').isDisabled(), false); + const preservedForm = page.locator('.priority-change-form[data-task-id="API-08"]'); + const preservedTicket = preservedForm.locator('xpath=../..'); + assert.equal(Number(await preservedForm.getAttribute('data-revision')), revisionN1); + assert.equal(await preservedTicket.locator('.priority').textContent(), 'low'); + assert.equal(await preservedForm.getAttribute('data-preview-token'), null); + assert.equal(await preservedForm.locator('[data-priority-preview]').isVisible(), false); + assert.equal(await preservedForm.locator('[data-priority-confirm]').count(), 0); + assert.equal(await preservedForm.locator('[name="priority"]').inputValue(), 'urgent'); + assert.equal(await preservedForm.locator('[name="reason"]').inputValue(), 'Preserve this unsent explanation across a newer task revision.'); + assert.equal(await preservedForm.locator('[name="priority"]').isDisabled(), false); + assert.equal(await preservedForm.locator('[name="reason"]').isDisabled(), false); - await form.getByRole('button', { name: 'Review change', exact: true }).click(); - await form.locator('[data-priority-confirm]').waitFor(); - const currentToken = await form.getAttribute('data-preview-token'); + await preservedForm.getByRole('button', { name: 'Review change', exact: true }).click(); + await preservedForm.locator('[data-priority-confirm]').waitFor(); + const currentToken = await preservedForm.getAttribute('data-preview-token'); assert.notEqual(currentToken, staleToken); - assert.equal(await form.locator('[data-priority-preview] dd').nth(2).innerText(), String(revisionN1)); + assert.equal(await preservedForm.locator('[data-priority-preview] dd').nth(2).innerText(), String(revisionN1)); + await page.locator('#refresh-console').click(); + await page.locator('#live-refresh-status[data-generation="4"]').waitFor(); + const currentForm = page.locator('.priority-change-form[data-task-id="API-08"]'); + assert.equal(await currentForm.getAttribute('data-preview-token'), currentToken); + assert.equal(await currentForm.locator('[data-priority-preview]').isVisible(), true); + assert.equal(await currentForm.locator('[data-priority-confirm]').isVisible(), true); + assert.equal(await currentForm.locator('[name="priority"]').inputValue(), 'urgent'); + assert.equal(await currentForm.locator('[name="reason"]').inputValue(), 'Preserve this unsent explanation across a newer task revision.'); }); test('SCN-console-current-preview-and-draft-survive-unchanged-refresh: a current preview and its fields remain intact', async (t) => {