fix(combat): keep the busy() re-entrancy guard, split the action-mapping test instead
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -114,20 +114,39 @@ describe('CombatPageComponent', () => {
|
|||||||
expect(element.querySelector('[data-combat-potion]')?.textContent).toContain('Trank 2/2');
|
expect(element.querySelector('[data-combat-potion]')?.textContent).toContain('Trank 2/2');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sends the matching action for each of the four new buttons', async () => {
|
it('sends HEAVY_STRIKE when Schwerer Hieb is clicked', async () => {
|
||||||
const fixture = await setup(activeCombat);
|
const fixture = await setup(activeCombat);
|
||||||
const element = fixture.nativeElement as HTMLElement;
|
const element = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
element.querySelector<HTMLButtonElement>('[data-combat-heavy-strike]')?.click();
|
element.querySelector<HTMLButtonElement>('[data-combat-heavy-strike]')?.click();
|
||||||
|
|
||||||
expect(combatStore.performAction).toHaveBeenCalledWith('HEAVY_STRIKE');
|
expect(combatStore.performAction).toHaveBeenCalledWith('HEAVY_STRIKE');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sends SHIELD_BASH when Schildstoß is clicked', async () => {
|
||||||
|
const fixture = await setup(activeCombat);
|
||||||
|
const element = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
element.querySelector<HTMLButtonElement>('[data-combat-shield-bash]')?.click();
|
element.querySelector<HTMLButtonElement>('[data-combat-shield-bash]')?.click();
|
||||||
|
|
||||||
expect(combatStore.performAction).toHaveBeenCalledWith('SHIELD_BASH');
|
expect(combatStore.performAction).toHaveBeenCalledWith('SHIELD_BASH');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sends DEFEND when Verteidigen is clicked', async () => {
|
||||||
|
const fixture = await setup(activeCombat);
|
||||||
|
const element = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
element.querySelector<HTMLButtonElement>('[data-combat-defend]')?.click();
|
element.querySelector<HTMLButtonElement>('[data-combat-defend]')?.click();
|
||||||
|
|
||||||
expect(combatStore.performAction).toHaveBeenCalledWith('DEFEND');
|
expect(combatStore.performAction).toHaveBeenCalledWith('DEFEND');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sends POTION when Trank is clicked', async () => {
|
||||||
|
const fixture = await setup(activeCombat);
|
||||||
|
const element = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
element.querySelector<HTMLButtonElement>('[data-combat-potion]')?.click();
|
element.querySelector<HTMLButtonElement>('[data-combat-potion]')?.click();
|
||||||
|
|
||||||
expect(combatStore.performAction).toHaveBeenCalledWith('POTION');
|
expect(combatStore.performAction).toHaveBeenCalledWith('POTION');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export class CombatPageComponent implements OnInit {
|
|||||||
|
|
||||||
protected async performAction(action: CombatAction): Promise<void> {
|
protected async performAction(action: CombatAction): Promise<void> {
|
||||||
const before = this.displayed();
|
const before = this.displayed();
|
||||||
if (!before) {
|
if (!before || this.busy()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user