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

@@ -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);
});