Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ describe('TicketDetailPage reply access', () => {
.toBeTruthy()
})

it('preserves freshly revalidated assignees when marking a ticket read completes', async () => {
it('revalidates fresh detail after marking the ticket read', async () => {
const markReadRequest = createDeferred<void>()
mockedMarkRead.mockReturnValue(markReadRequest.promise)
mockUseSWR.mockReturnValue({
Expand All @@ -254,35 +254,10 @@ describe('TicketDetailPage reply access', () => {

await waitFor(() => {
expect(mockMutate)
.toHaveBeenCalledWith(expect.any(Function), false)
.toHaveBeenCalledTimes(1)
})

const updateCachedTicket = mockMutate.mock.calls[0][0] as (
ticket?: SupportTicketDetail,
) => SupportTicketDetail | undefined
const freshlyRevalidatedTicket: SupportTicketDetail = {
...closedTicket,
assignees: [{
assignedAt: '2026-08-07T01:30:00.000Z',
handle: 'support-staff',
userId: '67890',
}],
hasUnread: true,
responseCount: 1,
responses: [{
createdAt: '2026-08-07T01:30:00.000Z',
id: 'response-1',
markdown: 'We are investigating.',
readBy: [],
userHandle: 'support-staff',
userId: '67890',
}],
}

expect(updateCachedTicket(freshlyRevalidatedTicket))
.toEqual({ ...freshlyRevalidatedTicket, hasUnread: false })
expect(updateCachedTicket(undefined))
.toBeUndefined()
expect(mockMutate.mock.calls[0])
.toEqual([])
})

it('identifies support team replies without labelling the ticket owner', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ export const TicketDetailPage: FC = () => {

markedReadTicket.current = data.id
markSupportTicketRead(data.id)
.then(() => mutate(current => (current
? { ...current, hasUnread: false }
: current), false))
.then(() => mutate())
.catch(() => undefined)
}, [data, mutate])

Expand Down
Loading