优化
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const source = readFileSync(resolve(process.cwd(), 'src/modules/inbounds/measurement/components/MeasurementEvidenceThumbnail.vue'), 'utf8')
|
||||
const weightWrapperSource = readFileSync(resolve(process.cwd(), 'src/modules/inbounds/weight/components/WeightImageThumbnail.vue'), 'utf8')
|
||||
|
||||
describe('MeasurementEvidenceThumbnail', () => {
|
||||
it('uses the authenticated measurement thumbnail API with stale-request and object-url cleanup', () => {
|
||||
expect(source).toContain("import { downloadWeightThumbnail } from '../../weight/api/weightOcr'")
|
||||
expect(source).toContain('downloadWeightThumbnail(props.customerId, props.inboundId, props.fileId)')
|
||||
expect(source).toContain('currentRequest !== requestId')
|
||||
expect(source).toContain('URL.revokeObjectURL(imageUrl.value)')
|
||||
})
|
||||
|
||||
it('renders explicit loading, failure and missing-file states', () => {
|
||||
expect(source).toContain("fileId?: string | null")
|
||||
expect(source).toContain("!fileId ? emptyText : failed ? '图片加载失败'")
|
||||
expect(source).toContain(':disabled="!fileId"')
|
||||
})
|
||||
|
||||
it('is also the evidence thumbnail used by the editable OCR workspace', () => {
|
||||
expect(weightWrapperSource).toContain("import MeasurementEvidenceThumbnail from '../../measurement/components/MeasurementEvidenceThumbnail.vue'")
|
||||
expect(weightWrapperSource).toContain('<MeasurementEvidenceThumbnail')
|
||||
expect(weightWrapperSource).toContain('empty-text="未绑定称重图片"')
|
||||
})
|
||||
})
|
||||
@@ -64,7 +64,7 @@ onBeforeUnmount(() => {
|
||||
<img v-if="imageUrl" :src="imageUrl" :alt="alt" loading="lazy" />
|
||||
<span v-else class="measurement-evidence-thumb__state" :class="{ 'is-loading': loading }">
|
||||
<ImageOff v-if="failed || !fileId" :size="22" aria-hidden="true" />
|
||||
<span>{{ !fileId ? emptyText : failed ? '图片加载失败,点击重试' : '图片加载中' }}</span>
|
||||
<span>{{ !fileId ? emptyText : failed ? '图片加载失败' : '图片加载中' }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user