优化
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
import { overseasRequest, overseasUpload, resetOverseasRequestStateForTest } from '../src/api/overseas.js'
|
||||
import { overseasDownload, overseasRequest, overseasUpload, resetOverseasRequestStateForTest } from '../src/api/overseas.js'
|
||||
import { PDA_AUTHORITY, PDA_ROLE, session, signInWithTokens, signOut } from '../src/stores/session.js'
|
||||
|
||||
const future = () => Math.floor(Date.now() / 1000) + 3600
|
||||
@@ -128,6 +128,18 @@ test('photo upload refreshes and replays once while retaining the file payload',
|
||||
])
|
||||
})
|
||||
|
||||
test('authenticated photo download maps the public api path through the H5 overseas proxy', async () => {
|
||||
const value = prepareSession(); const calls = []
|
||||
globalThis.uni.downloadFile = (options) => {
|
||||
calls.push(options)
|
||||
options.success({ statusCode: 200, tempFilePath: '/tmp/restored.jpg', header: {} })
|
||||
}
|
||||
assert.equal(await overseasDownload('/api/pda/v1/last-leg/receiving-containers/current/unload-photos/files/99/download'), '/tmp/restored.jpg')
|
||||
assert.equal(calls.length, 1)
|
||||
assert.equal(calls[0].url, '/overseas-api/pda/v1/last-leg/receiving-containers/current/unload-photos/files/99/download')
|
||||
assert.equal(calls[0].header.Authorization, `Bearer ${value.overseasAccessToken}`)
|
||||
})
|
||||
|
||||
test('business and network errors retain diagnostics without refreshing or clearing a valid session', async () => {
|
||||
prepareSession(); let refreshCount = 0
|
||||
globalThis.uni.request = (options) => {
|
||||
@@ -147,4 +159,3 @@ test('business and network errors retain diagnostics without refreshing or clear
|
||||
await assert.rejects(overseasRequest('GET', '/pda/network'), (error) => error.network === true && /socket/.test(error.message))
|
||||
assert.ok(session.currentUser)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user