feat: automate business upgrades and sync reviewed frontend
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readBlobBusinessMessage } from './blobError.js'
|
||||
|
||||
const jsonBlob = (value, type = 'application/json') => new Blob([JSON.stringify(value)], { type })
|
||||
|
||||
test('reads the export limit message from a json blob', async () => {
|
||||
const message = '导出数据超过10000条,请缩小时间范围或筛选条件'
|
||||
assert.equal(await readBlobBusinessMessage(jsonBlob({ code: 500, msg: message })), message)
|
||||
})
|
||||
|
||||
test('reads the same message when the file type is not json', async () => {
|
||||
const message = '导出数据超过10000条,请缩小时间范围或筛选条件'
|
||||
assert.equal(await readBlobBusinessMessage(jsonBlob({ code: 500, msg: message }, 'application/octet-stream')), message)
|
||||
})
|
||||
|
||||
test('reads a plain-text export error', async () => {
|
||||
const message = '导出数据超过10000条,请缩小时间范围或筛选条件'
|
||||
assert.equal(await readBlobBusinessMessage(new Blob([message], { type: 'text/plain' })), message)
|
||||
})
|
||||
|
||||
test('leaves spreadsheet and unrelated json files alone', async () => {
|
||||
const sheet = new Blob([new Uint8Array([0x50, 0x4b, 0x03, 0x04, 0x14, 0x00])], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
|
||||
assert.equal(await readBlobBusinessMessage(sheet), '')
|
||||
assert.equal(await readBlobBusinessMessage(jsonBlob({ versionName: '1.0', versionCode: '1', message: '发版说明' })), '')
|
||||
assert.equal(await readBlobBusinessMessage(jsonBlob({ code: 0, msg: 'ok' })), '')
|
||||
assert.equal(await readBlobBusinessMessage(jsonBlob({ msg: '导出数据超过10000条,请缩小时间范围或筛选条件' })), '导出数据超过10000条,请缩小时间范围或筛选条件')
|
||||
})
|
||||
Reference in New Issue
Block a user