test(analytics) : align dashboard tests with visible rankings
This commit is contained in:
@@ -43,38 +43,38 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe("public analytics dashboard", () => {
|
||||
it("starts with Stygian enabled and updates all five rankings and totals on toggle", async () => {
|
||||
it("starts with Stygian enabled and updates all three team rankings and totals on toggle", async () => {
|
||||
await act(async () => root.render(<AnalyticsDashboard data={data} />));
|
||||
const toggle = container.querySelector<HTMLElement>('[role="switch"][aria-labelledby="include-stygian-label"]')!;
|
||||
expect(toggle.getAttribute("aria-checked")).toBe("true");
|
||||
expect(container.querySelector(`#${toggle.getAttribute("aria-labelledby")}`)?.textContent).toBe("รวมข้อมูล Stygian");
|
||||
expect(container.querySelectorAll("details[data-ranking]")).toHaveLength(5);
|
||||
expect(container.querySelectorAll("tbody tr")).toHaveLength(10);
|
||||
expect(container.querySelectorAll("details[data-ranking]")).toHaveLength(3);
|
||||
expect(container.querySelectorAll("tbody tr")).toHaveLength(6);
|
||||
expect(container.querySelector('[aria-label="ภาพรวมข้อมูล"]')?.textContent).toContain("ทีมทั้งหมด2");
|
||||
expect(Array.from(container.querySelectorAll("tbody tr:first-child td:last-child"), (cell) => cell.textContent)).toEqual(Array(5).fill("7"));
|
||||
expect(Array.from(container.querySelectorAll("tbody tr:first-child td:last-child"), (cell) => cell.textContent)).toEqual(Array(3).fill("7"));
|
||||
|
||||
const details = container.querySelector<HTMLDetailsElement>("details[data-ranking]")!;
|
||||
details.open = true;
|
||||
await act(async () => toggle.click());
|
||||
expect(toggle.getAttribute("aria-checked")).toBe("false");
|
||||
expect(details.open).toBe(true);
|
||||
expect(container.querySelectorAll("tbody tr")).toHaveLength(5);
|
||||
expect(container.querySelectorAll("tbody tr")).toHaveLength(3);
|
||||
expect(container.textContent).not.toContain("Stygian only");
|
||||
expect(container.querySelector('[aria-label="ภาพรวมข้อมูล"]')?.textContent).toContain("ทีมทั้งหมด1");
|
||||
expect(container.querySelector('[aria-label="ภาพรวมข้อมูล"]')?.textContent).toContain("เวอร์ชัน Stygian0");
|
||||
expect(Array.from(container.querySelectorAll("tbody tr:first-child td:last-child"), (cell) => cell.textContent)).toEqual(Array(5).fill("2"));
|
||||
expect(Array.from(container.querySelectorAll("tbody tr:first-child td:last-child"), (cell) => cell.textContent)).toEqual(Array(3).fill("2"));
|
||||
|
||||
await act(async () => root.render(<AnalyticsDashboard data={{ ...data, teamGroups: [...data.teamGroups, { guideId: "g1", signature: "new-team", count: 1 }] }} />));
|
||||
expect(toggle.getAttribute("aria-checked")).toBe("false");
|
||||
expect(container.querySelector('[aria-label="ภาพรวมข้อมูล"]')?.textContent).toContain("ทีมทั้งหมด2");
|
||||
});
|
||||
|
||||
it("shows empty states for sources without entries", async () => {
|
||||
it("shows empty states for team rankings without entries", async () => {
|
||||
await act(async () => root.render(<AnalyticsDashboard data={{
|
||||
...data, team: { character: [], weapon: [], artifact: [] }, recommendation: { weapon: [], artifact: [] },
|
||||
...data, team: { character: [], weapon: [], artifact: [] },
|
||||
}} />));
|
||||
expect(container.querySelectorAll("details[data-ranking]")).toHaveLength(0);
|
||||
expect(container.querySelectorAll('[data-slot="empty-title"]')).toHaveLength(5);
|
||||
expect(container.querySelectorAll('[data-slot="empty-title"]')).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("lets each guide be excluded and restored and supports repeated-team filtering", async () => {
|
||||
|
||||
Reference in New Issue
Block a user