feat(gift): 관리자 선물함 신청 취소 액션 추가

서버 availableActions에 CANCEL이 포함된 경우에만 목록/상세에 신청 취소 버튼을 노출하고,
기존 액션 확인창·dispatch 프레임워크를 재사용해 body 없는 POST /api/v2/admin/gifts/{applicationNo}/cancel을 호출한다.

- giftActions에 CANCEL(신청 취소) 추가 및 cancelGift API 추가
- 확인창에 신청번호와 발신자 전액 리워드캔 환불 안내 표시
- 성공 시 필터/페이지를 유지한 채 목록과 열린 상세 재조회, 실패 시 현재 상태만 재조회(재시도 없음)
- 취소 노출/요청/성공/실패 시나리오 단위 테스트 추가
This commit is contained in:
Yu Sung
2026-10-22 20:13:29 +09:00
parent ea16cf2aa1
commit c245539e46
5 changed files with 136 additions and 11 deletions
+111 -4
View File
@@ -79,7 +79,7 @@ test('API: 기본 페이지와 조합 필터를 query로 전달하고 envelope
assert.deepEqual(calls[2][1].params, { page: 0, size: 20 })
})
test('API: 상세 및 네 가지 POST 경로/본문을 정확하게 전달한다', async () => {
test('API: 상세 및 다섯 가지 POST 경로/본문을 정확하게 전달한다', async () => {
const calls = []
Vue.axios = {
get: async (...args) => { calls.push(['GET', ...args]); return { data: envelope(detail()) } },
@@ -90,21 +90,23 @@ test('API: 상세 및 네 가지 POST 경로/본문을 정확하게 전달한다
await api.completeInspection('G/001')
await api.completeDelivery('G/001')
await api.markUndeliverable('G/001', '파손')
await api.cancelGift('G/001')
assert.deepEqual(calls, [
['GET', '/api/v2/admin/gifts/G%2F001'],
['POST', '/api/v2/admin/gifts/G%2F001/arrive-mailbox'],
['POST', '/api/v2/admin/gifts/G%2F001/complete-inspection'],
['POST', '/api/v2/admin/gifts/G%2F001/complete-delivery'],
['POST', '/api/v2/admin/gifts/G%2F001/mark-undeliverable', { reason: '파손' }]
['POST', '/api/v2/admin/gifts/G%2F001/mark-undeliverable', { reason: '파손' }],
['POST', '/api/v2/admin/gifts/G%2F001/cancel']
])
})
test('액션: 서버 availableActions에 있는 버튼만 실제 템플릿에서 노출한다', () => {
assert.deepEqual(giftActions.map(action => [action.value, action.label]), [
['ARRIVE_MAILBOX', '사서함 도착 처리'], ['COMPLETE_INSPECTION', '검수 완료 처리'],
['COMPLETE_DELIVERY', '전달 완료 처리'], ['MARK_UNDELIVERABLE', '전달 불가 처리']
['COMPLETE_DELIVERY', '전달 완료 처리'], ['MARK_UNDELIVERABLE', '전달 불가 처리'], ['CANCEL', '신청 취소']
])
const scenarios = [[], ['ARRIVE_MAILBOX', 'MARK_UNDELIVERABLE'], ['COMPLETE_INSPECTION', 'MARK_UNDELIVERABLE'], ['COMPLETE_DELIVERY', 'MARK_UNDELIVERABLE'], [], [], []]
const scenarios = [['CANCEL'], ['ARRIVE_MAILBOX', 'MARK_UNDELIVERABLE'], ['COMPLETE_INSPECTION', 'MARK_UNDELIVERABLE'], ['COMPLETE_DELIVERY', 'MARK_UNDELIVERABLE'], [], [], []]
for (const actions of scenarios.concat([['UNKNOWN'], ['MARK_UNDELIVERABLE']])) {
const vm = new Vue({ ...GiftActions, propsData: { actions } })
const buttons = nodes(vm._render()).filter(node => node.tag === 'v-btn')
@@ -403,6 +405,111 @@ test('메뉴: ADMIN에 선물함 리스트를 추가하고 기존 서버 메뉴
}
})
test('취소: 서버 availableActions에 CANCEL이 있을 때만 목록과 상세에 노출하고 기존 dispatch로 실행한다', () => {
const { vm } = page()
vm.gifts = [{
applicationNo: 'G-001', senderNickname: '발송인', recipientNickname: '수취인',
sizeName: '소형', sizeCode: 'S', categoryName: '문구', classificationNumber: 'C1',
courierCompanyName: null, trackingNumber: null, status: 'RECEIVED', statusName: '접수 완료', availableActions: ['CANCEL']
}]
vm.detail = detail({ status: 'RECEIVED', statusName: '접수 완료', availableActions: ['CANCEL'] })
vm.show_detail_dialog = true
const components = nodes(vm._render()).filter(node => node.componentOptions && node.componentOptions.Ctor.options.name === 'GiftActions')
assert.equal(components.length, 2)
for (const component of components) {
const actions = Array.from(component.componentOptions.propsData.actions)
assert.deepEqual(actions, ['CANCEL'])
const buttons = nodes(new Vue({ ...GiftActions, propsData: { actions } })._render()).filter(node => node.tag === 'v-btn')
assert.deepEqual(buttons.map(button => nodes(button).map(node => node.text || '').join('').trim()), ['신청 취소'])
}
components[0].componentOptions.listeners.select('CANCEL')
assert.deepEqual({ ...vm.pendingAction }, { value: 'CANCEL', label: '신청 취소', method: 'cancelGift', applicationNo: 'G-001' })
vm.cancelAction()
for (const actions of [[], ['ARRIVE_MAILBOX'], ['COMPLETE_INSPECTION'], ['COMPLETE_DELIVERY', 'MARK_UNDELIVERABLE']]) {
const buttons = nodes(new Vue({ ...GiftActions, propsData: { actions } })._render()).filter(node => node.tag === 'v-btn')
assert.equal(buttons.map(button => nodes(button).map(node => node.text || '').join('').trim()).includes('신청 취소'), false)
}
vm.requestAction({ applicationNo: 'G-002', status: 'RECEIVED', availableActions: [] }, 'CANCEL')
assert.equal(vm.pendingAction, null)
assert.equal(vm.show_confirm_dialog, false)
})
test('취소 확인창: 신청번호와 전액 리워드캔 환불 안내를 표시하고 닫으면 요청하지 않는다', async () => {
const { vm } = page()
let posts = 0
Vue.axios = { post: async () => { posts++; return { data: envelope({}) } }, get: async () => ({ data: envelope(list()) }) }
vm.requestAction(detail({ status: 'RECEIVED', statusName: '접수 완료', availableActions: ['CANCEL'] }), 'CANCEL')
assert.equal(vm.show_confirm_dialog, true)
assert.equal(vm.show_reason_dialog, false)
const text = nodes(vm._render()).map(node => node.text || '').join(' ')
for (const part of ['G-001', '취소하시겠습니까?', '사용한 캔 전액이 발신자에게 리워드캔으로 환불됩니다.']) assert.ok(text.includes(part), part)
vm.cancelConfirmation()
assert.equal(vm.show_confirm_dialog, false)
assert.equal(vm.pendingAction, null)
await vm.executeAction()
assert.equal(posts, 0)
})
test('취소: 확정 시 본문 없이 한 번만 요청하고 필터/페이지를 유지한 채 목록과 상세를 갱신한다', async () => {
const { vm, successes, errors } = page()
const pending = deferred()
const calls = []
Vue.axios = {
post: async (...args) => {
calls.push(['POST', ...args])
await pending.promise
return { data: envelope({ applicationNo: 'G-001', status: 'CANCELED', statusName: '신청 취소', occurredAt: '2026-09-30T12:00:00Z' }) }
},
get: async (url, config) => {
calls.push(['GET', url, config])
return { data: envelope(config ? list({ page: 2, totalCount: 60 }) : detail({ status: 'CANCELED', statusName: '신청 취소', availableActions: [] })) }
}
}
vm.appliedFilters = { status: 'RECEIVED', applicationNo: '', nickname: '발송인' }
vm.page = 3
vm.detail = detail({ status: 'RECEIVED', statusName: '접수 완료', availableActions: ['CANCEL'] })
vm.show_detail_dialog = true
vm.requestAction(vm.detail, 'CANCEL')
const operation = vm.executeAction()
await vm.executeAction()
pending.resolve()
await operation
assert.deepEqual(calls.filter(call => call[0] === 'POST'), [['POST', '/api/v2/admin/gifts/G-001/cancel']])
assert.deepEqual(calls.find(call => call[1] === '/api/v2/admin/gifts')[2].params, { status: 'RECEIVED', nickname: '발송인', page: 2, size: 20 })
assert.ok(calls.some(call => call[1] === '/api/v2/admin/gifts/G-001'))
assert.equal(vm.page, 3)
assert.equal(vm.detail.status, 'CANCELED')
assert.equal(vm.detail.statusName, '신청 취소')
assert.deepEqual(Array.from(vm.detail.availableActions), [])
assert.deepEqual(successes, ['신청 취소되었습니다.'])
assert.deepEqual(errors, [])
assert.equal(vm.is_operating, false)
assert.equal(vm.show_confirm_dialog, false)
})
test('취소 실패: 가짜 취소 없이 공통 오류를 표시하고 서버 현재 상태를 재조회한다', async () => {
for (const fail of [async () => ({ data: { success: false, message: '이미 변경된 상태입니다.' } }), async () => { throw { response: { data: { message: '통신 실패' } } } }]) {
const { vm, errors, successes } = page()
const calls = []
Vue.axios = {
post: fail,
get: async (url, config) => {
calls.push(url)
return { data: envelope(config ? list() : detail({ status: 'DELIVERED', statusName: '전달 완료', availableActions: [] })) }
}
}
vm.detail = detail({ status: 'RECEIVED', statusName: '접수 완료', availableActions: ['CANCEL'] })
vm.show_detail_dialog = true
vm.requestAction(vm.detail, 'CANCEL')
await vm.executeAction()
assert.equal(errors.length, 1)
assert.equal(successes.length, 0)
assert.deepEqual(calls.slice().sort(), ['/api/v2/admin/gifts', '/api/v2/admin/gifts/G-001'])
assert.equal(vm.detail.status, 'DELIVERED')
assert.equal(vm.is_operating, false)
}
})
;(async () => {
for (const { name, run } of tests) {
try {