Fix equip coverage after the item-action refactor
The item action buttons derived their focus key from the visible label, so
the bag's Equip button became "Equip-<id>" when 9b01ee3 replaced the panel's
own lowercase "equip-<id>" button with itemControls. Slugify the label so the
key stays stable when a button is reworded, and point the progression spec at
the item-action endpoint the refactor moved equip onto -- it still polled the
websocket intents, which no longer carry equip.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,7 @@ export function createItemActions(o:Options){
|
||||
}
|
||||
function controls(id:string,slot:string){
|
||||
const row=node('div','','gear-actions'),c=o.character();if(!c)return row;const item=c.items.find(i=>i.id===id),consumable=c.consumables?.find(i=>i.id===id),disabled=c.entity.state!=='alive'||c.remainingSeconds<=0||!!c.houseId;
|
||||
function button(label:string,fn:()=>void,extra=false){const b=node('button',label);b.type='button';b.dataset.focusKey=`${label}-${id}`;b.disabled=(label.startsWith('Drop')&&c!.entity.state==='eligible'?c!.remainingSeconds<=0||!!c!.houseId:disabled)||extra;b.onclick=fn;row.append(b)}
|
||||
function button(label:string,fn:()=>void,extra=false){const b=node('button',label);b.type='button';b.dataset.focusKey=`${label.toLowerCase().replaceAll(' ','-')}-${id}`;b.disabled=(label.startsWith('Drop')&&c!.entity.state==='eligible'?c!.remainingSeconds<=0||!!c!.houseId:disabled)||extra;b.onclick=fn;row.append(b)}
|
||||
if(item&&!item.houseId&&!item.furniture)button('Equip',()=>activate(id,slot),!item.equippable);
|
||||
if(!item&&(id==='bandage'||consumable&&consumable.useEffect?.kind!=='weapon-coating'||id==='escape_stone'||id.startsWith('book_')))button(id.startsWith('book_')?'Learn':'Consume',()=>activate(id));
|
||||
if(id.startsWith('kit_'))button('Place',()=>o.place(id));
|
||||
|
||||
@@ -20,6 +20,8 @@ test('progression and signed permanent titles render in game, account, and admin
|
||||
await page.route('**/api/control?*', route => route.fulfill({ json: { worlds, characters: [record], commands: [], provisioningEnabled: false, characterLimit: 500, auditLimit: 100 } }));
|
||||
let sendSnapshot: () => void = () => {};
|
||||
const intents: { op: string; target: string; slot: string }[] = [];
|
||||
const itemActions: { op: string; item: string; slot: string }[] = [];
|
||||
await page.route('**/api/item-action', route => { itemActions.push(route.request().postDataJSON()); route.fulfill({ json: { id: 'item-action-fixture', message: 'Equipped Trial Ring.', returned: {} } }); });
|
||||
await page.routeWebSocket('**/ws', socket => {
|
||||
socket.onMessage(raw => { const intent = JSON.parse(String(raw)); if (intent.op !== 'move') intents.push(intent); });
|
||||
sendSnapshot = () => {
|
||||
@@ -40,7 +42,7 @@ test('progression and signed permanent titles render in game, account, and admin
|
||||
sendSnapshot();
|
||||
await expect(page.getByLabel('Ring slot for Trial Ring')).toHaveValue('ring8');
|
||||
await page.locator('[data-focus-key="equip-ring-fixture"]').click();
|
||||
await expect.poll(() => intents.at(-1)).toMatchObject({ op: 'equip', target: 'ring-fixture', slot: 'ring8' });
|
||||
await expect.poll(() => itemActions.at(-1)).toMatchObject({ op: 'equip', item: 'ring-fixture', slot: 'ring8' });
|
||||
character.equipment.ring8 = 'ring-fixture'; sendSnapshot();
|
||||
await page.getByRole('navigation', { name: 'Character menus' }).getByRole('button', { name: 'Equipment', exact: true }).click();
|
||||
await expect(page.locator('.equipment-slot')).toHaveCount(21);
|
||||
|
||||
Reference in New Issue
Block a user