fix(customs): keep result section pending until detail refresh finishes

This commit is contained in:
2026-10-03 12:57:26 +08:00
parent fc32d0b390
commit 78315873d7
2 changed files with 21 additions and 2 deletions
@@ -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"/)
})
@@ -385,7 +385,7 @@ function clearanceResultStatusLabel(value: MerchantClearanceResult) {
<span>{{ clearanceError }}</span>
<el-button :loading="clearanceLoading" @click="retryClearanceResults">重新加载</el-button>
</div>
<el-skeleton v-else-if="clearanceLoading" :rows="2" animated />
<el-skeleton v-else-if="loading || clearanceLoading" :rows="2" animated />
<el-empty v-else-if="!clearanceResults.length" description="暂无海关结果" :image-size="48" />
<div v-else class="clearance-result-list">
<div v-for="item in clearanceResults" :key="item.id" class="clearance-result-row">