mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 14:40:52 +00:00
fix(sources): stop listing a source whose readings were all deleted
The in-use probe matched tombstoned readings, so a source stayed marked on the priority ladder after every reading from it was deleted. Both the read and the save response of the source-priority route go through this one probe.
This commit is contained in:
1 parent
27dfc6a617
commit
dcbd564962
3 files changed
+84
-2
No files matched your search
@@ -38,6 +38,21 @@ describe("getSourcesInUse", () => {
|
||||
expect(await getSourcesInUse("u1")).toEqual(["MANUAL"]);
|
||||
});
|
||||
|
||||
it("does not count a source whose readings were all deleted", async () => {
|
||||
// The probe answers like the database: a MANUAL row exists, but it is a
|
||||
// tombstone, so only a probe that admits deleted rows finds it.
|
||||
vi.mocked(prisma.measurement.findFirst).mockImplementation(((args: {
|
||||
where: { source: string; deletedAt?: null };
|
||||
}) =>
|
||||
Promise.resolve(
|
||||
args.where.source === "MANUAL" && !("deletedAt" in args.where)
|
||||
? { id: "m-deleted" }
|
||||
: null,
|
||||
)) as never);
|
||||
|
||||
expect(await getSourcesInUse("u1")).toEqual([]);
|
||||
});
|
||||
|
||||
it("lists a connected integration that has not delivered yet", async () => {
|
||||
vi.mocked(prisma.measurement.findFirst).mockResolvedValue(null);
|
||||
vi.mocked(prisma.withingsConnection.findUnique).mockResolvedValue({
|
||||
|
||||
Reference in new issue
Block a user