-
Notifications
You must be signed in to change notification settings - Fork 1
test(reports): reconstruct #879 comparison post-coordinate contract #1034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: repair/leftover-map-compare-plot-criterion-coordinates-v2930
Are you sure you want to change the base?
Changes from all commits
d9972c2
de53e86
fee9f2b
5015f19
a169e68
49d02bf
de5a547
48705cc
1a75983
9cb44bb
7653023
9aecd55
89adb85
9ea8e9e
4078f76
708e435
603e255
0171755
b9dec94
9946cb4
b916ec6
d2e0eb6
f2982ab
c31ae62
bca5135
d09dd1c
f47c1cf
ee649c9
6bda129
b8b5075
c1ad80e
f5b4620
449a0aa
e2b6724
825f47a
d5b00f0
8b4df5e
4fb7122
8a26c4f
bb664b7
53950a8
17ffe7b
0c1a972
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import { render, screen } from "@testing-library/react"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| import type { LeftoverPair } from "../api"; | ||
| import { setLocale } from "../i18n"; | ||
| import { LeftoverMapPlot } from "./LeftoverMapPlot"; | ||
| import { LeftoverPairList } from "./LeftoverPairList"; | ||
|
|
||
| const PAIR: LeftoverPair = { | ||
| pair_kind: "closest", | ||
| post_id: "post-demo-public", | ||
| post_title: "Public post", | ||
| criterion_code: "sales_lead_quality", | ||
| leftover_distance: 0.12, | ||
| leftover_residual: 0.4, | ||
| leftover_map_person_axis_1: 0.5, | ||
| leftover_map_person_axis_2: 0.1, | ||
| leftover_map_item_axis_1: 0.5, | ||
| leftover_map_item_axis_2: -0.02, | ||
| }; | ||
|
|
||
| const PAIR_WITHOUT_PERSON_COORDINATES: LeftoverPair = { | ||
| ...PAIR, | ||
| leftover_map_person_axis_1: null, | ||
| }; | ||
|
|
||
| describe("LeftoverMapPlot comparison post accessibility", () => { | ||
| afterEach(() => setLocale("en")); | ||
|
|
||
| it("composes the comparison marker name from existing localized copy", () => { | ||
| setLocale("ko"); | ||
| render( | ||
| <LeftoverMapPlot | ||
| pairs={[PAIR]} | ||
| criterionLabel={() => "sales-lead"} | ||
| onSelectPost={vi.fn()} | ||
| variant="comparison" | ||
| />, | ||
| ); | ||
|
|
||
| expect( | ||
| screen.getByRole("button", { | ||
| name: "잔여 지도 비교 그림: 잔여 지도 글 Public post 열기 (ξ (+0.50, +0.10))", | ||
| }), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("does not invent a post marker when persisted person coordinates are unavailable", () => { | ||
| const { container } = render( | ||
| <LeftoverMapPlot | ||
| pairs={[PAIR_WITHOUT_PERSON_COORDINATES]} | ||
| criterionLabel={() => "sales-lead"} | ||
| onSelectPost={vi.fn()} | ||
| variant="comparison" | ||
| />, | ||
| ); | ||
|
|
||
| expect(container).toBeEmptyDOMElement(); | ||
| }); | ||
|
|
||
| it("keeps the pair-button open action when missing coordinates make the plot non-plottable", () => { | ||
| render( | ||
| <LeftoverPairList | ||
| pairs={[PAIR_WITHOUT_PERSON_COORDINATES]} | ||
| criterionLabel={() => "sales-lead"} | ||
| onSelectPost={vi.fn()} | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.queryByLabelText("Leftover-map graphic display")).not.toBeInTheDocument(); | ||
| expect( | ||
| screen.getByRole("button", { | ||
| name: "Open leftover closest pair: Public post · sales-lead", | ||
| }), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| """Executable contract for comparison-graphic post person-coordinate captions.""" | ||
|
|
||
| from pathlib import Path | ||
| import re | ||
|
|
||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
| LAYOUT_SOURCE = ROOT / "frontend" / "src" / "leftoverMapPlotLayout.ts" | ||
| PLOT_SOURCE = ROOT / "frontend" / "src" / "components" / "LeftoverMapPlot.tsx" | ||
|
|
||
|
|
||
| def test_comparison_graphic_post_names_persisted_person_coordinates() -> None: | ||
| """Comparison post markers use distinct ξ copy without changing report markers.""" | ||
| layout_source = LAYOUT_SOURCE.read_text(encoding="utf-8") | ||
| plot_source = PLOT_SOURCE.read_text(encoding="utf-8") | ||
|
|
||
| assert ( | ||
| 'LEFTOVER_MAP_COMPARE_PLOT_POST_ACTION =\n' | ||
| ' "Open leftover map comparison graphic leftover-map post {title} at ξ {person}";' | ||
| in layout_source | ||
| ) | ||
| assert "leftoverMapComparePlotPostBadge" in layout_source | ||
| assert "leftoverMapComparePlotPostBadge" in plot_source | ||
| assert "LEFTOVER_MAP_PLOT_POST_ACTION" in plot_source | ||
| assert re.search( | ||
| r'variant\s*===\s*"comparison".*?leftoverMapComparePlotPostBadge.*?LEFTOVER_MAP_PLOT_POST_ACTION', | ||
| plot_source, | ||
| re.DOTALL, | ||
| ) | ||
|
|
||
|
|
||
| def test_comparison_post_badge_consumes_person_axes_fail_closed_without_item_inference() -> None: | ||
| """Comparison ξ comes only from finite persisted person axes; zero remains explicit.""" | ||
| layout_source = LAYOUT_SOURCE.read_text(encoding="utf-8") | ||
| helper = re.search( | ||
| r"export function leftoverMapComparePlotPostBadge\(.*?\n}\n", | ||
| layout_source, | ||
| re.DOTALL, | ||
| ) | ||
| assert helper is not None | ||
| helper_source = helper.group(0) | ||
|
|
||
| assert "formatLeftoverMapCoordinatePair(axis1, axis2)" in helper_source | ||
| assert "person === null" in helper_source | ||
| assert "return null" in helper_source | ||
| assert "LEFTOVER_MAP_COMPARE_PLOT_POST_ACTION" in helper_source | ||
| assert "leftover_map_item_axis" not in helper_source | ||
| assert "Math.sqrt" not in helper_source | ||
|
Comment on lines
+10
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 실행 가능한 접근성 라벨 검사를 추가하세요. 현재 테스트는 소스 문자열만 검사합니다. 따라서 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. source-text-only coverage 지적은 유효했습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
exact-head Tests가 아직 queued 상태이므로 이 thread는 테스트가 GREEN이 될 때까지 열어 두는 것이 적절합니다. You are interacting with an AI system. |
||
| assert "Math.abs" not in helper_source | ||
Uh oh!
There was an error while loading. Please reload this page.