mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
feat: scope Telegram reminder tracking to recipients
- keep delegated recipient slots independent\n- bind callback cleanup to the recipient account
This commit is contained in:
1 parent
5807879439
commit
fa46f27b01
6 files changed
+99
-51
No files matched your search
@@ -291,6 +291,14 @@ describe("Telegram webhook — callback dispatch", () => {
|
||||
const res = await POST(tgRequest(callbackUpdate("taken:med-1")));
|
||||
expect(res.status).toBe(200);
|
||||
|
||||
expect(prisma.telegramReminderMessage.deleteMany).toHaveBeenCalledWith({
|
||||
where: {
|
||||
recipientUserId: "user-1",
|
||||
medicationId: "med-1",
|
||||
medication: { userId: "user-1" },
|
||||
},
|
||||
});
|
||||
|
||||
// No schedules wired → the take is ad-hoc and inserts standalone.
|
||||
expect(prisma.medicationIntakeEvent.create).toHaveBeenCalledTimes(1);
|
||||
const intakeArgs = vi.mocked(prisma.medicationIntakeEvent.create).mock
|
||||
@@ -779,6 +787,16 @@ describe("Telegram webhook — slot convergence (v1.16.9)", () => {
|
||||
const res = await POST(tgRequest(callbackUpdate("taken:med-1")));
|
||||
expect(res.status).toBe(200);
|
||||
|
||||
expect(prisma.telegramReminderMessage.findFirst).toHaveBeenCalledWith({
|
||||
where: {
|
||||
recipientUserId: "user-1",
|
||||
medicationId: "med-1",
|
||||
chatId: "7777",
|
||||
messageId: 555,
|
||||
},
|
||||
select: { date: true, timeOfDay: true },
|
||||
});
|
||||
|
||||
// The pending row was updated in place — never a duplicate insert.
|
||||
expect(prisma.medicationIntakeEvent.create).not.toHaveBeenCalled();
|
||||
expect(prisma.medicationIntakeEvent.update).toHaveBeenCalledTimes(1);
|
||||
|
||||
Reference in new issue
Block a user