mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-23 14:36:34 +00:00
profilelink (#4661)
## Description: <img width="930" height="755" alt="image" src="https://github.com/user-attachments/assets/f606bdce-fbeb-4fc3-98fb-ba6622634350" /> <img width="875" height="368" alt="image" src="https://github.com/user-attachments/assets/81c8243d-5dc0-4687-bed4-cadb6bafb808" /> ## 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:
@@ -159,18 +159,20 @@ describe("public player profile route", () => {
|
||||
expect(fetchPublicPlayerProfileMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("returns to the clan members tab when opened from a clan", async () => {
|
||||
it("hands back to the clan modal when opened from a clan", async () => {
|
||||
fetchPublicPlayerProfileMock.mockResolvedValue({
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
stats: statsTree,
|
||||
});
|
||||
const returnToMembers = vi.fn();
|
||||
// The clan modal decides which tab to restore (Members vs Game History)
|
||||
// via returnFromPlayerProfile — the profile modal just hands back to it.
|
||||
const returnFromPlayerProfile = vi.fn();
|
||||
const fakeClanModal = document.createElement(
|
||||
"clan-modal",
|
||||
) as HTMLElement & {
|
||||
returnToMembers: () => void;
|
||||
returnFromPlayerProfile: () => void;
|
||||
};
|
||||
fakeClanModal.returnToMembers = returnToMembers;
|
||||
fakeClanModal.returnFromPlayerProfile = returnFromPlayerProfile;
|
||||
document.body.appendChild(fakeClanModal);
|
||||
|
||||
modal.openFromClan("clan-member");
|
||||
@@ -183,7 +185,7 @@ describe("public player profile route", () => {
|
||||
backButton.click();
|
||||
|
||||
expect(modal.isOpen()).toBe(false);
|
||||
expect(returnToMembers).toHaveBeenCalled();
|
||||
expect(returnFromPlayerProfile).toHaveBeenCalled();
|
||||
fakeClanModal.remove();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -312,6 +312,26 @@ describe("ClanGamePlayerSchema", () => {
|
||||
expect(ClanGamePlayerSchema.safeParse(validPlayer).success).toBe(true);
|
||||
});
|
||||
|
||||
it("accepts the verified flag or its absence (older API)", () => {
|
||||
const verified = ClanGamePlayerSchema.safeParse({
|
||||
...validPlayer,
|
||||
verified: true,
|
||||
});
|
||||
expect(verified.success).toBe(true);
|
||||
if (verified.success) expect(verified.data.verified).toBe(true);
|
||||
// validPlayer omits verified entirely — still valid (→ undefined).
|
||||
const bare = ClanGamePlayerSchema.safeParse(validPlayer);
|
||||
expect(bare.success).toBe(true);
|
||||
if (bare.success) expect(bare.data.verified).toBeUndefined();
|
||||
});
|
||||
|
||||
it("rejects a non-boolean verified", () => {
|
||||
expect(
|
||||
ClanGamePlayerSchema.safeParse({ ...validPlayer, verified: "yes" })
|
||||
.success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects when won is not a boolean", () => {
|
||||
expect(
|
||||
ClanGamePlayerSchema.safeParse({ ...validPlayer, won: "true" }).success,
|
||||
|
||||
Reference in New Issue
Block a user