This commit is contained in:
2026-08-26 16:50:25 +08:00
parent 5868e774d4
commit 083299602d
31 changed files with 816 additions and 239 deletions
+9 -5
View File
@@ -2,7 +2,7 @@ import test from 'node:test'
import assert from 'node:assert/strict'
import {
PDA_AUTHORITY, PDA_ROLE, replaceTokens, restoreSession, session,
PDA_AUTHORITY, PDA_ROLE, applyWarehouseProfile, replaceTokens, restoreSession, session,
decodeAccessToken, signInWithTokens, signOut, validatePdaTokenPair
} from '../src/stores/session.js'
import { receiving } from '../src/stores/receiving.js'
@@ -63,6 +63,14 @@ test('JWT decoding preserves unquoted snowflake subjects and warehouse IDs exact
assert.equal(decoded.overseas_warehouse_id, '2091919753155878914')
})
test('warehouse master profile replaces the technical ID only for the token-bound warehouse', () => {
storage(); signOut(); signInWithTokens(tokenPair())
applyWarehouseProfile({ warehouseId: '900', warehouseCode: 'US-LAX-01', warehouseName: '洛杉矶一号仓' })
assert.equal(session.currentUser.warehouse, '洛杉矶一号仓')
assert.equal(session.currentUser.warehouseCode, 'US-LAX-01')
assert.throws(() => applyWarehouseProfile({ warehouseId: '901', warehouseName: '其他仓' }), /不一致/)
})
test('login fails closed for wrong role, authority, warehouse, application, or token subject', () => {
storage(); signOut()
const invalidPairs = [
@@ -123,9 +131,7 @@ test('sign out clears tokens, frozen warehouse identity, and every receiving dra
receiving.current = { containerNo: 'CONT-1', status: 'RECEIVING' }
receiving.selected = receiving.current
receiving.photoSlots = [{ fileId: '1' }, null, null]
receiving.selectedInboundCode = 'IN-1'
receiving.resolvedCarton = { cartonMark: 'BOX-1' }
receiving.resolvedSku = { skuCode: 'SKU-1' }
receiving.resolvedPallet = { palletCode: 'PALLET-1' }
receiving.lastReceipt = { acceptedPackages: 1 }
@@ -139,9 +145,7 @@ test('sign out clears tokens, frozen warehouse identity, and every receiving dra
assert.equal(receiving.current, null)
assert.equal(receiving.selected, null)
assert.deepEqual(receiving.photoSlots, [null, null, null])
assert.equal(receiving.selectedInboundCode, '')
assert.equal(receiving.resolvedCarton, null)
assert.equal(receiving.resolvedSku, null)
assert.equal(receiving.resolvedPallet, null)
assert.equal(receiving.lastReceipt, null)
})