From 78315873d7d2db363bf0570fb7ed324b2b683589 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sat, 3 Oct 2026 12:57:26 +0800 Subject: [PATCH] fix(customs): keep result section pending until detail refresh finishes --- .../CustomsDocumentsDialog.test.mjs | 21 ++++++++++++++++++- .../components/CustomsDocumentsDialog.vue | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/modules/first-leg/components/CustomsDocumentsDialog.test.mjs b/src/modules/first-leg/components/CustomsDocumentsDialog.test.mjs index 111151e..9c4860d 100644 --- a/src/modules/first-leg/components/CustomsDocumentsDialog.test.mjs +++ b/src/modules/first-leg/components/CustomsDocumentsDialog.test.mjs @@ -25,6 +25,25 @@ function harness(t) { const detail = id => ({ loadingPlanId: id, inbounds: [{ orderId: id, inboundId: `IN-${id}`, taxMode: 'TAX_REFUND' }] }) const tick = async () => { await Promise.resolve(); await vue.nextTick(); await Promise.resolve() } +test('result section stays pending while the refreshed detail is still loading', async t => { + const h = harness(t) + h.props.initialDetail = detail('A') + h.props.modelValue = true + await tick() + assert.equal(h.view.detail.value.loadingPlanId, 'A') + assert.equal(h.view.loading.value, true) + assert.equal(h.view.clearanceLoading.value, false) + assert.equal(h.clearances.length, 0) + const template = readFileSync(new URL('./CustomsDocumentsDialog.vue', import.meta.url), 'utf8') + assert.match(template, /v-else-if="loading \|\| clearanceLoading"/) + h.requests[0].resolve(detail('A')); await tick() + assert.equal(h.view.clearanceLoading.value, true) + h.clearances[0].resolve([]); await tick() + assert.equal(h.view.loading.value, false) + assert.equal(h.view.clearanceLoading.value, false) + assert.deepEqual(h.view.clearanceResults.value, []) +}) + test('switching orders while open starts the new request and ignores stale detail', async t => { const h = harness(t); h.props.modelValue = true; await tick() h.props.orderId = 'B'; await tick() @@ -125,6 +144,6 @@ test('result error and retry reuse existing section error styling before the emp const source = readFileSync(new URL('./CustomsDocumentsDialog.vue', import.meta.url), 'utf8') assert.match(source, /v-if="clearanceError" class="customs-error" role="alert"/) assert.match(source, /@click="retryClearanceResults"/) - assert.match(source, /v-else-if="clearanceLoading"/) + assert.match(source, /v-else-if="loading \|\| clearanceLoading"/) assert.match(source, /v-else-if="!clearanceResults.length"/) }) diff --git a/src/modules/first-leg/components/CustomsDocumentsDialog.vue b/src/modules/first-leg/components/CustomsDocumentsDialog.vue index 064ae21..2f3ae9b 100644 --- a/src/modules/first-leg/components/CustomsDocumentsDialog.vue +++ b/src/modules/first-leg/components/CustomsDocumentsDialog.vue @@ -385,7 +385,7 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) { {{ clearanceError }} 重新加载 - +