补齐人工复核转换和列表筛选
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import {
|
||||
convertReservationManualReviewTask,
|
||||
fetchReservationOrderDetail,
|
||||
fetchReservationOrders,
|
||||
fetchReservationTaskDetail,
|
||||
@@ -76,6 +77,31 @@ describe('reservationService real API mode', () => {
|
||||
expect(result.items[0]?.source_subject).toBe('Booking Request')
|
||||
})
|
||||
|
||||
it('passes task subtype and terminal task status filters to the backend', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
items: [],
|
||||
page: {
|
||||
page_num: 1,
|
||||
page_size: 20,
|
||||
total: 0,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
await fetchReservationTaskList({
|
||||
task_subtype: 'RATE_CHANGE',
|
||||
task_status: 'FAILED',
|
||||
page_num: 1,
|
||||
page_size: 20,
|
||||
})
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/reservation/tasks?hotel_id=HOTEL-TEST&task_subtype=RATE_CHANGE&task_status=FAILED&page_num=1&page_size=20',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
)
|
||||
})
|
||||
|
||||
it('fetches the order list from the backend by default', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
@@ -117,6 +143,70 @@ describe('reservationService real API mode', () => {
|
||||
expect(result.items[0]?.next_processable_task_id).toBe('10002')
|
||||
})
|
||||
|
||||
it('passes order status and business-key filters to the backend', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
items: [],
|
||||
page: {
|
||||
page_num: 2,
|
||||
page_size: 10,
|
||||
total: 0,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
await fetchReservationOrders({
|
||||
order_status: 'LOGIC_DELETED',
|
||||
group_code: 'GRP-001',
|
||||
confirmation_number: 'CNF-001',
|
||||
keyword: 'VIP',
|
||||
page_num: 2,
|
||||
page_size: 10,
|
||||
})
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/reservation/orders?hotel_id=HOTEL-TEST&order_status=LOGIC_DELETED&group_code=GRP-001&confirmation_number=CNF-001&keyword=VIP&page_num=2&page_size=10',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
)
|
||||
})
|
||||
|
||||
it('converts a manual review task through the backend endpoint', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
task_id: '10001',
|
||||
order_id: '20002',
|
||||
original_order_id: '20001',
|
||||
system_task_type: 'UPDATE_BOOKING',
|
||||
task_card_type: 'UPDATE_BOOKING',
|
||||
task_status: 'PENDING_CONFIRM',
|
||||
original_order_logic_deleted: true,
|
||||
}),
|
||||
)
|
||||
|
||||
const result = await convertReservationManualReviewTask('10001', {
|
||||
target_task_type: 'UPDATE_BOOKING',
|
||||
target_order_id: '20002',
|
||||
reason: 'Matched by group code',
|
||||
})
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/reservation/tasks/10001/manual-review-conversions',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
headers: expect.objectContaining({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: JSON.stringify({
|
||||
target_task_type: 'UPDATE_BOOKING',
|
||||
target_order_id: '20002',
|
||||
reason: 'Matched by group code',
|
||||
}),
|
||||
}),
|
||||
)
|
||||
expect(result.system_task_type).toBe('UPDATE_BOOKING')
|
||||
expect(result.original_order_logic_deleted).toBe(true)
|
||||
})
|
||||
|
||||
it('fetches order detail from the backend by default', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
|
||||
Reference in New Issue
Block a user