fix: add test coverage for crafting-utils, pact-utils, and activity-log

This commit is contained in:
2026-05-22 14:39:27 +02:00
parent 49f8de01ca
commit ca1709006f
21 changed files with 1963 additions and 25 deletions
+11 -1
View File
@@ -5,6 +5,7 @@ import { Component, ReactNode } from 'react';
interface ErrorBoundaryProps {
children: ReactNode;
fallback?: ReactNode;
onReset?: () => void;
}
interface ErrorBoundaryState {
@@ -24,11 +25,20 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
render() {
if (this.state.hasError) {
return this.props.fallback || (
if (this.props.fallback) return this.props.fallback;
return (
<div className="p-4 bg-red-900/20 border border-red-600/50 rounded">
<h3 className="text-red-400 font-bold mb-2">Something went wrong:</h3>
<pre className="text-xs text-red-300">{this.state.error?.message}</pre>
<pre className="text-xs text-gray-500 mt-2">{this.state.error?.stack}</pre>
{this.props.onReset && (
<button
onClick={this.props.onReset}
className="mt-3 px-3 py-1 bg-red-700 hover:bg-red-600 text-white text-xs rounded"
>
Reset &amp; Recover
</button>
)}
</div>
);
}
@@ -73,6 +73,17 @@ function EnemyRow({ enemy, floor }: { enemy: EnemyState; floor: number }) {
}
export function RoomDisplay({ floorState, floor }: RoomDisplayProps) {
// Guard against null/undefined/stale floorState
if (!floorState || !floorState.roomType) {
return (
<Card className="bg-gray-900/80 border-gray-700">
<CardHeader className="pb-2">
<CardTitle className="text-sm text-gray-400">Loading room...</CardTitle>
</CardHeader>
</Card>
);
}
const roomDisplay = getSpireRoomTypeDisplay(floorState.roomType as RoomType);
// Handle special room types (cast to string for extended types)