-
Notifications
You must be signed in to change notification settings - Fork 986
Add requeue button to Ranked victory/defeat modal #3121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
evanpelle
merged 5 commits into
openfrontio:main
from
Skigim:feature/ranked-requeue-button
Feb 7, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5169dfc
Add requeue button to Ranked victory/defeat modal
Skigim 53d3e23
Add tests for requeue navigation and URL parameter handling in WinModal
Skigim 67ec2c1
Merge branch 'feature/ranked-requeue-button' of https://github.com/Sk…
Skigim 97be4e6
Address PR review comments: improve requeue reliability
Skigim 60c34f1
Make MatchmakingButton.open() public for robust API
Skigim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; | ||
| import { RankedType } from "../../../../src/core/game/Game"; | ||
|
|
||
| vi.mock("../../../../src/client/Utils", () => ({ | ||
| translateText: vi.fn((key: string) => { | ||
| const translations: Record<string, string> = { | ||
| "win_modal.exit": "Exit", | ||
| "win_modal.requeue": "Play Again", | ||
| "win_modal.keep": "Keep Playing", | ||
| "win_modal.spectate": "Spectate", | ||
| }; | ||
| return translations[key] || key; | ||
| }), | ||
| getGamesPlayed: vi.fn(() => 10), | ||
| isInIframe: vi.fn(() => false), | ||
| TUTORIAL_VIDEO_URL: "https://example.com/tutorial", | ||
| })); | ||
|
|
||
| vi.mock("../../../../src/client/Api", () => ({ | ||
| getUserMe: vi.fn(async () => null), | ||
| })); | ||
|
|
||
| vi.mock("../../../../src/client/Cosmetics", () => ({ | ||
| fetchCosmetics: vi.fn(async () => []), | ||
| handlePurchase: vi.fn(), | ||
| patternRelationship: vi.fn(() => ({})), | ||
| })); | ||
|
|
||
| vi.mock("../../../../src/client/CrazyGamesSDK", () => ({ | ||
| crazyGamesSDK: { | ||
| happytime: vi.fn(), | ||
| requestAd: vi.fn(), | ||
| gameplayStop: vi.fn(), | ||
| }, | ||
| })); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| describe("WinModal Requeue", () => { | ||
| let mockLocationHref = ""; | ||
|
|
||
| beforeEach(() => { | ||
| mockLocationHref = ""; | ||
| // Mock window.location.href using Object.defineProperty | ||
| const locationMock = { | ||
| get href() { | ||
| return mockLocationHref; | ||
| }, | ||
| set href(value: string) { | ||
| mockLocationHref = value; | ||
| }, | ||
| }; | ||
| Object.defineProperty(window, "location", { | ||
| value: locationMock, | ||
| writable: true, | ||
| configurable: true, | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| describe("isRankedGame detection", () => { | ||
| it("should detect ranked 1v1 game", () => { | ||
| const gameConfig = { | ||
| rankedType: RankedType.OneVOne, | ||
| }; | ||
| const isRankedGame = gameConfig.rankedType === RankedType.OneVOne; | ||
| expect(isRankedGame).toBe(true); | ||
| }); | ||
|
|
||
| it("should not detect non-ranked game", () => { | ||
| const gameConfig = { | ||
| rankedType: undefined, | ||
| }; | ||
| const isRankedGame = gameConfig.rankedType === RankedType.OneVOne; | ||
| expect(isRankedGame).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("requeue navigation", () => { | ||
| it("should navigate to /?requeue when requeue is triggered", () => { | ||
| // Simulate the _handleRequeue behavior | ||
| const handleRequeue = () => { | ||
| window.location.href = "/?requeue"; | ||
| }; | ||
|
|
||
| handleRequeue(); | ||
|
|
||
| expect(window.location.href).toBe("/?requeue"); | ||
| }); | ||
|
|
||
| it("should navigate to / when exit is triggered", () => { | ||
| // Simulate the _handleExit behavior | ||
| const handleExit = () => { | ||
| window.location.href = "/"; | ||
| }; | ||
|
|
||
| handleExit(); | ||
|
|
||
| expect(window.location.href).toBe("/"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("requeue URL parameter handling", () => { | ||
| it("should parse requeue parameter from URL", () => { | ||
| const url = new URL("http://localhost:9000/?requeue"); | ||
| const hasRequeue = url.searchParams.has("requeue"); | ||
| expect(hasRequeue).toBe(true); | ||
| }); | ||
|
|
||
| it("should not find requeue parameter when absent", () => { | ||
| const url = new URL("http://localhost:9000/"); | ||
| const hasRequeue = url.searchParams.has("requeue"); | ||
| expect(hasRequeue).toBe(false); | ||
| }); | ||
| }); | ||
| }); | ||
|
Skigim marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.