Fixed the date ranges for the Reference options

This commit is contained in:
2026-10-19 18:10:16 -03:00
parent cc025e488d
commit 71d550dfb1
10 changed files with 135 additions and 372 deletions

View File

@@ -174,70 +174,28 @@ test("SR Save validates form, maps dynamic values, locks duplicate clicks and pr
assert.equal(posts[0].message.phase, "prepare");
const preparedPayload = { ...payload, ReportedByPartyId: 303, SvcQuestionsCollection_c: [],
SourceCd: "SVC_OPPORTUNITY_SCREEN", SeverityCd: "ORA_SVC_SEV2", ChannelTypeCd: "ORA_SVC_WEB" };
const preparedHeaders = {
requestSrTokenCatalog: { Authorization: "Session", "Content-Type": "application/vnd.oracle.adf.action+json", Origin: "https://example.invalid" },
requestPostServiceRequest: { Authorization: "Session", "Content-Type": "application/vnd.oracle.adf.action+json", Origin: "https://example.invalid", "vb-proxy-header-x-oracle-ectoken": "(generated after confirmation)" }
};
posts[0].resolve({ ok: true, payload: preparedPayload, headers: preparedHeaders });
posts[0].resolve({ ok: true, payload: preparedPayload });
await flush();
const confirmation = () => h.nodes().find(node => node.className?.includes("opportunities-extension-sr-confirmation"));
const confirm = () => h.nodes().find(node => node.textContent === "Confirm Save");
assert.ok(confirmation());
const preview = h.nodes().find(node => node.tag === "pre");
assert.equal(preview.textContent, JSON.stringify(preparedPayload, null, 2));
const previews = h.nodes().filter(node => node.tag === "pre");
assert.equal(previews.length, 3);
assert.equal(previews[1].textContent, JSON.stringify(preparedHeaders.requestSrTokenCatalog, null, 2));
assert.equal(previews[2].textContent, JSON.stringify(preparedHeaders.requestPostServiceRequest, null, 2));
assert.ok(h.nodes().some(node => node.textContent === "x-appbuilder-client-id: not yet observed in SeaaS requests."));
assert.equal(h.form().parent.inert, true);
assert.equal(h.document.activeElement.textContent, "Cancel");
assert.equal(h.nodes().some(node => node.className?.includes("opportunities-extension-sr-confirmation")), false);
assert.equal(h.nodes().some(node => node.textContent === "Confirm Save"), false);
assert.equal(posts.length, 2, "Save proceeds directly from preparation to creation");
assert.equal(posts[1].message.phase, "confirm");
assert.deepEqual(posts[1].message.payload, preparedPayload);
assert.equal(save().textContent, "Saving...");
await submit();
assert.equal(posts.length, 1, "awaiting confirmation must never send a creation request");
confirm().focus();
confirmation().listeners.keydown({ key: "Tab", preventDefault() {}, stopPropagation() {} });
assert.equal(h.document.activeElement, preview);
h.nodes().filter(node => node.tag === "button" && node.textContent === "Cancel").at(-1).click();
assert.equal(posts.length, 2, "duplicate clicks cannot create another SR");
posts[1].resolve({ ok: false, error: "Synthetic failure" });
await saving;
assert.equal(posts.length, 1, "Cancel never creates SR");
assert.equal(confirmation(), undefined);
assert.equal(h.form().parent.inert, false);
assert.equal(notices.at(-1)[1], true);
assert.equal(save().disabled, false);
assert.equal(h.nodes().find(node => node.name === "description").value, "Dynamic description");
assert.equal(h.document.activeElement, save());
assert.equal(notices.length, 0);
const escaped = submit();
posts[1].resolve({ ok: true, payload: preparedPayload });
await flush();
confirmation().listeners.keydown({ key: "Escape", preventDefault() {}, stopPropagation() {} });
await escaped;
assert.equal(posts.length, 2);
assert.ok(h.form(), "Escape closes only the confirmation");
const failed = submit();
posts[2].resolve({ ok: true, payload: preparedPayload });
await flush();
const confirmButton = confirm();
confirmButton.click();
confirmButton.click();
await flush();
assert.equal(posts.length, 4, "double confirm sends only one creation request");
assert.equal(posts[3].message.phase, "confirm");
assert.deepEqual(posts[3].message.payload, preparedPayload);
assert.equal(posts[3].message.payload.AccountPartyId, 100000000000101);
assert.equal(save().textContent, "Saving...");
posts[3].resolve({ ok: false, error: "Synthetic failure" });
await failed;
assert.equal(notices.at(-1)[1], true);
delete h.app.opportunitiesTableState.opportunitiesTableState.items[1].CustomerAccount.CountryCode;
const retry = submit();
assert.equal(posts[4].message.payload.CountryText_c, "BR", "uses PrimaryAddress.CountryCode even without CustomerAccount.CountryCode");
posts[4].resolve({ ok: true, payload: preparedPayload });
assert.equal(posts[2].message.payload.CountryText_c, "BR", "uses PrimaryAddress.CountryCode even without CustomerAccount.CountryCode");
posts[2].resolve({ ok: true, payload: preparedPayload });
await flush();
confirm().click();
await flush();
posts[5].resolve({ ok: true, result: { SrId: 505, SrNumber: "SR505" } });
assert.equal(posts.length, 4);
posts[3].resolve({ ok: true, result: { SrId: 505, SrNumber: "SR505" } });
await retry;
assert.equal(h.form(), undefined);
assert.equal(notices.at(-1)[0], "Service Request saved successfully.");