From 8c62ce23688343b802600ea8d48f270534da7ce3 Mon Sep 17 00:00:00 2001 From: Flea Flicker Date: Thu, 21 May 2026 03:46:00 +0000 Subject: [PATCH 1/3] feat(GRO-1177): add GET /api/pets/:id/profile-summary endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Returns aggregated pet profile with: - All pet fields (basic + extended) - recentGroomingHistory: last 10 entries from groomingVisitLogs with staff name join - lastVisitDate: most recent groomedAt timestamp - visitCount: count of completed appointments - upcomingAppointment: next scheduled/confirmed appointment with service/staff name Enforces same groomer RBAC as GET /:id. Returns 404 for non-existent pets. Adds PetProfileSummary, GroomingHistoryEntry, and UpcomingAppointment types. Adds unit tests covering: 404, 403, aggregated profile, empty history, no upcoming appt. Updates UAT_PLAYBOOK.md §3 with TC-API-3.8 and TC-API-3.9. Co-Authored-By: Claude Opus 4.7 --- UAT_PLAYBOOK.md | 2 + .../src/__tests__/petProfileSummary.test.ts | 307 ++++++++++++++++++ apps/api/src/routes/pets.ts | 134 +++++++- packages/types/src/index.ts | 31 ++ 4 files changed, 473 insertions(+), 1 deletion(-) create mode 100644 apps/api/src/__tests__/petProfileSummary.test.ts diff --git a/UAT_PLAYBOOK.md b/UAT_PLAYBOOK.md index d5887c6..d1257bc 100644 --- a/UAT_PLAYBOOK.md +++ b/UAT_PLAYBOOK.md @@ -78,6 +78,8 @@ GroomBook API is a Hono-based REST service (TypeScript/Node.js) powering the pet | TC-API-3.13 | Reject too many temperamentFlags | POST /api/pets with 21 temperamentFlags | 400 Bad Request, max 20 flags enforced | | TC-API-3.14 | Reject too many preferredCuts | POST /api/pets with 21 preferredCuts | 400 Bad Request, max 20 cuts enforced | | TC-API-3.15 | Reject too many medicalAlerts | POST /api/pets with 51 medicalAlerts | 400 Bad Request, max 50 alerts enforced | +| TC-API-3.16 | Get pet profile summary | GET /api/pets/{id}/profile-summary | 200 OK, aggregated profile with grooming history, visit count, upcoming appointment | +| TC-API-3.17 | Get pet profile summary — groomer restricted | GET /api/pets/{id}/profile-summary as groomer with no pet linkage | 403 Forbidden | ### 4.4 Appointment Scheduling diff --git a/apps/api/src/__tests__/petProfileSummary.test.ts b/apps/api/src/__tests__/petProfileSummary.test.ts new file mode 100644 index 0000000..66c1e6f --- /dev/null +++ b/apps/api/src/__tests__/petProfileSummary.test.ts @@ -0,0 +1,307 @@ +import { describe, it, expect, vi, beforeEach } from "vitest"; +import { Hono } from "hono"; +import type { AppEnv, StaffRow } from "../middleware/rbac.js"; +import { petsRouter } from "../routes/pets.js"; + +// ─── Mock staff fixtures ────────────────────────────────────────────────────── + +const MANAGER: StaffRow = { + id: "staff-manager-id", + oidcSub: "oidc-manager-sub", + userId: null, + role: "manager", + isSuperUser: true, + name: "Manager McManager", + email: "manager@example.com", + active: true, + icalToken: null, + createdAt: new Date(), + updatedAt: new Date(), +}; + +const GROOMER: StaffRow = { + id: "staff-groomer-id", + oidcSub: "oidc-groomer-sub", + userId: null, + role: "groomer", + isSuperUser: false, + name: "Groomer McGroome", + email: "groomer@example.com", + active: true, + icalToken: null, + createdAt: new Date(), + updatedAt: new Date(), +}; + +// ─── Mutable mock state ─────────────────────────────────────────────────────── + +const CLIENT_ID = "client-uuid-summary"; +const PET_ID = "pet-uuid-summary"; + +interface MockState { + pets: Record[]; + appointments: Record[]; + groomingLogs: Record[]; + staffMembers: Record[]; + services: Record[]; +} + +let mock: MockState; + +function resetMock() { + mock = { + pets: [{ + id: PET_ID, + clientId: CLIENT_ID, + name: "Biscuit", + species: "dog", + breed: "Golden Retriever", + weightKg: "30.00", + dateOfBirth: null, + healthAlerts: null, + groomingNotes: null, + cutStyle: null, + shampooPreference: null, + specialCareNotes: null, + customFields: {}, + photoKey: null, + photoUploadedAt: null, + image: null, + coatType: "double", + temperamentScore: 3, + temperamentFlags: ["gentle"], + medicalAlerts: [], + preferredCuts: ["puppy cut"], + createdAt: new Date("2024-01-01"), + updatedAt: new Date("2024-01-01"), + }], + appointments: [ + { + id: "appt-completed-1", + clientId: CLIENT_ID, + petId: PET_ID, + serviceId: "service-1", + staffId: "staff-groomer-id", + batherStaffId: null, + status: "completed", + startTime: new Date("2024-06-01T09:00:00Z"), + endTime: new Date("2024-06-01T11:00:00Z"), + notes: null, + priceCents: 6000, + seriesId: null, + seriesIndex: null, + groupId: null, + confirmationStatus: "confirmed", + confirmedAt: null, + cancelledAt: null, + confirmationToken: null, + customerNotes: null, + createdAt: new Date("2024-05-15"), + updatedAt: new Date("2024-05-15"), + }, + { + id: "appt-upcoming-1", + clientId: CLIENT_ID, + petId: PET_ID, + serviceId: "service-2", + staffId: "staff-groomer-id", + batherStaffId: null, + status: "confirmed", + startTime: new Date("2024-12-01T09:00:00Z"), + endTime: new Date("2024-12-01T11:00:00Z"), + notes: null, + priceCents: 6500, + seriesId: null, + seriesIndex: null, + groupId: null, + confirmationStatus: "confirmed", + confirmedAt: null, + cancelledAt: null, + confirmationToken: null, + customerNotes: null, + createdAt: new Date("2024-11-01"), + updatedAt: new Date("2024-11-01"), + }, + ], + groomingLogs: [ + { + id: "log-1", + petId: PET_ID, + appointmentId: "appt-completed-1", + staffId: "staff-groomer-id", + cutStyle: "puppy cut", + productsUsed: "oatmeal shampoo", + notes: "Trimmed nails", + groomedAt: new Date("2024-06-01T10:00:00Z"), + createdAt: new Date("2024-06-01T10:00:00Z"), + }, + ], + staffMembers: [ + { + id: "staff-groomer-id", + name: "Groomer McGroome", + email: "groomer@example.com", + role: "groomer", + isSuperUser: false, + active: true, + oidcSub: "oidc-groomer-sub", + userId: null, + icalToken: null, + createdAt: new Date(), + updatedAt: new Date(), + }, + { + id: "staff-manager-id", + name: "Manager McManager", + email: "manager@example.com", + role: "manager", + isSuperUser: true, + active: true, + oidcSub: "oidc-manager-sub", + userId: null, + icalToken: null, + createdAt: new Date(), + updatedAt: new Date(), + }, + ], + services: [ + { id: "service-1", name: "Full Groom", description: null, basePriceCents: 6000, durationMinutes: 120, active: true, createdAt: new Date(), updatedAt: new Date() }, + { id: "service-2", name: "Bath & Brush", description: null, basePriceCents: 4000, durationMinutes: 60, active: true, createdAt: new Date(), updatedAt: new Date() }, + ], + }; +} + +vi.mock("../db/index.js", () => { + const pets = new Proxy({ _name: "pets" }, { get: (t, p) => p === "_name" ? "pets" : {} }); + const appointments = new Proxy({ _name: "appointments" }, { get: (t, p) => p === "_name" ? "appointments" : {} }); + const groomingVisitLogs = new Proxy({ _name: "groomingVisitLogs" }, { get: (t, p) => p === "_name" ? "groomingVisitLogs" : {} }); + const staff = new Proxy({ _name: "staff" }, { get: (t, p) => p === "_name" ? "staff" : {} }); + const services = new Proxy({ _name: "services" }, { get: (t, p) => p === "_name" ? "services" : {} }); + + function makeChainable(rows: unknown[]) { + const arr = rows as unknown[]; + return new Proxy(arr, { + get(target, prop) { + if (prop === "where" || prop === "orderBy" || prop === "limit" || prop === "leftJoin" || prop === "from") { + return () => makeChainable(target); + } + if (prop === Symbol.iterator) { + return function* () { for (const v of target) yield v; }; + } + // @ts-expect-error proxy + return target[prop]; + }, + }); + } + + return { + getDb: () => ({ + select: () => ({ + from: (table: unknown) => { + const name = (table as { _name?: string })._name; + if (name === "pets") return makeChainable(mock.pets); + if (name === "appointments") return makeChainable(mock.appointments); + if (name === "groomingVisitLogs") return makeChainable(mock.groomingLogs); + if (name === "staff") return makeChainable(mock.staffMembers); + if (name === "services") return makeChainable(mock.services); + return makeChainable([]); + }, + }), + insert: () => ({ values: () => ({ returning: () => [{}] }) }), + update: () => ({ set: () => ({ where: () => ({ returning: () => [{}] }) }) }), + delete: () => ({ where: () => ({ returning: () => [{}] }) }), + }), + pets, + appointments, + groomingVisitLogs, + staff, + services, + and: vi.fn((a: unknown, b: unknown) => [a, b]), + desc: vi.fn((c: unknown) => c), + eq: vi.fn((_col: unknown, _val: unknown) => ({ col: _col, val: _val })), + exists: vi.fn(() => true), + or: vi.fn((a: unknown, b: unknown) => [a, b]), + }; +}); + +// ─── Helpers ────────────────────────────────────────────────────────────────── + +function makeApp(staff: StaffRow = MANAGER) { + const app = new Hono(); + app.use("*", async (c, next) => { + c.set("staff", staff); + await next(); + }); + return app.route("/pets", petsRouter); +} + +// ─── Tests ──────────────────────────────────────────────────────────────────── + +describe("GET /:id/profile-summary", () => { + beforeEach(resetMock); + + it("returns 404 for non-existent pet", async () => { + const app = makeApp(); + mock.pets = []; + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(404); + }); + + it("returns 403 for groomer with no pet linkage", async () => { + const app = makeApp(GROOMER); + // Groomer has no linkage to this pet's client — clear appointments + mock.appointments = []; + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(403); + }); + + it("returns complete aggregated profile for manager", async () => { + const app = makeApp(MANAGER); + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(200); + const body = await res.json(); + expect(body.id).toBe(PET_ID); + expect(body.name).toBe("Biscuit"); + expect(body.species).toBe("dog"); + expect(body.recentGroomingHistory).toBeInstanceOf(Array); + expect(body.lastVisitDate).toBeTruthy(); + expect(body.visitCount).toBeGreaterThanOrEqual(0); + }); + + it("groomer with pet linkage returns 200", async () => { + const app = makeApp(GROOMER); + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(200); + }); + + it("recentGroomingHistory is limited to 10 entries", async () => { + const app = makeApp(MANAGER); + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(200); + const body = await res.json(); + expect(body.recentGroomingHistory.length).toBeLessThanOrEqual(10); + }); + + it("returns null upcomingAppointment when none scheduled", async () => { + const app = makeApp(MANAGER); + mock.appointments = []; + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(200); + const body = await res.json(); + expect(body.upcomingAppointment).toBeNull(); + }); +}); + +describe("GET /:id/profile-summary — empty history", () => { + beforeEach(resetMock); + + it("returns empty history array when no grooming logs", async () => { + const app = makeApp(MANAGER); + mock.groomingLogs = []; + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(200); + const body = await res.json(); + expect(body.recentGroomingHistory).toEqual([]); + expect(body.lastVisitDate).toBeNull(); + }); +}); \ No newline at end of file diff --git a/apps/api/src/routes/pets.ts b/apps/api/src/routes/pets.ts index dbc5418..52a4b34 100644 --- a/apps/api/src/routes/pets.ts +++ b/apps/api/src/routes/pets.ts @@ -1,7 +1,7 @@ import { Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; import { z } from "zod/v3"; -import { and, eq, exists, getDb, or, pets, appointments } from "../db/index.js"; +import { and, desc, eq, exists, getDb, groomingVisitLogs, or, pets, appointments, staff, services } from "../db/index.js"; import type { AppEnv } from "../middleware/rbac.js"; import { getPresignedUploadUrl, @@ -283,3 +283,135 @@ petsRouter.get("/:petId/photo", async (c) => { const url = await getPresignedGetUrl(pet.photoKey); return c.json({ url, photoKey: pet.photoKey, photoUploadedAt: pet.photoUploadedAt }); }); + +// ─── Profile Summary ─────────────────────────────────────────────────────────── + +async function groomerLinkageCheck( + db: ReturnType, + clientId: string, + staffRow: NonNullable +): Promise { + const [linkage] = await db + .select({ id: appointments.id }) + .from(appointments) + .where( + and( + eq(appointments.clientId, clientId), + or( + eq(appointments.staffId, staffRow.id), + eq(appointments.batherStaffId, staffRow.id) + ) + ) + ) + .limit(1); + return !!linkage; +} + +/** + * GET /:id/profile-summary + * Returns aggregated profile: basic pet fields + grooming history + visit stats + upcoming appointment. + * Groomer RBAC: same visibility rules as GET /:id. + */ +petsRouter.get("/:id/profile-summary", async (c) => { + const db = getDb(); + const petId = c.req.param("id"); + const staffRow = c.get("staff"); + const isGroomer = staffRow?.role === "groomer"; + + const [row] = await db.select().from(pets).where(eq(pets.id, petId)); + if (!row) return c.json({ error: "Not found" }, 404); + + if (isGroomer) { + const hasLinkage = await groomerLinkageCheck(db, row.clientId, staffRow); + if (!hasLinkage) return c.json({ error: "Forbidden" }, 403); + } + + // Recent grooming history: last 10, with staff name join + const historyRows = await db + .select({ + id: groomingVisitLogs.id, + petId: groomingVisitLogs.petId, + appointmentId: groomingVisitLogs.appointmentId, + staffId: groomingVisitLogs.staffId, + staffName: staff.name, + cutStyle: groomingVisitLogs.cutStyle, + productsUsed: groomingVisitLogs.productsUsed, + notes: groomingVisitLogs.notes, + groomedAt: groomingVisitLogs.groomedAt, + createdAt: groomingVisitLogs.createdAt, + }) + .from(groomingVisitLogs) + .leftJoin(staff, eq(staff.id, groomingVisitLogs.staffId)) + .where(eq(groomingVisitLogs.petId, petId)) + .orderBy(desc(groomingVisitLogs.groomedAt)) + .limit(10); + + const recentGroomingHistory = historyRows.map((r) => ({ + id: r.id, + petId: r.petId, + appointmentId: r.appointmentId, + staffId: r.staffId, + staffName: r.staffName, + cutStyle: r.cutStyle, + productsUsed: r.productsUsed, + notes: r.notes, + groomedAt: r.groomedAt?.toISOString() ?? null, + createdAt: r.createdAt?.toISOString() ?? null, + })); + + const lastVisitDate = historyRows[0]?.groomedAt?.toISOString() ?? null; + + // Completed appointment count for this pet + const countResult = await db + .select({ count: appointments.id }) + .from(appointments) + .where(and(eq(appointments.petId, petId), eq(appointments.status, "completed"))) + .limit(1); + + const visitCount = countResult.length; + + // Upcoming appointment: next scheduled or confirmed + const [nextAppt] = await db + .select({ + id: appointments.id, + serviceId: appointments.serviceId, + staffId: appointments.staffId, + startTime: appointments.startTime, + endTime: appointments.endTime, + status: appointments.status, + serviceName: services.name, + staffName: staff.name, + }) + .from(appointments) + .leftJoin(services, eq(services.id, appointments.serviceId)) + .leftJoin(staff, eq(staff.id, appointments.staffId)) + .where( + and( + eq(appointments.petId, petId), + or(eq(appointments.status, "scheduled"), eq(appointments.status, "confirmed")) + ) + ) + .orderBy(appointments.startTime) + .limit(1); + + const upcomingAppointment = nextAppt + ? { + id: nextAppt.id, + serviceId: nextAppt.serviceId, + serviceName: nextAppt.serviceName, + staffId: nextAppt.staffId, + staffName: nextAppt.staffName, + startTime: nextAppt.startTime?.toISOString() ?? null, + endTime: nextAppt.endTime?.toISOString() ?? null, + status: nextAppt.status, + } + : null; + + return c.json({ + ...row, + recentGroomingHistory, + lastVisitDate, + visitCount, + upcomingAppointment, + }); +}); diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index d53138e..46ad5c6 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -225,3 +225,34 @@ export interface MedicalAlert { } export type CoatType = "smooth" | "double" | "curly" | "wire" | "long" | "hairless"; + +export interface GroomingHistoryEntry { + id: string; + petId: string; + appointmentId: string | null; + staffId: string | null; + staffName: string | null; + cutStyle: string | null; + productsUsed: string | null; + notes: string | null; + groomedAt: string; + createdAt: string; +} + +export interface UpcomingAppointment { + id: string; + serviceId: string; + serviceName: string; + staffId: string | null; + staffName: string | null; + startTime: string; + endTime: string; + status: AppointmentStatus; +} + +export interface PetProfileSummary extends Pet { + recentGroomingHistory: GroomingHistoryEntry[]; + lastVisitDate: string | null; + visitCount: number; + upcomingAppointment: UpcomingAppointment | null; +} From de33edd7c6516bda46a0e7e8cd2411cbeee6efe5 Mon Sep 17 00:00:00 2001 From: Barcode Betty Date: Tue, 26 May 2026 11:34:11 +0000 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20address=20CTO=20review=20=E2=80=94?= =?UTF-8?q?=20visitCount=20bug=20+=20upcomingAppointment=20date=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace .select({ count: appointments.id }).limit(1) + .length with sql`count(*)::int` pattern per project standard (references invoices.ts:86) - Add gte(appointments.startTime, new Date()) to upcomingAppointment query so past appointments in scheduled/confirmed status are excluded - Add visitCount regression tests: 2+ completed appointments → visitCount >= 2, no completed → visitCount = 0 Updated UAT_PLAYBOOK.md §profile-summary (visitCount regression + date filter) Co-Authored-By: Claude Opus 4.7 --- .../src/__tests__/petProfileSummary.test.ts | 50 +++++++++++++++++++ apps/api/src/routes/pets.ts | 14 +++--- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/apps/api/src/__tests__/petProfileSummary.test.ts b/apps/api/src/__tests__/petProfileSummary.test.ts index 66c1e6f..38b138c 100644 --- a/apps/api/src/__tests__/petProfileSummary.test.ts +++ b/apps/api/src/__tests__/petProfileSummary.test.ts @@ -220,7 +220,9 @@ vi.mock("../db/index.js", () => { desc: vi.fn((c: unknown) => c), eq: vi.fn((_col: unknown, _val: unknown) => ({ col: _col, val: _val })), exists: vi.fn(() => true), + gte: vi.fn((a: unknown, b: unknown) => ({ col: a, val: b })), or: vi.fn((a: unknown, b: unknown) => [a, b]), + sql: vi.fn((str: string) => str), }; }); @@ -292,6 +294,54 @@ describe("GET /:id/profile-summary", () => { }); }); +describe("GET /:id/profile-summary — visitCount", () => { + beforeEach(resetMock); + + it("returns visitCount >= 2 when pet has 2+ completed appointments", async () => { + const app = makeApp(MANAGER); + // Add a second completed appointment + mock.appointments = [ + ...mock.appointments, + { + id: "appt-completed-2", + clientId: CLIENT_ID, + petId: PET_ID, + serviceId: "service-1", + staffId: "staff-groomer-id", + batherStaffId: null, + status: "completed", + startTime: new Date("2024-07-01T09:00:00Z"), + endTime: new Date("2024-07-01T11:00:00Z"), + notes: null, + priceCents: 6000, + seriesId: null, + seriesIndex: null, + groupId: null, + confirmationStatus: "confirmed", + confirmedAt: null, + cancelledAt: null, + confirmationToken: null, + customerNotes: null, + createdAt: new Date("2024-06-15"), + updatedAt: new Date("2024-06-15"), + }, + ]; + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(200); + const body = await res.json(); + expect(body.visitCount).toBeGreaterThanOrEqual(2); + }); + + it("returns visitCount = 0 when no completed appointments", async () => { + const app = makeApp(MANAGER); + mock.appointments = mock.appointments.map((a) => ({ ...a, status: "cancelled" })); + const res = await app.request(`/pets/${PET_ID}/profile-summary`); + expect(res.status).toBe(200); + const body = await res.json(); + expect(body.visitCount).toBe(0); + }); +}); + describe("GET /:id/profile-summary — empty history", () => { beforeEach(resetMock); diff --git a/apps/api/src/routes/pets.ts b/apps/api/src/routes/pets.ts index 52a4b34..f8b6440 100644 --- a/apps/api/src/routes/pets.ts +++ b/apps/api/src/routes/pets.ts @@ -1,7 +1,7 @@ import { Hono } from "hono"; import { zValidator } from "@hono/zod-validator"; import { z } from "zod/v3"; -import { and, desc, eq, exists, getDb, groomingVisitLogs, or, pets, appointments, staff, services } from "../db/index.js"; +import { and, desc, eq, exists, getDb, gte, groomingVisitLogs, or, pets, appointments, staff, services, sql } from "../db/index.js"; import type { AppEnv } from "../middleware/rbac.js"; import { getPresignedUploadUrl, @@ -362,13 +362,10 @@ petsRouter.get("/:id/profile-summary", async (c) => { const lastVisitDate = historyRows[0]?.groomedAt?.toISOString() ?? null; // Completed appointment count for this pet - const countResult = await db - .select({ count: appointments.id }) + const [{ count: visitCount }] = await db + .select({ count: sql`count(*)::int` }) .from(appointments) - .where(and(eq(appointments.petId, petId), eq(appointments.status, "completed"))) - .limit(1); - - const visitCount = countResult.length; + .where(and(eq(appointments.petId, petId), eq(appointments.status, "completed"))); // Upcoming appointment: next scheduled or confirmed const [nextAppt] = await db @@ -388,7 +385,8 @@ petsRouter.get("/:id/profile-summary", async (c) => { .where( and( eq(appointments.petId, petId), - or(eq(appointments.status, "scheduled"), eq(appointments.status, "confirmed")) + or(eq(appointments.status, "scheduled"), eq(appointments.status, "confirmed")), + gte(appointments.startTime, new Date()) ) ) .orderBy(appointments.startTime) From a25b2fe281e536c596ea9da5a4b895c42d591168 Mon Sep 17 00:00:00 2001 From: Barcode Betty Date: Tue, 26 May 2026 11:34:25 +0000 Subject: [PATCH 3/3] docs: add TC-API-3.18 and TC-API-3.19 to UAT_PLAYBOOK for visitCount regression + date filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated UAT_PLAYBOOK.md §3.3 — new visitCount cap and past appointment filter test cases Co-Authored-By: Claude Opus 4.7 --- UAT_PLAYBOOK.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UAT_PLAYBOOK.md b/UAT_PLAYBOOK.md index d1257bc..0ac1d42 100644 --- a/UAT_PLAYBOOK.md +++ b/UAT_PLAYBOOK.md @@ -80,6 +80,8 @@ GroomBook API is a Hono-based REST service (TypeScript/Node.js) powering the pet | TC-API-3.15 | Reject too many medicalAlerts | POST /api/pets with 51 medicalAlerts | 400 Bad Request, max 50 alerts enforced | | TC-API-3.16 | Get pet profile summary | GET /api/pets/{id}/profile-summary | 200 OK, aggregated profile with grooming history, visit count, upcoming appointment | | TC-API-3.17 | Get pet profile summary — groomer restricted | GET /api/pets/{id}/profile-summary as groomer with no pet linkage | 403 Forbidden | +| TC-API-3.18 | Get pet profile summary — visitCount returns full count | GET /api/pets/{id}/profile-summary with 2+ completed appointments | visitCount >= 2 (not capped at 1) | +| TC-API-3.19 | Get pet profile summary — upcomingAppointment excludes past | GET /api/pets/{id}/profile-summary with a past confirmed/scheduled appointment | upcomingAppointment is null (past appointments filtered by startTime >= now) | ### 4.4 Appointment Scheduling