feat(web): add match detail tabs
This commit is contained in:
1 parent
a88562b208
commit
96bae0ce28
5 files changed
+523
-29
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import {
|
||||
createMatchDetailTabSearchParams,
|
||||
createMatchDetailTabs,
|
||||
moveMatchDetailTabFocus,
|
||||
resolveMatchDetailTab,
|
||||
} from "../src/components/competition/match-detail-tabs.ts";
|
||||
|
||||
test("uses tabs only in progress or when finished and exposes operations only to managers", () => {
|
||||
assert.deepEqual(
|
||||
createMatchDetailTabs({ status: "recruiting", canManage: true }),
|
||||
[],
|
||||
);
|
||||
assert.deepEqual(
|
||||
createMatchDetailTabs({ status: "team-built", canManage: true }),
|
||||
[],
|
||||
);
|
||||
|
||||
const publicTabs = createMatchDetailTabs({
|
||||
status: "in-progress",
|
||||
canManage: false,
|
||||
});
|
||||
assert.deepEqual(
|
||||
publicTabs.map((tab) => tab.id),
|
||||
["bracket", "games", "teams", "info"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
publicTabs.map((tab) => tab.label),
|
||||
["대진표·순위", "경기 기록", "팀", "일정·안내"],
|
||||
);
|
||||
|
||||
const managerTabs = createMatchDetailTabs({
|
||||
status: "finished",
|
||||
canManage: true,
|
||||
});
|
||||
assert.deepEqual(
|
||||
managerTabs.map((tab) => tab.id),
|
||||
["bracket", "games", "teams", "info", "ops"],
|
||||
);
|
||||
});
|
||||
|
||||
test("falls back to the bracket for missing, invalid, or unauthorized tabs", () => {
|
||||
const publicTabs = createMatchDetailTabs({
|
||||
status: "in-progress",
|
||||
canManage: false,
|
||||
});
|
||||
|
||||
assert.equal(resolveMatchDetailTab(null, []), null);
|
||||
assert.equal(resolveMatchDetailTab(null, publicTabs), "bracket");
|
||||
assert.equal(resolveMatchDetailTab("unknown", publicTabs), "bracket");
|
||||
assert.equal(resolveMatchDetailTab("ops", publicTabs), "bracket");
|
||||
assert.equal(resolveMatchDetailTab("games", publicTabs), "games");
|
||||
});
|
||||
|
||||
test("updates the tab query without mutating or dropping unrelated parameters", () => {
|
||||
const current = new URLSearchParams("season=2026&tab=teams&from=history");
|
||||
const next = createMatchDetailTabSearchParams(current, "games");
|
||||
|
||||
assert.equal(next.get("tab"), "games");
|
||||
assert.equal(next.get("season"), "2026");
|
||||
assert.equal(next.get("from"), "history");
|
||||
assert.equal(current.get("tab"), "teams");
|
||||
});
|
||||
|
||||
test("moves tab focus with wrapping arrow keys and boundary keys", () => {
|
||||
const tabs = createMatchDetailTabs({
|
||||
status: "in-progress",
|
||||
canManage: false,
|
||||
});
|
||||
|
||||
assert.equal(moveMatchDetailTabFocus(tabs, "bracket", "ArrowRight"), "games");
|
||||
assert.equal(moveMatchDetailTabFocus(tabs, "bracket", "ArrowLeft"), "info");
|
||||
assert.equal(moveMatchDetailTabFocus(tabs, "info", "ArrowRight"), "bracket");
|
||||
assert.equal(moveMatchDetailTabFocus(tabs, "teams", "Home"), "bracket");
|
||||
assert.equal(moveMatchDetailTabFocus(tabs, "games", "End"), "info");
|
||||
});
|
||||
Reference in new issue
Block a user