import test from 'node:test' import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' const read = (path) => readFile(new URL(path, import.meta.url), 'utf8') test('remote PDA mutations use the shared online gate', async () => { const [api, http, network, page] = await Promise.all([ read('../api/pda-loading.js'), read('../api/http.js'), read('../utils/network.js'), read('../pages/picking/picking.vue') ]) assert.match(api, /const request = apiRequest/) assert.match(http, /async function runAuthenticated\(execute\) \{[\s\S]*?requireOnline\(\)/) assert.match(api, /uploadEvidenceFile[\s\S]*?requireOnline\('当前网络不可用,无法上传装柜照片'\)/) assert.match(network, /uni\.onNetworkStatusChange/) assert.match(network, /result\.networkType !== 'none'/) assert.match(page, /当前网络不可用,请联网后再拍照上传/) }) test('remote refresh keeps draft actions but does not restore stale server item snapshots', async () => { const page = await read('../pages/picking/picking.vue') const restore = page.match(/restoreRemoteDraft\(\) \{[\s\S]*?\n\t\t\t\},/)?.[0] || '' assert.match(restore, /itemIds/) assert.match(restore, /restored\.itemStates/) assert.doesNotMatch(restore, /this\.boxes = restored\.boxes/) assert.match(page, /refreshTask\(\)[\s\S]*?persistSession\(\)[\s\S]*?syncRemoteTask\(\)/) })