Implemented the feature to identify and update estimates based on the ACR value, consumption start date, and ramp-up
This commit is contained in:
@@ -34,7 +34,7 @@ test("failed results are never cached and identity changes discard previous resp
|
||||
h.user(""); await h.cache.send(msg, send); await h.cache.send(msg, send); assert.equal(calls, 5);
|
||||
});
|
||||
test("writes and token requests always execute; successful saves and Refresh all invalidate queries", async () => {
|
||||
for (const name of ["requestTimeEntriesSave", "requestTimeEntriesDelete", "requestMgmtAction", "requestPostServiceRequest", "requestPostInternalServiceRequest", "invalidateProductsCache"]) {
|
||||
for (const name of ["requestTimeEntriesSave", "requestTimeEntriesDelete", "requestMgmtAction", "requestPostServiceRequest", "requestPostInternalServiceRequest", "requestWorkloadForecastUpdate", "invalidateProductsCache"]) {
|
||||
const h = setup(); let queries = 0, writes = 0;
|
||||
const query = message("requestActionFindLookup");
|
||||
const queryTransport = async () => { queries++; return { ok: true }; };
|
||||
@@ -47,6 +47,42 @@ test("writes and token requests always execute; successful saves and Refresh all
|
||||
for (let i = 0; i < 2; i++) await h.cache.send(message("requestSrTokenCatalog"), async () => { calls++; return { ok: true }; });
|
||||
assert.equal(calls, 2);
|
||||
});
|
||||
test("reopening workloads reuses account cache across token renewals and keeps original persistent expiry", async () => {
|
||||
const h = setup(); let calls = 0;
|
||||
h.hours(1);
|
||||
const transport = async () => { calls++; return { ok: true, workloads: [{ id: 1, forecast: [] }], cachedAt: 50000, fromCache: true }; };
|
||||
const msg = message("requestWorkloads", { customerId: 123, principal: "a@example.invalid", authorization: { value: "old-token" } });
|
||||
const first = await h.cache.send(msg, transport);
|
||||
first.workloads[0].forecast.push({ month: 1 });
|
||||
const second = await h.cache.send({ ...msg, customerId: "123", cacheMaxAgeMs: 3600000, authorization: { value: "new-token" } }, transport);
|
||||
assert.equal(calls, 1);
|
||||
assert.equal(second.fromCache, true);
|
||||
assert.equal(second.cachedAt, 50000);
|
||||
assert.equal(second.workloads[0].forecast.length, 0);
|
||||
h.advance(3550000);
|
||||
await h.cache.send(msg, transport);
|
||||
assert.equal(calls, 2, "expires from persistent fetchedAt rather than modal opening time");
|
||||
await h.cache.send({ ...msg, customerId: 456 }, transport);
|
||||
assert.equal(calls, 3);
|
||||
h.user("b@example.invalid");
|
||||
await h.cache.send({ ...msg, principal: "b@example.invalid" }, transport);
|
||||
assert.equal(calls, 4);
|
||||
});
|
||||
test("workload cache survives failed updates but invalidates after success and Refresh all", async () => {
|
||||
const h = setup(); let calls = 0;
|
||||
const msg = message("requestWorkloads", { customerId: 123 });
|
||||
const transport = async () => { calls++; return { ok: true, workloads: [] }; };
|
||||
await h.cache.send(msg, transport);
|
||||
await h.cache.send(message("requestWorkloadForecastUpdate"), async () => ({ ok: false }));
|
||||
await h.cache.send(msg, transport);
|
||||
assert.equal(calls, 1);
|
||||
await h.cache.send(message("requestWorkloadForecastUpdate"), async () => ({ ok: true }));
|
||||
await h.cache.send(msg, transport);
|
||||
assert.equal(calls, 2);
|
||||
await h.cache.send(message("invalidateProductsCache"), async () => ({ ok: true }));
|
||||
await h.cache.send(msg, transport);
|
||||
assert.equal(calls, 3);
|
||||
});
|
||||
test("concurrent queries share work but old responses cannot repopulate an invalidated cache", async () => {
|
||||
const h = setup(); let resolve, calls = 0;
|
||||
const msg = message("requestLookupTypePlatform");
|
||||
|
||||
Reference in New Issue
Block a user