接入M002V4订单任务多卡前端
This commit is contained in:
1 parent
13364e7edf
commit
cae169cefd
19 files changed
+4084
-343
No files matched your search
@@ -2,12 +2,19 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import {
|
||||
convertReservationManualReviewTask,
|
||||
ackReservationV4SourceNotification,
|
||||
confirmReservationV4OrderTaskCard,
|
||||
fetchReservationOrderDetail,
|
||||
fetchReservationOrders,
|
||||
fetchReservationTaskDetail,
|
||||
fetchReservationTaskList,
|
||||
fetchReservationV4OrderTaskDetail,
|
||||
fetchReservationV4OrderTasks,
|
||||
fetchReservationV4SourceNotificationDetail,
|
||||
fetchReservationV4WorkbenchItems,
|
||||
fetchSourceMessageConversation,
|
||||
resolveReservationManualReviewTask,
|
||||
resolveReservationV4OrderTaskCardReview,
|
||||
} from '@/services/reservationService'
|
||||
import { setReservationHotelIdProvider } from '@/config/reservationConfig'
|
||||
|
||||
@@ -129,6 +136,164 @@ describe('reservationService real API mode', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('fetches V4 workbench items from the backend with supported filters only', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
items: [],
|
||||
page: {
|
||||
page_num: 2,
|
||||
page_size: 10,
|
||||
total: 0,
|
||||
},
|
||||
}),
|
||||
)
|
||||
setReservationHotelIdProvider(() => 'HOTEL-BKK')
|
||||
|
||||
await fetchReservationV4WorkbenchItems({
|
||||
item_type: 'SOURCE_NOTIFICATION',
|
||||
keyword: 'S10',
|
||||
page_num: 2,
|
||||
page_size: 10,
|
||||
})
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/reservation/workbench-items?hotel_id=HOTEL-BKK&item_type=SOURCE_NOTIFICATION&keyword=S10&page_num=2&page_size=10',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
)
|
||||
})
|
||||
|
||||
it('fetches V4 order tasks with order task and card status filters', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
items: [],
|
||||
page: {
|
||||
page_num: 1,
|
||||
page_size: 20,
|
||||
total: 0,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
await fetchReservationV4OrderTasks({
|
||||
order_task_status: 'OPEN',
|
||||
card_status: 'REVIEW_REQUIRED',
|
||||
keyword: 'GRP',
|
||||
page_num: 1,
|
||||
page_size: 20,
|
||||
})
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/reservation/order-tasks?order_task_status=OPEN&card_status=REVIEW_REQUIRED&keyword=GRP&page_num=1&page_size=20',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
)
|
||||
})
|
||||
|
||||
it('fetches V4 order task and source notification details by id', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch')
|
||||
.mockResolvedValueOnce(mockJsonResponse({ order_task: { order_task_id: '9001' } }))
|
||||
.mockResolvedValueOnce(mockJsonResponse({ notification: { notification_id: '7001' } }))
|
||||
|
||||
await fetchReservationV4OrderTaskDetail('9001')
|
||||
await fetchReservationV4SourceNotificationDetail('7001')
|
||||
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'/api/reservation/order-tasks/9001',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
)
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'/api/reservation/source-notifications/7001',
|
||||
expect.objectContaining({ method: 'GET' }),
|
||||
)
|
||||
})
|
||||
|
||||
it('confirms a V4 task card with version and current-card payload', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
order_task: {
|
||||
order_task_id: '9001',
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
await confirmReservationV4OrderTaskCard('9001', '9101', {
|
||||
version: 3,
|
||||
confirmed_payload: {
|
||||
basic_information: {
|
||||
account_code: 'QBD_TRAVEL',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/reservation/order-tasks/9001/cards/9101/confirm',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
version: 3,
|
||||
confirmed_payload: {
|
||||
basic_information: {
|
||||
account_code: 'QBD_TRAVEL',
|
||||
},
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('resolves a V4 review card and acknowledges source notifications', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch')
|
||||
.mockResolvedValueOnce(mockJsonResponse({ order_task: { order_task_id: '9001' } }))
|
||||
.mockResolvedValueOnce(mockJsonResponse({ notification: { notification_id: '7001' } }))
|
||||
|
||||
await resolveReservationV4OrderTaskCardReview('9001', '9102', {
|
||||
version: 4,
|
||||
confirmed_order_id: '20001',
|
||||
reason: '人工确认',
|
||||
field_overrides: [
|
||||
{
|
||||
field_pointer: '/business_fields/room_items/0/room_type_code',
|
||||
value: 'TWN',
|
||||
},
|
||||
],
|
||||
})
|
||||
await ackReservationV4SourceNotification('7001', {
|
||||
version: 1,
|
||||
reason: '已读',
|
||||
})
|
||||
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'/api/reservation/order-tasks/9001/cards/9102/review-resolution',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
version: 4,
|
||||
confirmed_order_id: '20001',
|
||||
reason: '人工确认',
|
||||
field_overrides: [
|
||||
{
|
||||
field_pointer: '/business_fields/room_items/0/room_type_code',
|
||||
value: 'TWN',
|
||||
},
|
||||
],
|
||||
}),
|
||||
}),
|
||||
)
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'/api/reservation/source-notifications/7001/ack',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
version: 1,
|
||||
reason: '已读',
|
||||
}),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('fetches the order list from the backend by default', async () => {
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
|
||||
mockJsonResponse({
|
||||
|
||||
Reference in new issue
Block a user