mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-23 15:45:15 +00:00
make it a dedicated stats modal, not under account (#4627)
## Description: seperates the stats modal into a dedicated path, with gameID support e.g. : #modal=stats&gameID=VvyXpL9x ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n
This commit is contained in:
@@ -154,6 +154,41 @@ describe("GameInfoView", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("renders a fetch error and recovers when Retry succeeds", async () => {
|
||||
const retry = deferred<AnalyticsRecord | false>();
|
||||
const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
|
||||
try {
|
||||
fetchMock
|
||||
.mockRejectedValueOnce(new Error("network failure"))
|
||||
.mockReturnValueOnce(retry.promise);
|
||||
view = mountView("retry-game");
|
||||
|
||||
await waitForRender(view, () => {
|
||||
expect(view!.textContent).toContain("game_info_modal.load_failed");
|
||||
expect(view!.querySelector("button")?.textContent).toContain(
|
||||
"game_info_modal.retry",
|
||||
);
|
||||
});
|
||||
|
||||
const retryButton = view.querySelector("button") as HTMLButtonElement;
|
||||
retryButton.click();
|
||||
|
||||
await vi.waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(2));
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(2, "retry-game");
|
||||
|
||||
retry.resolve(makeSession("retry-game", GameMapType.Montreal));
|
||||
await retry.promise;
|
||||
await waitForRender(view, () => {
|
||||
expect(view!.textContent).toContain(GameMapType.Montreal);
|
||||
expect(view!.textContent).not.toContain("game_info_modal.load_failed");
|
||||
expect(view!.querySelectorAll("player-row")).toHaveLength(1);
|
||||
});
|
||||
} finally {
|
||||
errorSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it("clears rendered game state when gameId becomes null", async () => {
|
||||
fetchMock.mockResolvedValue(makeSession("game-1", GameMapType.Montreal));
|
||||
view = mountView("game-1");
|
||||
|
||||
Reference in New Issue
Block a user