mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
Poll on real conditions in the e2e suite and un-age the expiry fixtures
- account-sharing polls the offline persister's own IndexedDB store for the flushed snapshot instead of sleeping past the debounce. - The record-session-fence cases poll for the observable halves of their setups (the switch round-trip landing, the exit switch being issued); the one remaining fixed window is a documented absence-assertion grace with nothing to poll on. - The documents suite's two remaining sleeps are named for what they are: a focus-dance grace the outer document cannot observe, and the long-press gesture duration itself. - The inventory-date fixtures derive their printed expiry from now instead of a fixed 2027 date that would silently flip the fixture to expired when the calendar catches up.
This commit is contained in:
1 parent
97cb63a77f
commit
7611c82ae7
4 files changed
+86
-11
No files matched your search
@@ -18,6 +18,17 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
|
||||
// Now-anchored future expiry (the fixed 2027-06-01 was a fuse: once the
|
||||
// calendar passes it, an "expiring later" fixture silently becomes an
|
||||
// expired one and the assertions rot). ~300 days out keeps it a plainly
|
||||
// future date on every run; the expected strings derive from the same
|
||||
// instant so they can never drift from the fixture.
|
||||
const FUTURE_EXPIRY = new Date(Date.now() + 300 * 24 * 60 * 60 * 1000);
|
||||
const FUTURE_EXPIRY_YMD = FUTURE_EXPIRY.toISOString().slice(0, 10);
|
||||
const FUTURE_EXPIRY_ISO = `${FUTURE_EXPIRY_YMD}T00:00:00.000Z`;
|
||||
const [FE_Y, FE_M, FE_D] = FUTURE_EXPIRY_YMD.split("-");
|
||||
const FUTURE_EXPIRY_DE = `${FE_D}.${FE_M}.${FE_Y}`;
|
||||
|
||||
const src = readFileSync(
|
||||
resolve(
|
||||
process.cwd(),
|
||||
@@ -135,13 +146,13 @@ describe("<InventorySection> — item-row dates", () => {
|
||||
...BASE,
|
||||
state: "ACTIVE",
|
||||
firstUseAt: null,
|
||||
printedExpiry: "2027-06-01T00:00:00.000Z",
|
||||
printedExpiry: FUTURE_EXPIRY_ISO,
|
||||
},
|
||||
]);
|
||||
const html = render(
|
||||
<InventorySection medicationId="med-1" unitsPerDose={1} />,
|
||||
);
|
||||
expect(html).toContain("Haltbar bis 01.06.2027");
|
||||
expect(html).toContain(`Haltbar bis ${FUTURE_EXPIRY_DE}`);
|
||||
});
|
||||
|
||||
it("separates the two dates when the row carries both", () => {
|
||||
@@ -149,14 +160,14 @@ describe("<InventorySection> — item-row dates", () => {
|
||||
{
|
||||
...BASE,
|
||||
firstUseAt: "2026-06-12T00:00:00.000Z",
|
||||
printedExpiry: "2027-06-01T00:00:00.000Z",
|
||||
printedExpiry: FUTURE_EXPIRY_ISO,
|
||||
},
|
||||
]);
|
||||
const html = render(
|
||||
<InventorySection medicationId="med-1" unitsPerDose={1} />,
|
||||
);
|
||||
expect(html).toContain("Geöffnet 12.06.2026");
|
||||
expect(html).toContain("Haltbar bis 01.06.2027");
|
||||
expect(html).toContain(`Haltbar bis ${FUTURE_EXPIRY_DE}`);
|
||||
expect(html).toContain("<span>·</span>");
|
||||
});
|
||||
|
||||
@@ -174,7 +185,7 @@ describe("<AdjustInventoryDialog> — editable dates", () => {
|
||||
const item: Row = {
|
||||
...BASE,
|
||||
firstUseAt: "2026-06-12T00:00:00.000Z",
|
||||
printedExpiry: "2027-06-01T00:00:00.000Z",
|
||||
printedExpiry: FUTURE_EXPIRY_ISO,
|
||||
};
|
||||
|
||||
function renderDialog(over: Partial<Row> = {}): string {
|
||||
@@ -191,7 +202,7 @@ describe("<AdjustInventoryDialog> — editable dates", () => {
|
||||
const html = renderDialog();
|
||||
expect(html).toContain('id="inventory-edit-expiry"');
|
||||
expect(html).toContain("Aufgedrucktes Haltbarkeitsdatum");
|
||||
expect(html).toContain('value="2027-06-01"');
|
||||
expect(html).toContain(`value="${FUTURE_EXPIRY_YMD}"`);
|
||||
});
|
||||
|
||||
it("offers an opening-date field prefilled from the item", () => {
|
||||
@@ -205,7 +216,7 @@ describe("<AdjustInventoryDialog> — editable dates", () => {
|
||||
const html = renderDialog({ firstUseAt: null, printedExpiry: null });
|
||||
expect(html).toContain('id="inventory-edit-expiry"');
|
||||
expect(html).toContain('id="inventory-edit-opened"');
|
||||
expect(html).not.toContain("2027-06-01");
|
||||
expect(html).not.toContain(FUTURE_EXPIRY_YMD);
|
||||
expect(html).not.toContain("2026-06-12");
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user