From c84c691fe91bfd14995bab0d664e3cb0814065bf Mon Sep 17 00:00:00 2001 From: gunshiz Date: Sun, 11 Oct 2026 19:32:11 +0700 Subject: [PATCH] test(analytics) : align dashboard tests with visible rankings --- app/analytics/page.tsx | 4 ++-- components/public/analytics-dashboard.test.tsx | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/analytics/page.tsx b/app/analytics/page.tsx index 889cef1..bc6f16a 100644 --- a/app/analytics/page.tsx +++ b/app/analytics/page.tsx @@ -10,7 +10,7 @@ import { getCachedPublicAnalytics } from "@/lib/cache/analytics"; export const metadata: Metadata = { title: "วิเคราะห์ข้อมูล", - description: "อันดับตัวละคร อาวุธ และอาร์ติแฟกต์ที่ใช้และแนะนำบ่อยที่สุดในไกด์สาธารณะ พร้อมเลือกข้อมูล Stygian", + description: "อันดับตัวละคร อาวุธ และอาร์ติแฟกต์ที่ใช้ในไกด์สาธารณะ พร้อมเลือกข้อมูล Stygian", }; async function AnalyticsContent() { @@ -36,7 +36,7 @@ export default function AnalyticsPage() {

วิเคราะห์ข้อมูล

-

ส่องภาพรวมตัวละคร อาวุธ และอาร์ติแฟกต์ที่ใช้และแนะนำบ่อยที่สุดในไกด์ทั้งหมด

+

ส่องภาพรวมตัวละคร อาวุธ และอาร์ติแฟกต์ที่ใช้ในทีมจากไกด์ทั้งหมด

}>
diff --git a/components/public/analytics-dashboard.test.tsx b/components/public/analytics-dashboard.test.tsx index 5f18352..7ba0c65 100644 --- a/components/public/analytics-dashboard.test.tsx +++ b/components/public/analytics-dashboard.test.tsx @@ -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()); const toggle = container.querySelector('[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("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()); 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()); 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 () => {