138 lines
7.8 KiB
JavaScript
138 lines
7.8 KiB
JavaScript
const { JSDOM } = require("jsdom");
|
||
const fs = require("fs");
|
||
const html = fs.readFileSync("/Users/paige.petrone/messingaround/ServiceMeow-HQ.html", "utf8");
|
||
const csv = fs.readFileSync("/Users/paige.petrone/messingaround/oct13_export.csv", "utf8");
|
||
|
||
const errors = [];
|
||
const dom = new JSDOM(html, {
|
||
url: "http://localhost/",
|
||
runScripts: "dangerously",
|
||
pretendToBeVisual: true,
|
||
beforeParse(window) {
|
||
window.confirm = () => true;
|
||
window.alert = m => errors.push("alert: " + m);
|
||
},
|
||
});
|
||
const w = dom.window, d = w.document;
|
||
w.addEventListener("error", e => errors.push(e.message));
|
||
|
||
setTimeout(() => {
|
||
const ok = (name, cond) => { console.log((cond ? "PASS" : "FAIL") + " " + name); if (!cond) process.exitCode = 1; };
|
||
|
||
// --- hub / tabs ---
|
||
ok("hub tabs present", d.getElementById("tabbtn-roadmap") && d.getElementById("tabbtn-uat"));
|
||
ok("roadmap pane active by default", d.getElementById("tab-roadmap").classList.contains("active"));
|
||
d.getElementById("tabbtn-uat").click();
|
||
ok("UAT pane activates on click", d.getElementById("tab-uat").classList.contains("active"));
|
||
|
||
// --- launch calendar (today = Wed Oct 14 2026) ---
|
||
const cards = d.getElementById("launchCards").textContent;
|
||
console.log(" cards:", cards.replace(/\s+/g, " ").slice(0, 220));
|
||
ok("RND next launch = Oct 27 (4th Tue)", cards.includes("Oct 27"));
|
||
ok("RND freeze = Oct 23 Fri", cards.includes("Oct 23"));
|
||
ok("BT next launch = Oct 20 (3rd Tue)", cards.includes("Oct 20"));
|
||
ok("BT freeze = Oct 16 Fri", cards.includes("Oct 16"));
|
||
ok("freeze banner visible (Oct 16 <= 7 days)", d.getElementById("uatBanner").style.display === "flex");
|
||
|
||
// --- load the real weekly CSV via the app's own pipeline ---
|
||
w.__csv = csv;
|
||
w.eval("loadTickets(csvToTickets(__csv), 'oct13_export.csv')");
|
||
|
||
const bodyTxt = d.getElementById("list").textContent;
|
||
ok("RNDSystems section exists", /RNDSystem/i.test(bodyTxt));
|
||
ok("BT section exists", /\bBT\b/.test(bodyTxt));
|
||
const rnsHead = [...d.querySelectorAll(".section")].find(s => /RNDSystem/i.test(s.querySelector(".bsec").textContent));
|
||
const btHead = [...d.querySelectorAll(".section")].find(s => s.querySelector(".bsec") && /\bBT\b/.test(s.querySelector(".bsec").textContent.split("→")[0]));
|
||
ok("RND section points at Oct 27 launch + Oct 23 freeze", rnsHead && rnsHead.textContent.includes("Oct 27") && rnsHead.textContent.includes("Oct 23"));
|
||
ok("BT section points at Oct 20 launch + Oct 16 freeze", btHead && btHead.textContent.includes("Oct 20") && btHead.textContent.includes("Oct 16"));
|
||
|
||
// --- nearest launch is most prominent: BT (Oct 20) before RND (Oct 27) ---
|
||
const secNames = [...d.querySelectorAll("#list .section .bsec")].map(x => x.textContent);
|
||
const btPos = secNames.findIndex(t => /\bBT\b/.test(t.split("→")[0]));
|
||
const rnsPos = secNames.findIndex(t => /RNDSystem/i.test(t.split("→")[0]));
|
||
ok("BT section listed before RNDSystems (sooner launch first)", btPos !== -1 && rnsPos !== -1 && btPos < rnsPos);
|
||
const nextSec = d.querySelector("#list .section.next");
|
||
ok("nearest section has .next highlight + NEXT UP badge", nextSec && /\bBT\b/.test(nextSec.querySelector(".bsec").textContent.split("→")[0]) && nextSec.textContent.includes("NEXT UP"));
|
||
ok("launch cards sorted nearest first (BT card before RND)", d.getElementById("launchCards").children[0].textContent.includes("BT"));
|
||
|
||
const rows = d.querySelectorAll("#list .row");
|
||
ok("ticket rows rendered: " + rows.length, rows.length > 5);
|
||
|
||
// --- send-to-bottom button ---
|
||
const firstRns = rnsHead.querySelector(".rowwrap .row");
|
||
const ticketId = firstRns.dataset.ticket;
|
||
const bbtn = firstRns.parentElement.querySelector("[data-bottom]");
|
||
ok("bottom button present on row", !!bbtn);
|
||
bbtn.click();
|
||
const rnsHead2 = [...d.querySelectorAll(".section")].find(s => /RNDSystem/i.test(s.querySelector(".bsec").textContent));
|
||
ok("ticket moves into bottom zone", rnsHead2.querySelector(".bottom-zone") && rnsHead2.querySelector(".bottom-zone").textContent.includes(ticketId));
|
||
const order = JSON.parse(w.localStorage.getItem("uat-outreach-bottom-v1"));
|
||
ok("bottom order persisted", Array.isArray(order) && order[0] === ticketId);
|
||
// click again → back
|
||
const bbtn2 = rnsHead2.querySelector(".bottom-zone [data-bottom]");
|
||
bbtn2.click();
|
||
const rnsHead3 = [...d.querySelectorAll(".section")].find(s => /RNDSystem/i.test(s.querySelector(".bsec").textContent));
|
||
ok("ticket restored to priority order", !rnsHead3.querySelector(".bottom-zone"));
|
||
|
||
// --- status button still works ---
|
||
const anyRow = d.querySelector("#list .row");
|
||
const sbtn = anyRow.parentElement.querySelector('[data-s="1"]');
|
||
sbtn.click();
|
||
ok("outreach status still works", w.localStorage.getItem("uat-outreach-statuses-v1").includes(anyRow.dataset.ticket));
|
||
|
||
// --- Web Alignment tab ---
|
||
d.getElementById("tabbtn-wa").click();
|
||
ok("WA pane activates", d.getElementById("tab-wa").classList.contains("active"));
|
||
const whenTxt = d.getElementById("waWhen").textContent;
|
||
console.log(" wa when:", whenTxt.replace(/\s+/g, " "));
|
||
ok("next sync = Monday Oct 19 at 9:00 AM", whenTxt.includes("October 19") && whenTxt.includes("9:00"));
|
||
ok("badge shows — when empty", d.getElementById("waBadge").textContent === "—");
|
||
d.getElementById("waInput").value = "Decide staging data refresh cadence";
|
||
w.eval("addWaItem()");
|
||
d.getElementById("waInput").value = "Get sign-off on new mega menu structure";
|
||
w.eval("addWaItem()");
|
||
ok("two items listed", d.querySelectorAll("#waList label.item").length === 2);
|
||
ok("badge shows 2", d.getElementById("waBadge").textContent === "2");
|
||
// check first item off → covered
|
||
d.querySelector("#waList label.item input[type=checkbox]").click();
|
||
const coveredTxt = d.getElementById("waList").textContent;
|
||
ok("covered item moves to Covered zone", coveredTxt.includes("Covered") && d.getElementById("waList").textContent.includes("staging data"));
|
||
ok("badge back to 1", d.getElementById("waBadge").textContent === "1");
|
||
ok("WA items persisted", (JSON.parse(w.localStorage.getItem("sm-webalign-items-v1")) || []).length === 2);
|
||
|
||
// --- WA sub-items ---
|
||
const addsub = d.querySelector("#waList .wa-addsub");
|
||
ok("+ sub button present", !!addsub);
|
||
addsub.click();
|
||
let subInp = d.querySelector("#waList .wa-subadd input");
|
||
ok("sub-item input appears", !!subInp);
|
||
subInp.value = "Who owns the decision?";
|
||
subInp.dispatchEvent(new w.KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
|
||
ok("sub-item added", d.querySelectorAll("#waList .wa-subrow").length === 1);
|
||
ok("sub count badge 0/1", d.querySelector("#waList .wa-subcnt").textContent === "0/1");
|
||
// second sub via the reopened input (waShowSubInput re-opens after Enter)
|
||
subInp = d.querySelector("#waList .wa-subadd input");
|
||
if (subInp) {
|
||
subInp.value = "What does QA need?";
|
||
subInp.dispatchEvent(new w.KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
|
||
}
|
||
ok("two sub-items", d.querySelectorAll("#waList .wa-subrow").length === 2);
|
||
// toggle one sub done
|
||
d.querySelector("#waList .wa-subrow input[type=checkbox]").click();
|
||
ok("sub count badge 1/2", d.querySelector("#waList .wa-subcnt").textContent === "1/2");
|
||
const waData = JSON.parse(w.localStorage.getItem("sm-webalign-items-v1"));
|
||
ok("subs persisted on item", waData.some(i => (i.subs || []).length === 2));
|
||
// remove a sub
|
||
d.querySelector("#waList .wa-subrow .del").click();
|
||
ok("sub removed", d.querySelectorAll("#waList .wa-subrow").length === 1);
|
||
|
||
// --- roadmap tab still renders ---
|
||
d.getElementById("tabbtn-roadmap").click();
|
||
ok("roadmap tasks rendered", d.querySelectorAll("#todoList label.item").length > 10);
|
||
ok("gantt rendered", d.querySelectorAll("table.gantt .bar").length > 5);
|
||
ok("focus chips rendered", d.getElementById("focusChips").children.length > 0);
|
||
|
||
console.log(errors.length ? "\nPAGE ERRORS:\n" + errors.join("\n") : "\nno page errors");
|
||
process.exit(process.exitCode || 0);
|
||
}, 300);
|