Table sorting preferences will be saved and reused based on the user’s selections

This commit is contained in:
2026-10-25 00:39:55 -03:00
parent 19edee4e11
commit 0f1f399d1a
40 changed files with 896 additions and 230 deletions

View File

@@ -90,6 +90,8 @@ function dom() {
set textContent(value) { this.text = String(value); this.children = []; }
get textContent() { return (this.text || "") + this.children.map(child => child.textContent).join(""); }
append(...children) { for (const child of children) { child.parent = this; this.children.push(child); } }
replaceChildren(...children) { this.children = []; this.append(...children); }
querySelectorAll(selector) { return walk(this).filter(node => node !== this && node.tag === selector); }
setAttribute(name, value) { this.attributes[name] = value; }
addEventListener(name, fn) { this.listeners[name] = fn; }
focus() { document.activeElement = this; }
@@ -172,6 +174,26 @@ test("single-product opportunity alert opens the comparison directly with opport
assert.equal(host.children.length, 1);
});
test("projection sorting restores on reopening without changing forecast source order", () => {
const { document, host } = dom();
const app = loadApplication("content", { document, Intl, Date });
const input = product({ forecast: [
{ year: 2026, month: 11, adjustedConsumptionAmount: 10 },
{ year: 2026, month: 12, adjustedConsumptionAmount: 20 }
] });
const before = JSON.stringify(input);
const opportunity = { OptyNumber: "TEST" };
app.rampProjectionView.open(input, opportunity);
const button = walk(host).find(node => node.attributes["data-sort-key"] === "month");
button.click(); button.click();
const firstMonth = () => walk(host).find(node => node.tag === "tbody").children[0].children[0].textContent;
const expected = firstMonth();
app.rampProjectionView.close(); app.rampProjectionView.open(input, opportunity);
assert.equal(firstMonth(), expected);
assert.equal(walk(host).find(node => node.attributes["data-sort-key"] === "month").parent.attributes["aria-sort"], "descending");
assert.equal(JSON.stringify(input), before);
});
test("product column opens accessible read-only comparison and restores focus/background on close", () => {
const { document, host, content } = dom();
const app = loadApplication("content", { document, Intl, Date });