Files
Dune/tests/emperor-auction-gift-cache-controls.test.tsx
T
Quintine 28700389dc
Verify and publish checkpoint container / container (push) Successful in 11m23s
Support Advanced expansion auction gifts
2026-11-16 18:28:19 +11:00

42 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import assert from 'node:assert/strict';
import test from 'node:test';
import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import type { GameView } from '../game/engine';
import { EmperorAuctionGift } from '../components/emperor-auction-gift';
/** Synthetic owner projection: this verifies the rendered distinction, not
* a claim that a real cache-sale journey has already reached this control. */
const view = (source?: 'richese') => ({
players: [{id:'ally', name:'Ally'}],
emperorAuctionGift: {event:'gift-event', recipient:'ally', maximum:5, ...(source ? {source} : {})},
}) as unknown as GameView;
const render = (game: GameView, busy = false) => renderToStaticMarkup(
createElement(EmperorAuctionGift, {game, busy, act() {}}),
);
void test('Richese sale describes the committed payment and retains gift and Continue controls', () => {
const html = render(view('richese'));
assert.match(html, /Share spice with Ally/);
assert.match(html, /Continue settles the Richese sale with that payment after any gift response/);
assert.doesNotMatch(html, /Your ally chooses how to pay/);
assert.match(html, /<button\b(?![^>]*disabled)[^>]*>Share spice<\/button>/);
assert.match(html, /<button\b(?![^>]*disabled)[^>]*>Continue to payment<\/button>/);
assert.match(render(view('richese'), true), /<button\b[^>]*disabled=""[^>]*>Continue to payment<\/button>/);
});
void test('ordinary auction keeps its original buyer-payment guidance', () => {
const html = render(view());
assert.match(html, /Your ally chooses how to pay after the gift’s Karama response/);
assert.doesNotMatch(html, /Continue settles the Richese sale/);
});
void test('a live ally-funding guide remains actionable before the sale continues', () => {
const game = view('richese');
game.pledgePromiseGuide = {action:{type:'pledgeAid',amount:4}};
const html = render(game);
assert.match(html, /Set your promised ally funding before this purchase can close Bidding/);
assert.match(html, /<button\b(?![^>]*disabled)[^>]*>Set required ally funding<\/button>/);
assert.match(html, /<button\b[^>]*disabled=""[^>]*>Continue to payment<\/button>/);
});