Skip to content

Add test coverage and fix handling for zero value progression calculations#133

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-progression-test-cases
Draft

Add test coverage and fix handling for zero value progression calculations#133
Copilot wants to merge 3 commits intomainfrom
copilot/add-progression-test-cases

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 12, 2026

Adds comprehensive test cases for progression calculations when endValue is 0, covering normal stats, quotient stats (fkdr/kdr), and stars/experience. Also fixes the implementation to properly handle zero values with appropriate milestones.

Changes

  • Linear stats: 45 test cases covering all 9 stats × 5 gamemodes

    • Tests the case where stats remain at 0 (no progress)
    • Milestone is set to 1 when current value is 0
    • Days until milestone is Infinity when there's no progress
  • Quotient stats: 10 test cases for fkdr/kdr × 5 gamemodes

    • Tests when both dividend and divisor are 0 (no progress)
    • Milestone is set to 1 with sessionQuotient of 0
  • Stars/Experience: 10 test cases × 5 gamemodes

    • Tests when experience is 0 and remains at 0
    • Experience milestone is 1, stars milestone is 100 (next prestige)
    • Days until milestone is Infinity with no progress
  • Implementation fix: Updated progression.ts to handle endValue === 0 case

    • When endValue is 0 with no progress, returns milestone of 1 with Infinity days
    • Prevents Math.log10(0) which causes NaN values
    • "No progress" is no longer an error case, returns valid result instead

Example test structure:

await t.test("edge case - zero current value", () => {
    // Start: 0, End: 0 (no change)
    const history: History = [
        new PlayerDataBuilder(TEST_UUID, startDate)
            .withGamemodeStats(gamemode, 
                new StatsBuilder().withStat(stat, 0).build())
            .build(),
        new PlayerDataBuilder(TEST_UUID, endDate)
            .withGamemodeStats(gamemode, 
                new StatsBuilder().withStat(stat, 0).build())
            .build(),
    ];
    
    assert.deepStrictEqual(result, {
        stat, endValue: 0, progressPerDay: 0,
        nextMilestoneValue: 1, daysUntilMilestone: Infinity,
        trendingUpward: true,
        trackingDataTimeInterval: { start: startDate, end: endDate }
    });
});

Total: 65 new test cases. All 463 tests pass.

Original prompt

Add test cases to the progression tests covering the case when the current value is 0. Both for normal stats, quotient stats and stars/exp. For stars/ exp note that these cases are constructed, and new players have 500exp/1 star


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Jan 12, 2026
- Added "edge case - zero current value" tests for linear gamemode stats
- Added "edge case - zero current value" tests for quotient stats (fkdr, kdr)
- Added "edge case - zero current value" tests for stars/exp
- All tests document the actual behavior when current values are 0
- Tests cover all gamemodes (solo, doubles, threes, fours, overall)

Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Jan 12, 2026

Deploying rainbow with  Cloudflare Pages  Cloudflare Pages

Latest commit: 41a3374
Status: ✅  Deploy successful!
Preview URL: https://c124b34e.rainbow-ctx.pages.dev
Branch Preview URL: https://copilot-add-progression-test.rainbow-ctx.pages.dev

View logs

Copilot AI changed the title [WIP] Add test cases for progression tests with current value 0 Add test coverage for progression calculations with zero current values Jan 12, 2026
Copilot AI requested a review from Amund211 January 12, 2026 22:24
Copy link
Copy Markdown
Owner

@Amund211 Amund211 left a comment

Choose a reason for hiding this comment

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

Update the cases to not decrease in stats. When the end value is 0, the start value should be 0 as well. Also update the test cases to have milestone 1 when the value is 0. Then fix the implementation to handle this @copilot

- Changed test cases: start and end values are both 0 (no decrease in stats)
- Updated test expectations: milestone is 1 when value is 0, daysUntilMilestone is Infinity
- Fixed implementation: handle endValue === 0 case with milestone of 1
- Removed "no progress" from error cases as it now returns valid result with infinite time
- All 463 tests pass

Co-authored-by: Amund211 <14028449+Amund211@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

Update the cases to not decrease in stats. When the end value is 0, the start value should be 0 as well. Also update the test cases to have milestone 1 when the value is 0. Then fix the implementation...

Updated the test cases and implementation in commit 41a3374:

  • Test cases now have both start and end values at 0 (no decrease in stats)
  • When endValue is 0, milestone is set to 1 and daysUntilMilestone is Infinity
  • Fixed the implementation to handle the endValue === 0 case properly
  • Removed "no progress" from error cases since it now returns a valid result

All 463 tests pass.

Copilot AI changed the title Add test coverage for progression calculations with zero current values Add test coverage and fix handling for zero value progression calculations Jan 13, 2026
Copilot AI requested a review from Amund211 January 13, 2026 07:26
@Amund211
Copy link
Copy Markdown
Owner

zero value tests should probably just be just a special case of the no progress cases, which should return a milestone and infinite expected time instead of a no progress error

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.

2 participants