From bfa8389a9936a89d80cd8838bc46ae6a353af8dd Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Wed, 18 Nov 2026 23:29:02 +0000 Subject: [PATCH] Focus bank cargo bidding on board pieces and cancel zero cash drafts locally --- viewer/scripts/offshore-smoke.mjs | 47 ++++++++++++- viewer/src/components/Game.vue | 80 ++++++++++------------ viewer/src/components/OffshoreBank.vue | 2 +- viewer/src/components/pieces/Container.vue | 39 ++++++++++- viewer/tests/unit/offshore-bank.spec.ts | 26 ++++++- 5 files changed, 144 insertions(+), 50 deletions(-) diff --git a/viewer/scripts/offshore-smoke.mjs b/viewer/scripts/offshore-smoke.mjs index a9a4418..cf68664 100644 --- a/viewer/scripts/offshore-smoke.mjs +++ b/viewer/scripts/offshore-smoke.mjs @@ -103,6 +103,22 @@ try { ); assert.ok(bounds.x >= 0 && bounds.x + bounds.width <= width + 1, 'complete draft visible horizontally'); }; + // Zero cancels this bank draft only, by either mouse or keyboard. + for (const keyboard of [false, true]) { + const zeroCalculator = page.locator('[data-tutorial="bank-bid"]'); + assert.equal( + await page.locator('.bank-draft').getByRole('button', { name: 'Cancel', exact: true }).count(), + 0 + ); + if (keyboard) { + await zeroCalculator.focus(); + await zeroCalculator.press('0'); + await zeroCalculator.press('Enter'); + } else await zeroCalculator.getByRole('button', { name: 'Bid', exact: true }).click(); + assert.equal(await page.locator('.bank-draft, .offshore-lot.selected').count(), 0); + assert.equal(await page.evaluate(() => moves.length), 0); + await page.locator('.offshore-lot[data-type="containers"][data-lot="2"]').click(); + } await checkDraft('containers', 2); const calculator = page.locator('[data-tutorial="bank-bid"]'); await calculator.focus(); @@ -147,9 +163,36 @@ try { state.players[player].containersOnWarehouseStore.push({ piece: second, price: 3, moved: false }); await push(); await page.locator('.offshore-lot[data-type="cash"][data-lot="1"]').click(); - await page.locator(`.bank-draft [data-piece-id="${offered.id}"]`).click(); - await page.locator(`.bank-draft [data-piece-id="${second.id}"]`).click(); + await page.locator(`.piece.bid-eligible[data-piece-id="${offered.id}"]`).click(); + await page.locator(`.piece.bid-eligible[data-piece-id="${second.id}"]`).click(); assert.equal(await page.evaluate(() => moves.length), 0, 'selection never auto-submits'); + assert.equal(await page.locator('.piece.canDrag, .loan.canDrag, .offshore-lot.legal').count(), 0); + assert.equal(await page.locator('.piece.bid-selected').count(), 2); + assert.equal( + await page.locator('rect[stroke="blue"]').count(), + 1, + 'only draft frame remains, no ordinary action outlines' + ); + const selectedPiece = page.locator(`.piece[data-piece-id="${second.id}"]`); + await selectedPiece.focus(); + await selectedPiece.press('Space'); + assert.equal(await selectedPiece.getAttribute('aria-pressed'), 'false'); + await selectedPiece.press('Enter'); + assert.equal(await selectedPiece.getAttribute('aria-pressed'), 'true'); + if (width < 600) await page.locator('.player-board-tab').nth(player).click(); + await page.screenshot({ path: `/tmp/container-offshore-cargo-focus-${width}.png`, fullPage: true }); + + await page.getByRole('button', { name: 'Cancel', exact: true }).click(); + assert.equal(await page.locator('.bid-eligible, .bid-selected, .bank-draft').count(), 0); + assert.ok((await page.locator('.piece.canDrag').count()) > 0, 'cancel restores ordinary actions'); + assert.equal(await page.evaluate(() => moves.length), 0); + await page.locator('.offshore-lot[data-type="cash"][data-lot="1"]').click(); + await page.locator(`.piece.bid-eligible[data-piece-id="${offered.id}"]`).click(); + await page.locator(`.piece.bid-eligible[data-piece-id="${second.id}"]`).click(); + if (width < 600) { + await page.getByRole('button', { name: 'Bid (2)', exact: true }).click(); + assert.equal(await page.locator('.piece.bid-selected').count(), 2, 'navigation preserves draft'); + } await checkDraft('cash', 1); await page.screenshot({ path: `/tmp/container-offshore-cargo-draft-${width}.png`, fullPage: true }); const confirmBounds = await page.getByRole('button', { name: 'Confirm offer', exact: true }).boundingBox(); diff --git a/viewer/src/components/Game.vue b/viewer/src/components/Game.vue index 2c4e3ba..133591a 100644 --- a/viewer/src/components/Game.vue +++ b/viewer/src/components/Game.vue @@ -45,6 +45,7 @@ >{{ i === player ? 'You' : p.name }} +
Buy from {{ G.players[mobilePlayer].name }} @@ -243,6 +244,9 @@ rotate: container.rotate, }" :canDrag="canDragContainer(container)" + :bidEligible="bankContainerHighlights.includes(container.id)" + :bidSelected="offshoreContainers.has(container.id)" + @bid-select="toggleBankContainer(container.id)" :color="container.color" :owner="container.owner" :state="container.state" @@ -386,9 +390,10 @@ :aria-label="bankDraft.type === 'cash' ? 'Offer cargo' : 'Offer cash'" > - -