mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
fix(ui): link the adherence tile straight to the medication wizard and drop dead rail rules
The empty adherence tile linked to the retired /medications/new route, which only redirects. The sidebar's short-touch rules keyed on a touch screen at most 520 px tall, where the phone shell hides the rail, so they could never apply.
This commit is contained in:
1 parent
c1144b3c4c
commit
04084dd6e2
4 files changed
+61
-16
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Links point at a route that renders, not at a retired one that only
|
||||
* redirects: every hop through a redirect is a round trip on a phone, and
|
||||
* the redirect stubs exist for old bookmarks, not for the app's own links.
|
||||
*/
|
||||
import { readdirSync, readFileSync, statSync } from "node:fs";
|
||||
import { join, relative } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const ROOT = join(__dirname, "..", "..");
|
||||
|
||||
/** Retired route → where it redirects. */
|
||||
const RETIRED: Record<string, string> = {
|
||||
"/medications/new": "/medications?new=1",
|
||||
};
|
||||
|
||||
function walk(dir: string): string[] {
|
||||
return readdirSync(dir).flatMap((name) => {
|
||||
if (name === "__tests__" || name === "generated") return [];
|
||||
const abs = join(dir, name);
|
||||
if (statSync(abs).isDirectory()) return walk(abs);
|
||||
return /\.tsx?$/.test(name) ? [abs] : [];
|
||||
});
|
||||
}
|
||||
|
||||
describe("no link targets a retired route", () => {
|
||||
const files = walk(join(ROOT, "src"));
|
||||
|
||||
it("scans the source tree", () => {
|
||||
expect(files.length).toBeGreaterThan(100);
|
||||
});
|
||||
|
||||
it.each(Object.entries(RETIRED))("%s is linked as %s", (route) => {
|
||||
const pattern = new RegExp(
|
||||
`(?:href|push|replace)[=(]\\s*\\{?\\s*["'\`]${route.replace(/\//g, "\\/")}["'\`?#]`,
|
||||
);
|
||||
const offenders = files
|
||||
.filter((file) => pattern.test(readFileSync(file, "utf8")))
|
||||
.map((file) => relative(ROOT, file));
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user