diff --git a/client/src/item-actions.ts b/client/src/item-actions.ts index b15b096..351154b 100644 --- a/client/src/item-actions.ts +++ b/client/src/item-actions.ts @@ -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)); diff --git a/tests/progression.spec.ts b/tests/progression.spec.ts index 5dc26a4..1347b50 100644 --- a/tests/progression.spec.ts +++ b/tests/progression.spec.ts @@ -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);