feat: make tracked effect owners editable

Default effect ownership to active participant, allow inline reassignment or clearing, move owner-linked effects between participant cards, and add direct turns-left editing coverage.
This commit is contained in:
david raistrick committed 2026-10-20 18:18:54 -04:00
1 parent 295c7e06b4
commit 0e7bc7c099
2 files changed
+41 -11

No files matched your search

+16 -5
View File
@@ -2,7 +2,7 @@ import { screen, fireEvent, waitFor, within } from '@testing-library/react';
import '@testing-library/jest-dom';
import {
setupReady, addMonsterViaUI, renderApp, createCampaignViaUI,
selectCampaignByName, selectEncounterByName, MOCK_DB,
selectCampaignByName, selectEncounterByName, startCombatViaUI, MOCK_DB,
} from './testHelpers';
function latestEncounter() {
@@ -57,16 +57,27 @@ describe('tracked effects DM UI', () => {
test('Spiritual Weapon preset creates 10-round encounter effect', async () => {
await setupReady('Weapon Camp', 'Weapon Encounter');
await addMonsterViaUI('Cleric', 30, 2);
await addMonsterViaUI('Wizard', 24, 3);
fireEvent.click(screen.getByRole('button', { name: 'Open conditions' }));
await startCombatViaUI();
const activeId = latestEncounter().currentTurnParticipantId;
const otherId = latestEncounter().participants.find(p => p.id !== activeId).id;
fireEvent.click(within(screen.getByTestId(`admin-participant-card-${otherId}`)).getByRole('button', { name: 'Open conditions' }));
fireEvent.click(screen.getByRole('button', { name: 'Spiritual Weapon' }));
await waitFor(() => expect(latestEncounter().effects[0]).toMatchObject({
presetId: 'spiritual_weapon', name: 'Spiritual Weapon', scope: 'encounter',
remainingRounds: 10, expiresOnDamage: false, playerDisplay: 'prominent',
ownerParticipantId: activeId, remainingRounds: 10,
expiresOnDamage: false, playerDisplay: 'prominent',
}));
const clericId = latestEncounter().participants.find(p => p.name === 'Cleric').id;
expect(within(screen.getByTestId(`admin-participant-card-${clericId}`)).getByText('SPIRITUAL WEAPON')).toBeInTheDocument();
expect(within(screen.getByTestId(`admin-participant-card-${activeId}`)).getByText('SPIRITUAL WEAPON')).toBeInTheDocument();
const ownerSelect = screen.getByLabelText('Owner for Spiritual Weapon');
expect(ownerSelect).toHaveValue(activeId);
fireEvent.change(ownerSelect, { target: { value: otherId } });
await waitFor(() => expect(latestEncounter().effects[0].ownerParticipantId).toBe(otherId));
expect(within(screen.getByTestId(`admin-participant-card-${otherId}`)).getByText('SPIRITUAL WEAPON')).toBeInTheDocument();
expect(within(screen.getByTestId(`admin-participant-card-${activeId}`)).queryByText('SPIRITUAL WEAPON')).not.toBeInTheDocument();
});
test('generic ruleset offers custom effects only and rounds only', async () => {