mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
fix(dashboard): disambiguate quick-add submenu labels (no more double "Hinzufügen")
The dashboard "Add" dropdown rendered two menu items whose visible text
both resolved to bare nouns ("Messung" / "Stimmungseintrag" in DE,
"Measurement" / "Mood entry" in EN). Combined with the trigger label
("Hinzufügen" / "Add"), screen-reader users effectively heard the same
verb three times in a row with no signal which row did what.
Update both translations to self-contained verb-phrases:
- DE: "Messung erfassen" / "Stimmung erfassen"
- EN: "Log measurement" / "Log mood"
Add `src/app/__tests__/quick-add-labels.test.ts` to lock the contract:
both labels must be non-empty, distinct from each other, and distinct
from `common.add` (the trigger). The test loads `messages/{en,de}.json`
directly so any future translator who collapses the labels back to
"Hinzufügen" or "Add" gets a red bar before merge.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
786b3951f6
commit
3e45a7ba53
5 files changed
+174
-19
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
/**
|
||||
* v1.4.15 phase-A3 fix #1 — the dashboard "Hinzufügen" / "Add" dropdown used
|
||||
* to render two menu items whose visible labels both resolved to the bare
|
||||
* verb ("Hinzufügen" in DE, "Add" in EN). The dropdown trigger ALSO says
|
||||
* "Hinzufügen", so a screen-reader user heard "Hinzufügen, Hinzufügen,
|
||||
* Hinzufügen" with no way to tell the entries apart.
|
||||
*
|
||||
* The fix is to give each entry a self-contained noun-phrase label
|
||||
* ("Messung erfassen", "Stimmung erfassen") that doesn't collide with the
|
||||
* trigger or the other entry. This guard locks that contract in: if anyone
|
||||
* later edits one of the two values to match the other (or to match
|
||||
* `common.add`), the test fails before the regression ships.
|
||||
*
|
||||
* Lives under `src/app/__tests__` because the consumer is the dashboard
|
||||
* page (`src/app/page.tsx`); the keys themselves are namespaced under
|
||||
* `dashboard.*` in both messages files.
|
||||
*/
|
||||
|
||||
const ROOT = join(__dirname, "../../..");
|
||||
const EN_PATH = join(ROOT, "messages/en.json");
|
||||
const DE_PATH = join(ROOT, "messages/de.json");
|
||||
|
||||
interface Messages {
|
||||
common: { add: string };
|
||||
dashboard: {
|
||||
quickAddMeasurement: string;
|
||||
quickAddMood: string;
|
||||
};
|
||||
}
|
||||
|
||||
function load(path: string): Messages {
|
||||
return JSON.parse(readFileSync(path, "utf8")) as Messages;
|
||||
}
|
||||
|
||||
describe("dashboard quick-add submenu labels", () => {
|
||||
it.each([
|
||||
["en", EN_PATH],
|
||||
["de", DE_PATH],
|
||||
])(
|
||||
"%s: measurement and mood entries have distinct labels and neither equals the trigger label",
|
||||
(_locale, path) => {
|
||||
const messages = load(path);
|
||||
|
||||
const measurement = messages.dashboard.quickAddMeasurement;
|
||||
const mood = messages.dashboard.quickAddMood;
|
||||
const trigger = messages.common.add;
|
||||
|
||||
// Non-empty
|
||||
expect(measurement.trim().length).toBeGreaterThan(0);
|
||||
expect(mood.trim().length).toBeGreaterThan(0);
|
||||
|
||||
// Distinct from each other — the icon is decorative (aria-hidden),
|
||||
// so the only thing distinguishing the two rows is the visible text.
|
||||
expect(measurement).not.toBe(mood);
|
||||
|
||||
// Distinct from the trigger label. The trigger sits ABOVE the menu
|
||||
// and announces itself first; if a menu item then repeats the same
|
||||
// word, screen-readers / users get no signal which row does what.
|
||||
expect(measurement).not.toBe(trigger);
|
||||
expect(mood).not.toBe(trigger);
|
||||
},
|
||||
);
|
||||
});
|
||||
+7
-4
@@ -373,10 +373,13 @@ export default function DashboardPage() {
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{/* v1.5 phase-5: the menu items used to share the literal label
|
||||
"Add" with the dialog titles, so screen-reader users heard
|
||||
two indistinguishable "Add" rows in the same dropdown. The
|
||||
trigger already says "Add" — these label what's being added. */}
|
||||
{/* Menu items must each carry a self-contained verb-phrase
|
||||
("Log measurement", "Log mood") — the trigger above already
|
||||
says "Add", and the icon is `aria-hidden`, so the visible
|
||||
text is the only thing distinguishing the rows. v1.4.15
|
||||
phase-A3 fix #1 hardened this with a unit guard at
|
||||
`src/app/__tests__/quick-add-labels.test.ts` — both labels
|
||||
must differ from each other AND from `common.add`. */}
|
||||
<DropdownMenuItem
|
||||
onClick={() => setQuickEntryDialog("measurement")}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user