Skip to content

Fix bugs and add Higher or Lower game with Playwright tests#30

Merged
krellekrelle merged 6 commits into
mainfrom
feat/casino-service
Jun 2, 2026
Merged

Fix bugs and add Higher or Lower game with Playwright tests#30
krellekrelle merged 6 commits into
mainfrom
feat/casino-service

Conversation

@krellekrelle

Copy link
Copy Markdown
Owner

No description provided.

Bug fixes:
- Landing.jsx: SignalR LobbyCreated handler registered before connection was ready
  (React child effects run before parent; guard with 'if (!isConnected) return')
- CasinoHub.cs: UpdateLobbySettings used case-sensitive JSON deserialization,
  so camelCase 'chamberCount' from JS never mapped to PascalCase 'ChamberCount' in C#
  (add PropertyNameCaseInsensitive: true to JsonSerializerOptions)
- Game.jsx: after a 'bang', the trigger overlay was never cleared, blocking the
  finished screen from rendering (SessionFinished handler now clears overlay after 2s)
- GameView.jsx + RussianRouletteEngine.cs + IGameEngine.cs: chamberCount was missing
  from the public game state, showing '?' during active gameplay
  (add chamberCount to GetPublicState via settings parameter)

Test infrastructure:
- tests/playwright.config.js: config moved from root, uses local Docker stack
- tests/global-setup.js: mints JWT tokens directly, bypasses Google OAuth
- tests/casino-roulette-e2e.spec.js: full E2E — two players, lobby creation,
  settings update, ready-up, start, pull triggers to game over
New game: Higher or Lower
- Players take turns guessing if the next card is higher or lower
- Pot grows by BaseFine every card drawn; first wrong guess pays the pot
- Ties count as correct (game lives on)
- Deck auto-reshuffles if exhausted (52-card standard deck)
- Ace = highest (14), 2 = lowest

Backend:
- HigherOrLowerEngine: full IGameEngine implementation with Fisher-Yates shuffle
- HigherOrLowerSettings: baseFine + fineUnit (DKK, beers, etc.)
- HigherOrLowerState: deck, currentCard, pot, turnOrder, history
- New Guess hub method with GuessResult broadcast
- IGameEngine.ApplyAction + GetPublicState now take settings parameter
- GameStarted/GameStateUpdated broadcasts wrapped with gameType field
- HigherOrLowerEngine registered in Program.cs

Frontend:
- HigherOrLower/GameView.jsx: card table, pot display, Higher/Lower buttons,
  guess history, correct/wrong overlay, game over screen
- HigherOrLower/GameView.css: green card table, playing card components,
  animated overlays
- Game.jsx: routes to correct view by gameType; handles GuessResult event
- Lobby.jsx: game-type-specific settings form (baseFine/fineUnit vs chambers)
- Landing.jsx: two start buttons (Russian Roulette + Higher or Lower)

Tests:
- casino-higher-or-lower-e2e.spec.js: full E2E two-player game
- casino-roulette-e2e.spec.js: fix button selector after label change
- Button: add href/target/rel props (renders as <a> when href set)
- Button: add 'success' variant
- Button: update stories with AsLink and Success examples
- New AppCard: service tile with icon, title, description, CTA button and badge support
- New StatusCard: full-page centered auth status layout (login/pending/rejected)
- Export AppCard and StatusCard from index.ts
- Add css-modules.d.ts to fix pre-existing CSS module TypeScript errors
- Replace static HTML files (dashboard, login, pending, rejected, admin)
  with a Vite + React SPA following the same pattern as hello-world-app
  and casino-service
- Pages use NavBar, Button, AppCard, StatusCard, Card, Badge from ui-library
- DashboardPage: responsive AppCard grid of all services; admin cards shown
  conditionally based on user.isAdmin
- AdminPage: stats row, tabbed user table with approve/reject/promote/demote/
  fine-club/delete actions and confirmation modal — all in ui-library tokens
- LoginPage: dark-theme Google sign-in button with proper branding
- PendingPage: Check Status flow (refresh tokens then re-check /api/user)
- RejectedPage: simple denied screen
- server.js: replace inline HTML blobs with serveSPA() helper; all protected
  routes still enforce JWT auth before serving index.html
- Dockerfile: multi-stage build (monorepo root context → build frontend →
  production Node stage)
- docker-compose.yml: change landing-page build from './landing-page'
  to context:'.' + dockerfile:'landing-page/Dockerfile' (matches
  hello-world-app and casino-service pattern)
- build-deploy.yml: add landing-page matrix entry with monorepo root
  build context; add ui-library/** to landing-page change trigger
- Commit tests/package-lock.json (should have been tracked)
- Add tests/playwright-report/ and tests/test-results/ to .gitignore
  (generated artifacts, change every run)
@krellekrelle
krellekrelle merged commit d2b0e50 into main Jun 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant