Implemented a tooltip on the SR to display the Internal SR

This commit is contained in:
2026-09-29 13:53:38 -03:00
parent a182609415
commit 4d3f1f9760
21 changed files with 400 additions and 28 deletions

View File

@@ -37,7 +37,7 @@ test("activity badge filters precede Status, are accessible and combine without
assert.equal(h.button("sr", "matched").textContent, "");
assert.equal(h.button("actions", "missing").textContent, "");
assert.equal(h.button("actions", "matched").type, "button");
assert.equal(h.controls.children[1].children[0].textContent, "Action");
assert.equal(h.controls.children[1].children[0].textContent, "WL Action");
for (const value of ["matched", "missing"]) {
assert.equal(h.button("actions", value).textContent, "");
assert.ok(h.button("actions", value).title.startsWith("Whether the Action is registered in Workload Workbench.\n"));

View File

@@ -41,7 +41,7 @@ test("distribution contracts: manifests, execution boundaries and deterministic
manifest_version: 3, name: "Opportunities Extension",
description: "Adiciona um atalho de Opportunities Extension nas paginas Oracle Fusion permitidas.",
version: "1.0.2", permissions: ["cookies", "storage"],
host_permissions: ["https://eeho.fa.us2.oraclecloud.com/*", "https://spa.oracle.com/*"],
host_permissions: ["https://eeho.fa.us2.oraclecloud.com/*", "https://spa.oracle.com/*", "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/*"],
content_scripts: [{
matches: ["https://eeho.fa.us2.oraclecloud.com/hcmUI/faces/FuseWelcome*", "https://eeho.fa.us2.oraclecloud.com/fscmUI/faces/FuseWelcome*"],
js: ["content.js"], all_frames: true, run_at: "document_idle"

View File

@@ -0,0 +1,41 @@
const assert = require("node:assert/strict");
const { test } = require("node:test");
const { loadBackground, response } = require("./support/characterization.cjs");
const type = "opportunitiesExtension.requestInternalServiceRequest";
for (const family of ["chrome", "firefox"]) {
test(`${family}: SR detail GET uses exact scope and Session authentication`, async () => {
const calls = [];
const children = [{ SrId: 123, SrNumber: "SR123", Title: "Synthetic" }];
const h = loadBackground({ family, fetch: async (url, options) => {
calls.push({ url, options });
return response({ items: [{ ServiceRequest_SRToInternalSR_Tgt: children }] });
} });
const result = await h.dispatch({ type, srId: "987", token: "secret-test" });
assert.equal(result.ok, true);
assert.deepEqual(result.items, children);
const url = new URL(calls[0].url);
assert.equal(url.hostname, "comcipapic-oalprod.integration.ocp.oraclecloud.com");
assert.equal(url.searchParams.get("q"), "SrId=987");
assert.equal(url.searchParams.get("onlyData"), "true");
assert.ok(url.searchParams.get("fields").includes("ServiceRequest_SRToInternalSR_Tgt:ReportedHours_c"));
assert.equal(calls[0].options.method, "GET");
assert.equal(calls[0].options.headers.Authorization, "Session");
assert.equal(calls[0].options.credentials, "include");
assert.equal(result.debugRequests[0].requestHeaders.Authorization, "Session");
assert.ok(!JSON.stringify(result).includes("secret-test"));
assert.equal(result.debugRequests[0].name, "requestInternalServiceRequest");
});
}
test("SR details distinguish empty collections from errors and validate inputs", async () => {
for (const body of [{ items: [] }, { items: [{}] }, { items: [{ ServiceRequest_SRToInternalSR_Tgt: [] }] }]) {
const h = loadBackground({ fetch: async () => response(body) });
assert.deepEqual((await h.dispatch({ type, srId: "1" })).items, []);
}
for (const fetch of [async () => response({}, 403), async () => response({}), async () => response({ items: [{ ServiceRequest_SRToInternalSR_Tgt: {} }] })]) {
const h = loadBackground({ fetch });
assert.equal((await h.dispatch({ type, srId: "1", token: "test" })).ok, false);
}
const h = loadBackground({ fetch: () => assert.fail("Invalid input must not fetch") });
assert.equal((await h.dispatch({ type, srId: "1 OR 1=1", token: "test" })).ok, false);
assert.equal((await h.dispatch({ type })).ok, false);
});

View File

@@ -1,6 +1,31 @@
const assert = require("node:assert/strict");
const { test } = require("node:test");
const { loadApplication } = require("./support/application.cjs");
const flush = () => new Promise(resolve => setImmediate(resolve));
test("internal SR uses Session without TokenRelay or retries on 401", async () => {
const h = setup();
let renewals = 0;
const sent = [];
h.app.authSessionState.accessToken = "stale-token";
h.app.authTokenRelay.requestTokenRelay = async () => `fresh-${++renewals}`;
h.app.debugContentView.renderDebugPanel = () => {};
h.app.platformContentMessages.sendRuntimeMessage = async message => {
sent.push(message);
return { ok: false, httpStatus: 401, error: "Unauthorized" };
};
h.app.fusionCrmServiceRequests.requestCrmServiceRequest = async () => [{ SrId: "123", SrNumber: "SR123", OpportunityName_Id_c: { OptyNumber: "OP1" } }];
await h.app.opportunityCrmServiceRequests.load("synthetic", 1);
const badge = h.app.opportunityCrmServiceRequests.createBadge("OP1");
h.modal.append(badge);
badge.listeners.pointerenter();
await flush();
assert.equal(renewals, 0);
assert.equal(sent.length, 1);
assert.equal(sent[0].token, undefined);
assert.ok(sent.every(item => item.type === "opportunitiesExtension.requestInternalServiceRequest"));
assert.ok(h.walk(h.panel()).some(node => node.textContent === "Unauthorized"));
});
function setup() {
const document = { activeElement: null, listeners: new Map() };
@@ -104,3 +129,42 @@ test("SR popover pins on click, closes on Escape/outside/scroll/reset and remove
assert.equal(panel(), undefined);
assert.equal(document.listeners.size, 0);
});
test("SR tooltip loads nested details with copy/link and empty text, discarding stale responses", async () => {
const h = setup();
const calls = [];
h.app.authSessionState.accessToken = "crm-token";
h.app.authTokenRelay.requestTokenRelay = async () => "fresh-crm-token";
h.app.debugContentView.renderDebugPanel = () => {};
h.app.platformContentMessages.sendRuntimeMessage = message => new Promise(resolve => calls.push({ message, resolve }));
await h.app.opportunityCrmServiceRequests.load("synthetic", 1);
const badge = h.app.opportunityCrmServiceRequests.createBadge("OP1");
h.modal.append(badge);
badge.listeners.pointerenter();
await flush();
assert.equal(calls.length, 2);
assert.equal(calls[0].message.token, undefined);
assert.equal(calls[0].message.srId, "NOT-THE-URL-ID");
assert.ok(h.walk(h.panel()).some(node => node.textContent === "Loading SR details..."));
calls[0].resolve({ ok: true, items: [{ SrId: 99, SrNumber: "SR &child", Title: "<child>", ServiceNew_c: "Queue" }] });
calls[1].resolve({ ok: true, items: [] });
await flush();
const nodes = h.walk(h.panel());
const link = nodes.find(node => node.tag === "a" && node.textContent === "SR &child");
assert.equal(link.parent.children[0].textContent, "Internal SR Number:");
assert.ok(link.href.endsWith("srNumber=SR%20%26child&srId=99"));
assert.equal(link.parent.children[2].title, "Copy SR number");
assert.ok(nodes.some(node => node.textContent.includes("Service Queue: Queue")));
assert.ok(nodes.some(node => node.textContent === "No further details."));
h.app.crmSrPopover?.close();
h.app.opportunityCrmServiceRequests.reset();
badge.listeners.pointerenter();
const oldPanel = h.panel();
await flush();
h.app.opportunityCrmServiceRequests.reset();
calls[2].resolve({ ok: true, items: [{ SrNumber: "STALE" }] });
calls[3].resolve({ ok: false, error: "Forbidden" });
await flush();
assert.equal(h.panel(), undefined);
assert.ok(!h.walk(oldPanel).some(node => node.textContent === "STALE"));
});