const assert = require("node:assert/strict"); const { test } = require("node:test"); const { loadApplication } = require("./support/application.cjs"); class Element { constructor() { this.children = []; this.attributes = {}; } set textContent(value) { this.text = value; this.children = []; } get textContent() { return this.text; } append(...nodes) { this.children.push(...nodes); } setAttribute(key, value) { this.attributes[key] = value; } addEventListener() {} } test("Total Opportunities displays filtered/overall and updates with filters and Reference data", () => { const dashboard = new Element(), table = new Element(); const app = loadApplication("content", { document: { createElement: () => new Element(), getElementById: id => id === "opportunities-extension-stage-dashboard" ? dashboard : id === "opportunities-extension-table" ? table : null }, performance: { now: () => 0 }, requestAnimationFrame: tick => tick(480) }); // Use real table/dashboard coordination without constructing unrelated row controls. app.opportunitiesTableState.opportunitiesTableState.status = "loading"; const items = Array.from({ length: 26 }, () => ({ ForecastGroup_c: "FORECAST" })); app.opportunitiesTableState.opportunitiesTableState.items = items; let filtered = items.slice(0, 11); app.opportunitiesFilters.getSortedOpportunities = () => filtered; const value = () => dashboard.children[0].children[1]; app.opportunitiesTable.renderOpportunitiesTable(); assert.equal(value().textContent, "11/26"); assert.equal(value().attributes["aria-label"], "11 filtered opportunities out of 26 total"); filtered = []; app.opportunitiesTable.renderOpportunitiesTable(); assert.equal(value().textContent, "0/26"); filtered = items; app.opportunitiesTable.renderOpportunitiesTable(); assert.equal(value().textContent, "26/26"); app.opportunitiesTableState.opportunitiesTableState.items = items.slice(0, 3); filtered = items.slice(0, 2); app.opportunitiesTable.renderOpportunitiesTable(); assert.equal(value().textContent, "2/3"); app.opportunitiesTableState.opportunitiesTableState.items = []; filtered = []; app.opportunitiesTable.renderOpportunitiesTable(); assert.equal(value().textContent, "0/0"); });