fix(viewer): label faction ban buttons compactly
This commit is contained in:
parent
c1acabcf58
commit
c39629c1b1
5 changed files with 42 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/old-ui",
|
||||
"version": "1.2.36",
|
||||
"version": "1.2.37",
|
||||
"scripts": {
|
||||
"serve": "vite --port 5193",
|
||||
"build": "vite build",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Engine from "@gaia-project/engine";
|
||||
import Engine, { AuctionVariant, Command } from "@gaia-project/engine";
|
||||
import betaFixture from "@gaia-project/engine/fixtures/Beta-2.json";
|
||||
import { move, stripSecret } from "@gaia-project/engine/wrapper";
|
||||
import { loadScenarioEngine, selfContainedScenarios } from "../../viewer/src/self-contained-scenarios";
|
||||
|
|
@ -41,6 +41,33 @@ describe("old UI on the current engine", () => {
|
|||
vi.unstubAllGlobals();
|
||||
delete HTMLElement.prototype.checkVisibility;
|
||||
});
|
||||
it.each([true, false])("labels the faction buttons only when banning (ban=%s)", async (ban) => {
|
||||
const engine = new Engine(["init 3 ban-label"], ban ? { auction: AuctionVariant.Silent } : {});
|
||||
engine.generateAvailableCommandsIfNeeded();
|
||||
expect(engine.availableCommands[0].name).toBe(ban ? Command.BanFaction : Command.ChooseFaction);
|
||||
const host = document.createElement("div");
|
||||
host.id = "old-ban-test";
|
||||
document.body.append(host);
|
||||
const viewer = launch("#old-ban-test");
|
||||
try {
|
||||
viewer.emit("player", { index: 0 });
|
||||
viewer.emit("state", JSON.parse(JSON.stringify(engine)));
|
||||
await vi.waitFor(() => expect(host.querySelector("#move-buttons .faction-picker-buttons")).not.toBeNull());
|
||||
const picker = host.querySelector("#move-buttons .faction-picker-buttons")!;
|
||||
const prompt = picker.querySelector(".faction-picker-prompt");
|
||||
if (ban) {
|
||||
expect(prompt?.textContent).toBe("Ban a faction");
|
||||
expect(prompt?.nextElementSibling?.querySelector("button.move-button")).not.toBeNull();
|
||||
expect(prompt?.closest("#move-title, .sticky-bar-title, .alert")).toBeNull();
|
||||
} else {
|
||||
expect(prompt).toBeNull();
|
||||
}
|
||||
} finally {
|
||||
viewer.app.$destroy();
|
||||
document.body.replaceChildren();
|
||||
}
|
||||
});
|
||||
|
||||
it("shows stopped premoves and opens their remaining steps with read-only played history", async () => {
|
||||
let engine = new Engine(
|
||||
Engine.parseMoves(`init 2 randomSeed
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/viewer",
|
||||
"version": "5.22.36",
|
||||
"version": "5.22.37",
|
||||
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
|
||||
"contributors": [
|
||||
"coyotte508",
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ describe("Commands", () => {
|
|||
button.textContent?.includes(name)
|
||||
);
|
||||
|
||||
expect(container.querySelector(".faction-picker-prompt")).to.equal(null);
|
||||
|
||||
const portraits = ["Tinkeroids", "Darkanians", "Moweyds", "Space Giants"].map((name) => {
|
||||
const image = buttonFor(name)?.querySelector<HTMLImageElement>("img");
|
||||
expect(image, `${name} portrait`).to.not.equal(null);
|
||||
|
|
@ -540,6 +542,11 @@ describe("Commands", () => {
|
|||
.filter((w) => w.text().includes("Terrans"));
|
||||
|
||||
expect(terransButton.length).to.equal(1);
|
||||
const prompt = wrapper.find("#move-buttons .faction-picker-buttons > .faction-picker-prompt");
|
||||
expect(prompt.text()).to.equal("Ban a faction");
|
||||
expect(prompt.isVisible()).to.equal(true);
|
||||
expect(prompt.element.nextElementSibling?.contains(terransButton.at(0).element)).to.equal(true);
|
||||
expect(prompt.element.closest("#move-title, .sticky-bar-title, .alert")).to.equal(null);
|
||||
|
||||
await terransButton.at(0).trigger("click");
|
||||
await Vue.nextTick();
|
||||
|
|
@ -860,10 +867,11 @@ describe("Commands", () => {
|
|||
expect(title.querySelector(".analysis-controls__shortfall").getAttribute("title")).to.contain("7 credits, 2 power");
|
||||
});
|
||||
|
||||
it("puts round 0's faction seed in the action area as one button per faction, announced in the header", async () => {
|
||||
it.each([false, true])("keeps round 0's planning faction seed separate from banning (ban=%s)", async (ban) => {
|
||||
// Owner instruction: every sandbox press belongs in this one action area. The picker used to be a
|
||||
// select plus a "Try this faction" button in AnalysisPanel.vue, above the map.
|
||||
const engine = new Engine(["init 2 lf-viewer-temporary-range"]);
|
||||
const engine = new Engine(["init 2 lf-viewer-temporary-range"], ban ? { auction: AuctionVariant.Silent } : {});
|
||||
engine.generateAvailableCommandsIfNeeded();
|
||||
const store = makeStore();
|
||||
store.commit("receiveData", engine);
|
||||
const choices = [
|
||||
|
|
@ -877,6 +885,7 @@ describe("Commands", () => {
|
|||
});
|
||||
|
||||
expect(container.querySelector("#move-title").textContent).to.contain("choose a faction to play as");
|
||||
expect(container.querySelector(".faction-picker-prompt")).to.equal(null);
|
||||
const buttons = Array.from(container.querySelectorAll("#move-buttons .faction-picker-buttons button"));
|
||||
expect(buttons.map((b) => b.textContent.trim())).to.deep.equal(["Terrans", "Nevlas"]);
|
||||
|
||||
|
|
|
|||
|
|
@ -379,6 +379,7 @@
|
|||
v-if="isBanningFaction && !analysisSeedActive"
|
||||
class="d-flex flex-wrap align-content-stretch faction-picker-buttons"
|
||||
>
|
||||
<p class="faction-picker-prompt w-100 small mb-1">Ban a faction</p>
|
||||
<MoveButton
|
||||
v-for="faction in factionToBan.data"
|
||||
:button="{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue