fix(customs): keep result section pending until detail refresh finishes
This commit is contained in:
@@ -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"/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user