diff --git a/src/static/tests/RoleSelectSpec.js b/src/static/tests/RoleSelectSpec.js index 1aaf626..5861069 100644 --- a/src/static/tests/RoleSelectSpec.js +++ b/src/static/tests/RoleSelectSpec.js @@ -127,10 +127,30 @@ describe("RoleSelect", () => { }); // ------------------------------------------------------------------ // - // room:roles_revealed event // + // room:all_roles_filled event // // ------------------------------------------------------------------ // - describe("room:roles_revealed event", () => { + describe("room:all_roles_filled event", () => { + let pickSigsWrap; + + beforeEach(() => { + pickSigsWrap = document.createElement("div"); + pickSigsWrap.id = "id_pick_sigs_wrap"; + pickSigsWrap.style.display = "none"; + testDiv.appendChild(pickSigsWrap); + }); + + it("shows #id_pick_sigs_wrap", () => { + window.dispatchEvent(new CustomEvent("room:all_roles_filled", { detail: {} })); + expect(pickSigsWrap.style.display).toBe(""); + }); + }); + + // ------------------------------------------------------------------ // + // room:sig_select_started event // + // ------------------------------------------------------------------ // + + describe("room:sig_select_started event", () => { let reloadCalled; beforeEach(() => { @@ -143,7 +163,7 @@ describe("RoleSelect", () => { }); it("triggers a page reload", () => { - window.dispatchEvent(new CustomEvent("room:roles_revealed", { detail: {} })); + window.dispatchEvent(new CustomEvent("room:sig_select_started", { detail: {} })); expect(reloadCalled).toBe(true); }); }); diff --git a/src/static/tests/TraySpec.js b/src/static/tests/TraySpec.js index 818249a..2148403 100644 --- a/src/static/tests/TraySpec.js +++ b/src/static/tests/TraySpec.js @@ -485,7 +485,7 @@ describe("Tray", () => { expect(firstCell.classList.contains("arc-in")).toBe(true); }); - it("removes .arc-in and force-closes after animationend", () => { + it("removes .arc-in and closes after animationend", () => { Tray.placeCard("PC", null); expect(Tray.isOpen()).toBe(true); firstCell.dispatchEvent(new Event("animationend")); @@ -497,6 +497,10 @@ describe("Tray", () => { let called = false; Tray.placeCard("PC", () => { called = true; }); firstCell.dispatchEvent(new Event("animationend")); + // Simulate the close transition completing (portrait: 'left' property) + const te = new Event("transitionend"); + te.propertyName = "left"; + wrap.dispatchEvent(te); expect(called).toBe(true); }); diff --git a/src/static_src/tests/RoleSelectSpec.js b/src/static_src/tests/RoleSelectSpec.js index f1cca80..5861069 100644 --- a/src/static_src/tests/RoleSelectSpec.js +++ b/src/static_src/tests/RoleSelectSpec.js @@ -127,10 +127,30 @@ describe("RoleSelect", () => { }); // ------------------------------------------------------------------ // - // room:roles_revealed event // + // room:all_roles_filled event // // ------------------------------------------------------------------ // - describe("room:roles_revealed event", () => { + describe("room:all_roles_filled event", () => { + let pickSigsWrap; + + beforeEach(() => { + pickSigsWrap = document.createElement("div"); + pickSigsWrap.id = "id_pick_sigs_wrap"; + pickSigsWrap.style.display = "none"; + testDiv.appendChild(pickSigsWrap); + }); + + it("shows #id_pick_sigs_wrap", () => { + window.dispatchEvent(new CustomEvent("room:all_roles_filled", { detail: {} })); + expect(pickSigsWrap.style.display).toBe(""); + }); + }); + + // ------------------------------------------------------------------ // + // room:sig_select_started event // + // ------------------------------------------------------------------ // + + describe("room:sig_select_started event", () => { let reloadCalled; beforeEach(() => { @@ -143,7 +163,7 @@ describe("RoleSelect", () => { }); it("triggers a page reload", () => { - window.dispatchEvent(new CustomEvent("room:roles_revealed", { detail: {} })); + window.dispatchEvent(new CustomEvent("room:sig_select_started", { detail: {} })); expect(reloadCalled).toBe(true); }); }); @@ -173,7 +193,6 @@ describe("RoleSelect", () => { trayWrap = document.createElement("div"); trayWrap.id = "id_tray_wrap"; - // Simulate server-side class during ROLE_SELECT trayWrap.className = "role-select-phase"; testDiv.appendChild(trayWrap); }); @@ -186,6 +205,13 @@ describe("RoleSelect", () => { expect(Tray.forceClose).toHaveBeenCalled(); }); + it("clears .active from all seats on turn change", () => { + window.dispatchEvent(new CustomEvent("room:turn_changed", { + detail: { active_slot: 2 } + })); + expect(testDiv.querySelector(".table-seat.active")).toBeNull(); + }); + it("re-adds role-select-phase to tray wrap on turn change", () => { trayWrap.classList.remove("role-select-phase"); // simulate it was shown window.dispatchEvent(new CustomEvent("room:turn_changed", { @@ -194,13 +220,6 @@ describe("RoleSelect", () => { expect(trayWrap.classList.contains("role-select-phase")).toBe(true); }); - it("clears .active from all seats on turn change", () => { - window.dispatchEvent(new CustomEvent("room:turn_changed", { - detail: { active_slot: 2 } - })); - expect(testDiv.querySelector(".table-seat.active")).toBeNull(); - }); - it("removes .active from the previously active seat", () => { window.dispatchEvent(new CustomEvent("room:turn_changed", { detail: { active_slot: 2 } diff --git a/src/static_src/tests/TraySpec.js b/src/static_src/tests/TraySpec.js index 818249a..2148403 100644 --- a/src/static_src/tests/TraySpec.js +++ b/src/static_src/tests/TraySpec.js @@ -485,7 +485,7 @@ describe("Tray", () => { expect(firstCell.classList.contains("arc-in")).toBe(true); }); - it("removes .arc-in and force-closes after animationend", () => { + it("removes .arc-in and closes after animationend", () => { Tray.placeCard("PC", null); expect(Tray.isOpen()).toBe(true); firstCell.dispatchEvent(new Event("animationend")); @@ -497,6 +497,10 @@ describe("Tray", () => { let called = false; Tray.placeCard("PC", () => { called = true; }); firstCell.dispatchEvent(new Event("animationend")); + // Simulate the close transition completing (portrait: 'left' property) + const te = new Event("transitionend"); + te.propertyName = "left"; + wrap.dispatchEvent(te); expect(called).toBe(true); });