SIG SELECT exit: 2s hang after tray closes; suppress waiting msg if PICK SKY already up — TDD
- polarity_room_done handler in sig-select.js wraps Tray.placeSig's callback in setTimeout(_settle, 2000) so the user gets a beat to register the tray closing before the overlay vanishes. Visual order now: stage → tray slides in → sig fades into the tray cell → tray slides out → 2s pause → overlay dismisses → table hex. - _showWaitingMsg early-exits if #id_pick_sky_btn is already revealed. The cross-polarity case — the OTHER room finishes WHILE this gamer's tray sequence is mid-flight — fires pick_sky_available during the hang, which removes any waiting msg & shows PICK SKY. When _settle fires after the hang, the PICK SKY check skips the now-stale waiting msg. - 2 SigSelectSpec specs: 2s delay before overlay dismisses; waiting msg suppressed when pick_sky_btn is visible. jasmine.clock() drives the setTimeout in both. Code architected by Disco DeDisco <discodedisco@outlook.com> Git commit message Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -825,8 +825,7 @@ describe("SigSelect", () => {
|
||||
|
||||
describe("polarity_room_done → tray sequence", () => {
|
||||
beforeEach(() => {
|
||||
// .table-center is appended to by _showWaitingMsg in the dismiss
|
||||
// path; provide one so dismissal doesn't error.
|
||||
jasmine.clock().install();
|
||||
const center = document.createElement("div");
|
||||
center.className = "table-center";
|
||||
document.body.appendChild(center);
|
||||
@@ -835,7 +834,8 @@ describe("SigSelect", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.querySelectorAll(".table-center, #id_hex_waiting_msg")
|
||||
jasmine.clock().uninstall();
|
||||
document.querySelectorAll(".table-center, #id_hex_waiting_msg, #id_pick_sky_btn")
|
||||
.forEach((el) => el.remove());
|
||||
});
|
||||
|
||||
@@ -855,17 +855,43 @@ describe("SigSelect", () => {
|
||||
expect(Tray.placeSig).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("dismisses the overlay only AFTER Tray.placeSig's callback fires", () => {
|
||||
it("dismisses the overlay 2s after Tray.placeSig's callback fires", () => {
|
||||
window.dispatchEvent(new CustomEvent("room:polarity_room_done", {
|
||||
detail: { polarity: "levity" },
|
||||
}));
|
||||
// Overlay still mounted — dismissal deferred to tray callback.
|
||||
// Overlay still mounted — dismissal deferred to tray callback + hang.
|
||||
expect(document.querySelector(".sig-overlay")).not.toBe(null);
|
||||
|
||||
const cb = Tray.placeSig.calls.mostRecent().args[1];
|
||||
cb();
|
||||
// 1.999s after callback — overlay still up.
|
||||
jasmine.clock().tick(1999);
|
||||
expect(document.querySelector(".sig-overlay")).not.toBe(null);
|
||||
// At 2s — overlay dismissed; waiting msg added.
|
||||
jasmine.clock().tick(1);
|
||||
expect(document.querySelector(".sig-overlay")).toBe(null);
|
||||
expect(document.getElementById("id_hex_waiting_msg")).not.toBe(null);
|
||||
});
|
||||
|
||||
it("does NOT add the waiting msg when pick_sky_btn is already revealed", () => {
|
||||
// pick_sky_available may fire DURING the tray sequence (other
|
||||
// polarity finishes first). When the tray callback then hangs +
|
||||
// dismisses, _settle must check whether PICK SKY is up and skip
|
||||
// the "Levity appraising…" / "Gravity settling…" message so it
|
||||
// doesn't co-exist w. the btn.
|
||||
const btn = document.createElement("button");
|
||||
btn.id = "id_pick_sky_btn";
|
||||
btn.style.display = ""; // visible — pick_sky_available fired
|
||||
document.body.appendChild(btn);
|
||||
|
||||
window.dispatchEvent(new CustomEvent("room:polarity_room_done", {
|
||||
detail: { polarity: "levity" },
|
||||
}));
|
||||
const cb = Tray.placeSig.calls.mostRecent().args[1];
|
||||
cb();
|
||||
jasmine.clock().tick(2001);
|
||||
expect(document.querySelector(".sig-overlay")).toBe(null);
|
||||
expect(document.getElementById("id_hex_waiting_msg")).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user