Repository navigation
Conversation
The Debate Details dialog on the Profile page built the type label with
`debateType.replace("_", " ")`, which only replaces the first underscore,
so `user_vs_bot` was shown as "User Vs_bot" (and "a user vs_bot debate"
in the summary). The Saved Transcripts viewer had the same label.
The summary also rendered `{eloChange && eloChange !== 0 && ...}`. When
eloChange is 0 this evaluates to 0, which React prints, so every summary
ended with "The result was a win.0".
Add a small formatDebateType helper ("User vs Bot", "User vs User") used
in both places, and only render the Elo sentence for a non-zero change.
Fixes AOSSIE-Org#820
Signed-off-by: Furqan <furqanfurqan6677@gmail.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Link your account with GitcordThanks for opening this PR, @Furqan-7! To receive Discord notifications and contributor tracking for this organization:
Once linked, Gitcord can notify you about reviews, merges, and more. — Posted by Gitcord |
Addressed Issues:
Fixes #820
Screenshots/Recordings:
Left: current main shows "User Vs_bot" and the summary ends with "The result was a win.0". Right: with this PR it shows "User vs Bot" and the summary ends at "win.". The profile response was mocked with the same format the profile API returns (
debateType: "user_vs_bot",eloChange: 0).Additional Notes:
Two small text bugs in the same dialog:
debateType.replace("_", " ")only replaces the first underscore, souser_vs_botbecame "user vs_bot". The Saved Transcripts viewer had the same label.{eloChange && eloChange !== 0 && (...)}returns0when the change is 0, and React prints that 0. The profile API currently sendseloChange: 0for every recent debate, so the "0" showed on every debate.Changes:
frontend/src/utils/debateType.ts(formatDebateType): "User vs Bot", "User vs User", and for any other type it replaces every underscore.frontend/src/Pages/Profile.tsx: uses the helper for the Type field and the summary, and only shows the Elo sentence when the change is non-zero. Removed thecapitalizeclass from the Type field so "vs" stays lowercase.frontend/src/components/SavedTranscripts.tsx: uses the same helper.Tests:
ProfileDebateDetails.test.tsx(new): opens the dialog and checks the type label, that there's no trailing "0" when the change is 0, and that the Elo sentence still shows for a non-zero change.SavedTranscripts.test.tsx: the dialog test now checks the "User vs Bot" label.debateType.test.ts(new): unit tests for the helper.Checks:
npm run test(37 files, 207 tests pass),tsc -bpasses, no new lint errors (each changed file has the same 1 pre-existing error before and after).Checklist
Summary by CodeRabbit