Skip to content

increase Test coverage to 80.8%#2449

Merged
sydseter merged 1 commit intoOWASP:masterfrom
muhammad7865:chore/Test-imporve
Mar 1, 2026
Merged

increase Test coverage to 80.8%#2449
sydseter merged 1 commit intoOWASP:masterfrom
muhammad7865:chore/Test-imporve

Conversation

@muhammad7865
Copy link
Contributor

@muhammad7865 muhammad7865 commented Feb 28, 2026

Fixes #2157

This PR improves the overall test coverage for the copi application to 81.9%. Let's review the approach and the changes that made this possible:

Changes Include:

  • Environment & Config: Fixed the Docker ADDGROUP error to allow building the test image, and added coveralls.json to properly exclude non-testable boilerplate files (like migrations) from coverage metrics.
  • Domain Logic: Added CornucopiaLogicTest to cover the complex scoring and game logic helper functions.
  • Integration Tests: Expanded the LiveView tests for GameLive and PlayerLive to handle end-to-end interactions like card selection, voting, and rate-limiting rules.
  • Components & Plugs: Added explicit tests for the rate limiter, UI components, and IP helpers (RateLimiterPlugTest, IpHelperTest, and CoreComponentsTest).
  • General Cleanup: Removed legacy warnings, unused imports, and fixed the syntax error Nested mappings bug in the GitHub .github/workflows/copi-deploy-staging.yml file.

Verification

Finished in 1.9 seconds (0.5s async, 1.4s sync)
57 tests, 0 failures

----------------
COV    FILE                                        LINES RELEVANT   MISSED
 80.0% lib/copi/application.ex                        38        5        1
100.0% lib/copi/cornucopia.ex                        416       58        0
100.0% lib/copi/cornucopia/game.ex                    65       15        0
...
 96.0% lib/copi_web/components/core_components.      630      152        6
 84.8% lib/copi_web/live/player_live/form_compo      121       33        5
 70.0% lib/copi_web/plugs/rate_limiter_plug.ex        42       10        3
...
[TOTAL]  81.9%
----------------

Copilot AI review requested due to automatic review settings February 28, 2026 20:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR focuses on increasing automated test coverage in the copi.owasp.org Elixir/Phoenix app, particularly around rate limiting and IP extraction logic, and adds some supporting test-runner configuration.

Changes:

  • Expanded/adjusted tests for rate limiting (Plug + LiveView) and IP extraction helpers to cover more branches.
  • Added a new schema changeset test (ContinueVote) to raise overall coverage.
  • Added/updated test environment tooling/config (Docker Compose test runner, test DB host env var, minor workflow tweak) and bumped nimble_ownership.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
copi.owasp.org/test/copi_web/plugs/rate_limiter_plug_test.exs Reworked plug tests to cover forwarded vs remote vs missing IP paths and 429 behavior.
copi.owasp.org/test/copi_web/live/player_live_test.exs Avoids heavy LiveView/DB loops by simulating rate limit saturation directly.
copi.owasp.org/test/copi_web/live/game_live_test.exs More robust selector for starting a game; adds coverage for ignoring non-matching broadcast topics.
copi.owasp.org/test/copi/ip_helper_test.exs Replaces/expands IP helper coverage across conn/socket/connect_info scenarios and formatting.
copi.owasp.org/test/copi/cornucopia/continue_vote_test.exs Adds changeset validity tests for ContinueVote.
copi.owasp.org/mix.lock Bumps nimble_ownership patch version.
copi.owasp.org/docker-compose.test.yml Introduces a docker-compose-based test runner with Postgres for local/CI usage.
copi.owasp.org/config/test.exs Makes test DB hostname configurable via DB_HOST.
.github/workflows/copi-deploy-staging.yml Minor YAML change for test step formatting (no functional change expected).

@sydseter sydseter merged commit c35ca60 into OWASP:master Mar 1, 2026
12 of 13 checks passed
@muhammad7865 muhammad7865 deleted the chore/Test-imporve branch March 1, 2026 12:09
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.

Improve test coverage for copi.owasp.org

3 participants