Single source of truth: combat logic, storage parity, slot ordering #3

Merged
robert merged 32 commits from single-source into main 2026-07-05 00:07:57 -04:00
2 changed files with 4 additions and 6 deletions
Showing only changes of commit d1cc3a8b9a - Show all commits
+1 -5
View File
@@ -1,5 +1,6 @@
// jest setup: RTL jest-dom + mock DB reset per test. // jest setup: RTL jest-dom + mock DB reset per test.
import '@testing-library/jest-dom'; import '@testing-library/jest-dom';
import { resetMockDb } from './__mocks__/firebase/_mock-db';
// RTL v14: tell React this is an act environment. Without it every // RTL v14: tell React this is an act environment. Without it every
// async update warns "current testing environment is not configured to // async update warns "current testing environment is not configured to
@@ -21,11 +22,6 @@ console.warn = (...args) => {
originalWarn(...args); originalWarn(...args);
throw new Error(`console.warn in test: ${args.map(String).join(' ').slice(0, 500)}`); throw new Error(`console.warn in test: ${args.map(String).join(' ').slice(0, 500)}`);
}; };
import { resetMockDb } from './__mocks__/firebase/_mock-db';
// Tell React this is an act environment. Without it, every act() call
// emits 'current testing environment is not configured to support act'.
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
// polyfill crypto.randomUUID for jsdom (used by generateId in App.js). // polyfill crypto.randomUUID for jsdom (used by generateId in App.js).
if (!global.crypto) global.crypto = {}; if (!global.crypto) global.crypto = {};
+3 -1
View File
@@ -123,7 +123,9 @@ describe('Combat -> Firebase', () => {
test('toggleHidePlayerHp: updateDoc patch on activeDisplay/status', async () => { test('toggleHidePlayerHp: updateDoc patch on activeDisplay/status', async () => {
await setupWithMonsters(); await setupWithMonsters();
await startCombatViaUI(); await startCombatViaUI();
const switchBtn = screen.getByRole('switch'); // Two switches now (Hide player HP + Hide NPC/monster HP). Scope to player one.
const playerHpLabel = screen.getByText('Hide player HP');
const switchBtn = playerHpLabel.parentElement.querySelector('[role="switch"]');
fireEvent.click(switchBtn); fireEvent.click(switchBtn);
await waitFor(() => { await waitFor(() => {
const adCalls = findCallActiveDisplay('updateDoc'); const adCalls = findCallActiveDisplay('updateDoc');