* Show "Syncing Draft State..." overlay during draft reconnection When a user reconnects to a draft room (socket reconnect, tab visibility return, etc.), there was a gap between when the socket connected and when the full draft state sync arrived. The ConnectionOverlay vanished instantly on reconnect, showing potentially stale data. Add an isSyncing flag that keeps the overlay visible with "Syncing Draft State..." messaging until the actual data arrives via socket or HTTP revalidation. A 5-second safety timeout prevents the overlay from getting stuck. Fixes #78 * Add team names utility tests
85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import {
|
|
prependOwnerToTeamName,
|
|
stripOwnerFromTeamName,
|
|
} from "~/utils/team-names";
|
|
|
|
describe("prependOwnerToTeamName", () => {
|
|
it("prepends username with 's possessive", () => {
|
|
expect(prependOwnerToTeamName("Kind Cobras", "bob")).toBe(
|
|
"Bob's Kind Cobras"
|
|
);
|
|
});
|
|
|
|
it("uses ' possessive when username ends in s", () => {
|
|
expect(prependOwnerToTeamName("Kind Cobras", "chris")).toBe(
|
|
"Chris' Kind Cobras"
|
|
);
|
|
});
|
|
|
|
it("capitalizes first letter of username", () => {
|
|
expect(prependOwnerToTeamName("Furious Penguins", "christhrowsrock")).toBe(
|
|
"Christhrowsrock's Furious Penguins"
|
|
);
|
|
});
|
|
|
|
it("handles username already capitalized", () => {
|
|
expect(prependOwnerToTeamName("Bold Bears", "Alice")).toBe(
|
|
"Alice's Bold Bears"
|
|
);
|
|
});
|
|
|
|
it("handles name ending in multiple s characters", () => {
|
|
expect(prependOwnerToTeamName("Mighty Tigers", "jess")).toBe(
|
|
"Jess' Mighty Tigers"
|
|
);
|
|
});
|
|
|
|
it("handles display name fallback", () => {
|
|
expect(prependOwnerToTeamName("Wild Wolves", "Member")).toBe(
|
|
"Member's Wild Wolves"
|
|
);
|
|
});
|
|
|
|
it("handles single character username", () => {
|
|
expect(prependOwnerToTeamName("Team 1", "s")).toBe("S's Team 1");
|
|
});
|
|
|
|
it("handles empty base name", () => {
|
|
expect(prependOwnerToTeamName("", "bob")).toBe("Bob's ");
|
|
});
|
|
});
|
|
|
|
describe("stripOwnerFromTeamName", () => {
|
|
it("strips 's possessive prefix", () => {
|
|
expect(stripOwnerFromTeamName("Bob's Kind Cobras", "bob")).toBe(
|
|
"Kind Cobras"
|
|
);
|
|
});
|
|
|
|
it("strips ' possessive prefix for names ending in s", () => {
|
|
expect(stripOwnerFromTeamName("Chris' Kind Cobras", "chris")).toBe(
|
|
"Kind Cobras"
|
|
);
|
|
});
|
|
|
|
it("returns name unchanged if prefix does not match", () => {
|
|
expect(
|
|
stripOwnerFromTeamName("Alice's Awesome Team", "bob")
|
|
).toBe("Alice's Awesome Team");
|
|
});
|
|
|
|
it("handles title case mismatch in username", () => {
|
|
expect(stripOwnerFromTeamName("Bob's Team", "bob")).toBe("Team");
|
|
});
|
|
|
|
it("returns name unchanged if renamed by owner", () => {
|
|
expect(stripOwnerFromTeamName("Custom Name", "bob")).toBe("Custom Name");
|
|
});
|
|
|
|
it("handles username ending in s matching 's prefix", () => {
|
|
expect(stripOwnerFromTeamName("Jess' Wild Wolves", "jess")).toBe(
|
|
"Wild Wolves"
|
|
);
|
|
});
|
|
});
|