From 2cb6c6bcdbdc0e65f32336a0850523032b78e85d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 18 Sep 2026 09:51:14 +0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(insights):=20one?= =?UTF-8?q?=20label=20map,=20one=20pending=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two same-class residuals from the delta review: - The run status had two maps. The table's inline list used the app's dictionary (insights.status.*) while the report kept a private table — and they had ALREADY drifted: tr `running` read "Çalışıyor" in the dictionary and "Sürüyor" in the report. runReportStatusLabel now reads the dictionary, the table badge calls it, and there is one place a new status gets a label. An unknown status stays raw on both surfaces. - The pending-students expression was copied between the panel and the export. pendingStudentsLine(locale, model) builds the one line (count, names in the ledger's order, `—` where the roster cannot resolve a name) and both render it, so the export cannot drift from the screen. The em-dash case now has a test on the same line the panel shows. Gates: tsc clean; insight-run-report.test.tsx 11/11. Live: the ledger badge and the report's Durum both read "Tamamlandı", the student rows read "Kararlı". --- .../insights/insight-run-report.test.tsx | 13 ++++--- .../insights/insight-run-report.tsx | 8 ++-- .../insights/insight-runs-table.tsx | 8 +--- src/lib/insight-run-report.ts | 39 +++++++++++++------ 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/components/insights/insight-run-report.test.tsx b/src/components/insights/insight-run-report.test.tsx index f2d439b..2ef206a 100644 --- a/src/components/insights/insight-run-report.test.tsx +++ b/src/components/insights/insight-run-report.test.tsx @@ -52,7 +52,9 @@ const RUN_B: InsightRun = { students_failed: 1, students_skipped: 6, rows_written: 9, - pending_students: ["s2"], + // One pending student the roster can name, one it cannot: the second pins the + // `—` fallback (the id itself stays in the technical disclosure). + pending_students: ["s2", "ghost-id"], // Real stage vocabulary (discover_students / fetch / compute / store), plus one // unknown stage so the fallback is pinned too. failed_modules: ["fetch", "mystery_stage"], @@ -165,8 +167,8 @@ describe("InsightRunReport", () => { await openReport(DAY_B); expect(screen.getByText(`Çalıştırma günü ${DAY_B}`)).toBeTruthy(); - // RUN_B's own ledger row, not RUN_A's: its pending student is named in the report. - await waitFor(() => expect(panel().getByText(/1 öğrenci sıradaki çalıştırmaya kaldı: Ayça Şahin/)).toBeTruthy()); + // RUN_B's own ledger row, not RUN_A's: its pending students are named in the report. + await waitFor(() => expect(panel().getByText(/2 öğrenci sıradaki çalıştırmaya kaldı: Ayça Şahin, —/)).toBeTruthy()); }); it("renders the run's counters from the ledger row", async () => { @@ -292,7 +294,7 @@ describe("InsightRunReport", () => { it("names the pending students in the export exactly as the panel does", async () => { await openReport(DAY_B); - await waitFor(() => expect(panel().getByText(/1 öğrenci sıradaki çalıştırmaya kaldı/)).toBeTruthy()); + await waitFor(() => expect(panel().getByText(/2 öğrenci sıradaki çalıştırmaya kaldı/)).toBeTruthy()); const markdown = buildRunReportMarkdown( buildRunReportModel({ @@ -305,7 +307,8 @@ describe("InsightRunReport", () => { }), "tr", ); - expect(markdown).toContain("1 öğrenci sıradaki çalıştırmaya kaldı: Ayça Şahin"); + // Same line, same order, same em-dash as the panel (one helper builds both). + expect(markdown).toContain("2 öğrenci sıradaki çalıştırmaya kaldı: Ayça Şahin, —"); expect(markdown).toContain("Veri üretmeyen modüller: Veri toplama, mystery_stage"); expect(markdown).toContain("Keşifsel"); expect(markdown).not.toContain("exploratory"); diff --git a/src/components/insights/insight-run-report.tsx b/src/components/insights/insight-run-report.tsx index 8fe6de8..dd2e6be 100644 --- a/src/components/insights/insight-run-report.tsx +++ b/src/components/insights/insight-run-report.tsx @@ -17,6 +17,7 @@ import { failedStageText, formatRunDuration, moduleLabel, + pendingStudentsLine, runReportFileName, runReportStatusLabel, studentAttendanceText, @@ -125,11 +126,8 @@ function ReportDocument(props: { 0}>