Skip to content

fix(tests): align BetType with SelectionType in locked-state test#121

Draft
Copilot wants to merge 9 commits intomainfrom
copilot/sub-pr-118-another-one
Draft

fix(tests): align BetType with SelectionType in locked-state test#121
Copilot wants to merge 9 commits intomainfrom
copilot/sub-pr-118-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

The AustraliaSelection_ShouldRenderLockedState_WhenExistingSelectionIsLocked test had an internally inconsistent mock setup — the /selections/{raceId}/mine response used BetType = Regular while the /selections/current snapshot used SelectionType = "PreQualy", with assertions expecting the Pre-Qualy radio to be checked. This divergence masked potential regressions in bet-type propagation.

Changes

  • AustraliaSelectionTests.cs: Changed BetType = BetType.RegularBetType = BetType.PreQualy in the locked-state test's Selection mock, aligning it with the snapshot's SelectionType and the existing assertions.
// Before — inconsistent: BetType.Regular but snapshot says "PreQualy"
handler.EnqueueResponse(CreateJsonResponse(new Selection
{
    BetType = BetType.Regular,  // ← mismatch
    IsLocked = true,
    ...
}));

// After — consistent: both agree on PreQualy
handler.EnqueueResponse(CreateJsonResponse(new Selection
{
    BetType = BetType.PreQualy,  // ← matches snapshot SelectionType and assertion
    IsLocked = true,
    ...
}));

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

PhilipWoulfe and others added 8 commits March 12, 2026 08:34
… on Australia selection page with full API/UI tests

add development-only mock data toggle for current selections endpoint and document env config
… mapping, and persist dev mock selections in memory
…normalize legacy selection data while keeping compatibility

remove legacy selection data
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
`ValidateSelections` only checked that 5 non-empty drivers were present,
allowing payloads with extra empty/whitespace entries (e.g. 6 items: 5
valid + 1 empty) to pass validation and be persisted as-is —
inconsistent with `ValidateMockSubmission` which requires `Count == 5`.

## Changes

- **`SelectionService.ValidateSelections`**: Added upfront
`selections.Count != 5` guard before the existing non-empty/distinct
checks:

```csharp
if (selections.Count != 5)
{
    throw new SelectionValidationException("Exactly 5 unique drivers must be selected.");
}
```

- **`SelectionServiceTests`**: Added
`UpsertSelectionAsync_ShouldReject_WhenMoreThanFiveSelectionsSubmitted`
covering the 5-valid + 1-empty payload case.

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PhilipWoulfe <8867626+PhilipWoulfe@users.noreply.github.com>
`GetCurrentSelectionsAsync` iterated `OrderedSelections` in persistence
order, making the endpoint non-deterministic and inconsistent with the
`Position` field's semantics.

## Changes

- **`SelectionService.cs`** — Sort `OrderedSelections` by `Position`
before building response rows:
  ```csharp
  var orderedSelections = selection.OrderedSelections
      .OrderBy(item => item.Position)
      .ToList();
  ```
- **`SelectionServiceTests.cs`** — Added
`GetCurrentSelectionsAsync_ShouldReturnRowsSortedByPosition_WhenSelectionsAreOutOfOrder`
to assert correct ordering when items are persisted out of sequence.

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/PhilipWoulfe/F1Competition/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PhilipWoulfe <8867626+PhilipWoulfe@users.noreply.github.com>
Co-authored-by: PhilipWoulfe <8867626+PhilipWoulfe@users.noreply.github.com>
Copilot AI changed the title [WIP] [WIP] Address feedback on "Feat/#86 retrieve selections" PR fix(tests): align BetType with SelectionType in locked-state test Mar 12, 2026
Base automatically changed from feat/#86-retrieve-selections to main March 12, 2026 11:06
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