fix: deep link reschedule audit log to booking drawer history tab (#27709)
* fix: deep link reschedule audit log to booking drawer history tab Co-Authored-By: [email protected] <[email protected]> * fix: make booking drawer tab-agnostic for cross-tab deep links Co-Authored-By: [email protected] <[email protected]> * fix: use status-agnostic /bookings URL for audit log deep links - Update audit service URLs from /bookings/upcoming?uid=... to /bookings?uid=... - Add /bookings/page.tsx redirect that routes to /bookings/upcoming preserving query params - Update tests to expect new URL format Co-Authored-By: [email protected] <[email protected]> * fixes * refactor: use client-side replaceState instead of server redirect for booking deep links Co-Authored-By: [email protected] <[email protected]> * fix: use router.replace instead of replaceState to update tab and booking list Co-Authored-By: [email protected] <[email protected]> * improvements * refactor: extract deep link logic from BookingListContainer into usePreSelectedBooking hook Co-Authored-By: [email protected] <[email protected]> * fix: use proper BookingOutput status type in test helper Co-Authored-By: [email protected] <[email protected]> * fix: decouple getTabForBooking from BookingOutput type for simpler testing Co-Authored-By: [email protected] <[email protected]> * fix: accept Date | string for endTime in BookingForTabResolution interface Co-Authored-By: [email protected] <[email protected]> * refactor: eliminate initialBookingUid prop drilling and revert formatting-only changes Co-Authored-By: [email protected] <[email protected]> * fix: use AuditDeepLink wrapper to preserve target=_blank through ServerTrans cloneElement Co-Authored-By: [email protected] <[email protected]> * Improve code organization * refactor: rename usePreSelectedBooking to useSwitchToCorrectStatusTab Co-Authored-By: [email protected] <[email protected]> * fix: push preSelectedBooking into store so drawer opens on direct navigation Co-Authored-By: [email protected] <[email protected]> * fixes * fixes * fixes * fix --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
9 files changed
+455
-96
No files matched your search
@@ -1,14 +1,13 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { NumberChangeSchema, StringChangeSchema } from "../common/changeSchemas";
|
||||
import type { DataRequirements } from "../service/EnrichmentDataStore";
|
||||
import { AuditActionServiceHelper } from "./AuditActionServiceHelper";
|
||||
import type {
|
||||
BaseStoredAuditData,
|
||||
GetDisplayJsonParams,
|
||||
GetDisplayTitleParams,
|
||||
IAuditActionService,
|
||||
TranslationWithParams,
|
||||
GetDisplayTitleParams,
|
||||
GetDisplayJsonParams,
|
||||
BaseStoredAuditData,
|
||||
} from "./IAuditActionService";
|
||||
|
||||
/**
|
||||
@@ -91,7 +90,7 @@ export class RescheduledAuditActionService implements IAuditActionService {
|
||||
newDate,
|
||||
},
|
||||
components: rescheduledToUid
|
||||
? [{ type: "link", href: `/booking/${rescheduledToUid}/logs` }]
|
||||
? [{ type: "link", href: `/bookings?uid=${rescheduledToUid}&activeSegment=history` }]
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
@@ -122,7 +121,7 @@ export class RescheduledAuditActionService implements IAuditActionService {
|
||||
oldDate,
|
||||
newDate,
|
||||
},
|
||||
components: [{ type: "link", href: `/booking/${fromRescheduleUid}/logs` }],
|
||||
components: [{ type: "link", href: `/bookings?uid=${fromRescheduleUid}&activeSegment=history` }],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ export class SeatRescheduledAuditActionService implements IAuditActionService {
|
||||
oldDate,
|
||||
newDate,
|
||||
},
|
||||
components: rescheduledToBookingUid
|
||||
? [{ type: "link", href: `/booking/${rescheduledToBookingUid}/logs` }]
|
||||
: undefined,
|
||||
components: rescheduledToBookingUid
|
||||
? [{ type: "link", href: `/bookings?uid=${rescheduledToBookingUid}&activeSegment=history` }]
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+87
-1
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, beforeEach } from "vitest";
|
||||
|
||||
import { verifyDataRequirementsContract } from "./contractVerification";
|
||||
import { verifyDataRequirementsContract, createTrackingDbStore, createEmptyAccessedData } from "./contractVerification";
|
||||
import { RescheduledAuditActionService } from "../RescheduledAuditActionService";
|
||||
|
||||
describe("RescheduledAuditActionService - getDataRequirements contract", () => {
|
||||
@@ -26,3 +26,89 @@ describe("RescheduledAuditActionService - getDataRequirements contract", () => {
|
||||
expect(accessedData.userUuids.size).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("RescheduledAuditActionService - getDisplayTitle", () => {
|
||||
let service: RescheduledAuditActionService;
|
||||
|
||||
beforeEach(() => {
|
||||
service = new RescheduledAuditActionService();
|
||||
});
|
||||
|
||||
it("should generate deep link to booking drawer with history tab", async () => {
|
||||
const rescheduledToUid = "new-booking-uid-123";
|
||||
const storedData = {
|
||||
version: 1,
|
||||
fields: {
|
||||
startTime: { old: 1700000000000, new: 1700100000000 },
|
||||
endTime: { old: 1700003600000, new: 1700103600000 },
|
||||
rescheduledToUid: { old: null, new: rescheduledToUid },
|
||||
},
|
||||
};
|
||||
|
||||
const dbStore = createTrackingDbStore(createEmptyAccessedData());
|
||||
const result = await service.getDisplayTitle({
|
||||
storedData,
|
||||
userTimeZone: "UTC",
|
||||
dbStore,
|
||||
});
|
||||
|
||||
expect(result.components).toBeDefined();
|
||||
expect(result.components).toHaveLength(1);
|
||||
expect(result.components![0].href).toBe(
|
||||
`/bookings?uid=${rescheduledToUid}&activeSegment=history`
|
||||
);
|
||||
});
|
||||
|
||||
it("should not include components when rescheduledToUid is null", async () => {
|
||||
const storedData = {
|
||||
version: 1,
|
||||
fields: {
|
||||
startTime: { old: 1700000000000, new: 1700100000000 },
|
||||
endTime: { old: 1700003600000, new: 1700103600000 },
|
||||
rescheduledToUid: { old: null, new: null },
|
||||
},
|
||||
};
|
||||
|
||||
const dbStore = createTrackingDbStore(createEmptyAccessedData());
|
||||
const result = await service.getDisplayTitle({
|
||||
storedData,
|
||||
userTimeZone: "UTC",
|
||||
dbStore,
|
||||
});
|
||||
|
||||
expect(result.components).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("RescheduledAuditActionService - getDisplayTitleForRescheduledFromLog", () => {
|
||||
let service: RescheduledAuditActionService;
|
||||
|
||||
beforeEach(() => {
|
||||
service = new RescheduledAuditActionService();
|
||||
});
|
||||
|
||||
it("should generate deep link to original booking's history tab", () => {
|
||||
const fromRescheduleUid = "original-booking-uid-456";
|
||||
const storedData = {
|
||||
version: 1,
|
||||
fields: {
|
||||
startTime: { old: 1700000000000, new: 1700100000000 },
|
||||
endTime: { old: 1700003600000, new: 1700103600000 },
|
||||
rescheduledToUid: { old: null, new: "some-uid" },
|
||||
},
|
||||
};
|
||||
|
||||
const result = service.getDisplayTitleForRescheduledFromLog({
|
||||
fromRescheduleUid,
|
||||
userTimeZone: "UTC",
|
||||
storedData,
|
||||
});
|
||||
|
||||
|
||||
expect(result.components).toBeDefined();
|
||||
expect(result.components).toHaveLength(1);
|
||||
expect(result.components![0].href).toBe(
|
||||
`/bookings?uid=${fromRescheduleUid}&activeSegment=history`
|
||||
);
|
||||
});
|
||||
});
|
||||
+58
-1
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, beforeEach } from "vitest";
|
||||
|
||||
import { verifyDataRequirementsContract } from "./contractVerification";
|
||||
import { verifyDataRequirementsContract, createTrackingDbStore, createEmptyAccessedData } from "./contractVerification";
|
||||
import { SeatRescheduledAuditActionService } from "../SeatRescheduledAuditActionService";
|
||||
|
||||
describe("SeatRescheduledAuditActionService - getDataRequirements contract", () => {
|
||||
@@ -27,3 +27,60 @@ describe("SeatRescheduledAuditActionService - getDataRequirements contract", ()
|
||||
expect(accessedData.userUuids.size).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("SeatRescheduledAuditActionService - getDisplayTitle", () => {
|
||||
let service: SeatRescheduledAuditActionService;
|
||||
|
||||
beforeEach(() => {
|
||||
service = new SeatRescheduledAuditActionService();
|
||||
});
|
||||
|
||||
it("should generate deep link to booking drawer with history tab", async () => {
|
||||
const rescheduledToBookingUid = "new-booking-uid-789";
|
||||
const storedData = {
|
||||
version: 1,
|
||||
fields: {
|
||||
seatReferenceUid: "seat-456",
|
||||
attendeeEmail: "[email protected]",
|
||||
startTime: { old: 1700000000000, new: 1700100000000 },
|
||||
endTime: { old: 1700003600000, new: 1700103600000 },
|
||||
rescheduledToBookingUid: { old: null, new: rescheduledToBookingUid },
|
||||
},
|
||||
};
|
||||
|
||||
const dbStore = createTrackingDbStore(createEmptyAccessedData());
|
||||
const result = await service.getDisplayTitle({
|
||||
storedData,
|
||||
userTimeZone: "UTC",
|
||||
dbStore,
|
||||
});
|
||||
|
||||
expect(result.components).toBeDefined();
|
||||
expect(result.components).toHaveLength(1);
|
||||
expect(result.components![0].href).toBe(
|
||||
`/bookings?uid=${rescheduledToBookingUid}&activeSegment=history`
|
||||
);
|
||||
});
|
||||
|
||||
it("should not include components when rescheduledToBookingUid is null", async () => {
|
||||
const storedData = {
|
||||
version: 1,
|
||||
fields: {
|
||||
seatReferenceUid: "seat-456",
|
||||
attendeeEmail: "[email protected]",
|
||||
startTime: { old: 1700000000000, new: 1700100000000 },
|
||||
endTime: { old: 1700003600000, new: 1700103600000 },
|
||||
rescheduledToBookingUid: { old: null, new: null },
|
||||
},
|
||||
};
|
||||
|
||||
const dbStore = createTrackingDbStore(createEmptyAccessedData());
|
||||
const result = await service.getDisplayTitle({
|
||||
storedData,
|
||||
userTimeZone: "UTC",
|
||||
dbStore,
|
||||
});
|
||||
|
||||
expect(result.components).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user