mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 14:40:52 +00:00
Merge wave B — the connect step reads liveness, not a latched field
A provider with no sync history reports "unknown" instead of "connected", so a fresh account is no longer told a device it never linked is already delivering; the connect step resolves the sync verdict into four honest tiles, records the flow's result only for a connection that is actually serving, points an unconfigured provider at its credentials, and steps over a source the account already has.
This commit is contained in:
commit
4d7b326fda
25 files changed
+1440
-73
No files matched your search
@@ -60,6 +60,7 @@ const whoopFind = prisma.whoopConnection.findUnique as ReturnType<typeof vi.fn>;
|
||||
|
||||
type Entry = {
|
||||
integration: string;
|
||||
state?: string;
|
||||
connected?: boolean;
|
||||
configured?: boolean;
|
||||
available?: boolean;
|
||||
@@ -344,3 +345,41 @@ describe("/api/integrations/status — the freshness read failed", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* v1.38.19 (wave B / I5) — the never-connected provider on the wire.
|
||||
*
|
||||
* The ledger's synthetic "no row" snapshot reads `unknown`, and the envelope
|
||||
* publishes it verbatim. A client that reads `state` must see a value that
|
||||
* cannot be mistaken for a live connection, while `syncHealth.verdict` keeps
|
||||
* saying `disconnected` for the same entry.
|
||||
*/
|
||||
describe("/api/integrations/status — a provider with no ledger row", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
for (const key of Object.keys(perIntegrationLedger)) {
|
||||
delete perIntegrationLedger[key];
|
||||
}
|
||||
polarAvailable.mockResolvedValue(true);
|
||||
ouraAvailable.mockResolvedValue(false);
|
||||
});
|
||||
|
||||
it("publishes state unknown beside connected false and a disconnected verdict", async () => {
|
||||
perIntegrationLedger.whoop = {
|
||||
state: "unknown",
|
||||
lastSuccessAt: null,
|
||||
lastAttemptAt: null,
|
||||
lastError: null,
|
||||
failingSince: null,
|
||||
};
|
||||
userFind.mockResolvedValue({});
|
||||
whoopFind.mockResolvedValue(null);
|
||||
|
||||
const whoop = (await fetchEntries()).find(
|
||||
(e) => e.integration === "whoop",
|
||||
)!;
|
||||
expect(whoop.state).toBe("unknown");
|
||||
expect(whoop.connected).toBe(false);
|
||||
expect(whoop.syncHealth?.verdict).toBe("disconnected");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user