From ebc0525c899b673500dbb3ea2a335c3bb3f29255 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Wed, 30 Jul 2025 22:35:23 -0400 Subject: [PATCH] Enforce minimum test coverage (#1646) ## Description: Enforce minimum test coverage. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [ ] I have read and accepted the CLA agreement (only required once). --- .github/workflows/ci.yml | 2 +- jest.config.ts | 8 ++++---- src/client/graphics/GameRenderer.ts | 3 +-- src/client/graphics/layers/EmojiTable.ts | 7 +++---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b920e29e..b19bf60f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: with: node-version: 20 - run: npm ci - - run: npm test + - run: npm run test:coverage eslint: name: 🔍 ESLint diff --git a/jest.config.ts b/jest.config.ts index c619f7d52..014158c29 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -29,10 +29,10 @@ export default { collectCoverageFrom: ["src/**/*.ts", "!src/**/*.d.ts"], coverageThreshold: { global: { - branches: 0, - functions: 0, - lines: 0, - statements: 0, + statements: 22.2, + branches: 17.5, + lines: 22.7, + functions: 21.2, }, }, coverageReporters: ["text", "lcov", "html"], diff --git a/src/client/graphics/GameRenderer.ts b/src/client/graphics/GameRenderer.ts index b412ff1fa..bc4d3406d 100644 --- a/src/client/graphics/GameRenderer.ts +++ b/src/client/graphics/GameRenderer.ts @@ -61,10 +61,9 @@ export function createRenderer( if (!emojiTable || !(emojiTable instanceof EmojiTable)) { console.error("EmojiTable element not found in the DOM"); } - emojiTable.eventBus = eventBus; emojiTable.transformHandler = transformHandler; emojiTable.game = game; - emojiTable.initEventBus(); + emojiTable.initEventBus(eventBus); const buildMenu = document.querySelector("build-menu") as BuildMenu; if (!buildMenu || !(buildMenu instanceof BuildMenu)) { diff --git a/src/client/graphics/layers/EmojiTable.ts b/src/client/graphics/layers/EmojiTable.ts index 7a9702578..542c24d37 100644 --- a/src/client/graphics/layers/EmojiTable.ts +++ b/src/client/graphics/layers/EmojiTable.ts @@ -12,12 +12,11 @@ import { TransformHandler } from "../TransformHandler"; @customElement("emoji-table") export class EmojiTable extends LitElement { @state() public isVisible = false; - public eventBus: EventBus; public transformHandler: TransformHandler; public game: GameView; - initEventBus() { - this.eventBus.on(ShowEmojiMenuEvent, (e) => { + initEventBus(eventBus: EventBus) { + eventBus.on(ShowEmojiMenuEvent, (e) => { this.isVisible = true; const cell = this.transformHandler.screenToWorldCoordinates(e.x, e.y); if (!this.game.isValidCoord(cell.x, cell.y)) { @@ -40,7 +39,7 @@ export class EmojiTable extends LitElement { targetPlayer === this.game.myPlayer() ? AllPlayers : (targetPlayer as PlayerView); - this.eventBus.emit( + eventBus.emit( new SendEmojiIntentEvent( recipient, flattenedEmojiTable.indexOf(emoji),