优化
This commit is contained in:
@@ -380,7 +380,7 @@ async function loginIdentifierModule() {
|
||||
}, ({ status, json }) => ({ status, rejectionCode: json?.code }))
|
||||
|
||||
const renamedLogin = await apiStep('login-identifiers', 'login with the changed username', {
|
||||
method: 'POST', path: '/api/auth/login', body: { username: temporaryUsername, password: clientPassword },
|
||||
method: 'POST', path: '/api/auth/login', body: { loginId: temporaryUsername, password: clientPassword },
|
||||
}, ({ json }) => {
|
||||
requireSuccess(json)
|
||||
assertPresent(json.data?.accessToken, 'accessToken')
|
||||
@@ -397,7 +397,7 @@ async function loginIdentifierModule() {
|
||||
}, ({ json }) => ({ username: json.data.username }))
|
||||
|
||||
const restoredLogin = await apiStep('login-identifiers', 'login after restoring the original username', {
|
||||
method: 'POST', path: '/api/auth/login', body: { username, password: clientPassword },
|
||||
method: 'POST', path: '/api/auth/login', body: { loginId: username, password: clientPassword },
|
||||
}, ({ json }) => {
|
||||
requireSuccess(json)
|
||||
assertPresent(json.data?.accessToken, 'accessToken')
|
||||
@@ -1770,7 +1770,7 @@ async function loadOrderMasterData(token, module) {
|
||||
requireSuccess(json)
|
||||
assertTrue(pageRecords(json.data).length > 0, 'at least one active DOMESTIC warehouse is required')
|
||||
}, ({ json }) => ({ total: json.data?.total, warehouseCount: pageRecords(json.data).length }))
|
||||
const receiving = pageRecords(receivingWarehouses.json.data)[0]
|
||||
const receivingCandidates = pageRecords(receivingWarehouses.json.data)
|
||||
|
||||
const destinationWarehouses = await apiStep(module, 'load active FBA destination warehouses', {
|
||||
method: 'GET', path: '/api/merchant/v1/warehouses?page=1&size=200&status=ACTIVE&warehouseType=FBA', token,
|
||||
@@ -1779,6 +1779,21 @@ async function loadOrderMasterData(token, module) {
|
||||
assertTrue(pageRecords(json.data).length > 0, 'at least one active FBA warehouse is required')
|
||||
}, ({ json }) => ({ total: json.data?.total, warehouseCount: pageRecords(json.data).length }))
|
||||
const destination = pageRecords(destinationWarehouses.json.data)[0]
|
||||
let receiving = null
|
||||
let pricedChannels = []
|
||||
for (const candidate of receivingCandidates) {
|
||||
const response = await httpRequest({
|
||||
method: 'GET', path: `/api/merchant/v1/first-leg/pricing/channels?originWarehouseId=${candidate.id}`, token,
|
||||
})
|
||||
const candidates = String(response?.json?.code) === '200' ? arrayData(response.json.data) : []
|
||||
const available = candidates.filter((item) => arrayData(item.pricingTaxModes).length > 0)
|
||||
if (available.length > 0) {
|
||||
receiving = candidate
|
||||
pricedChannels = available
|
||||
break
|
||||
}
|
||||
}
|
||||
assertPresent(receiving, 'active DOMESTIC warehouse with pricing channels')
|
||||
report.resources.receivingWarehouseId = receiving.id
|
||||
report.resources.destinationWarehouseId = destination.id
|
||||
|
||||
@@ -1796,7 +1811,7 @@ async function loadOrderMasterData(token, module) {
|
||||
requireSuccess(json)
|
||||
assertTrue(arrayData(json.data).length > 0, 'at least one active pricing channel is required')
|
||||
}, ({ json }) => ({ channels: arrayData(json.data).map((item) => ({ channelCode: item.channelCode, priceModel: item.priceModel, pricingTaxModes: item.pricingTaxModes })) }))
|
||||
const channel = arrayData(channels.json.data).find((item) => arrayData(item.pricingTaxModes).length > 0)
|
||||
const channel = pricedChannels.find((item) => arrayData(item.pricingTaxModes).length > 0)
|
||||
assertPresent(channel, 'pricing channel with pricingTaxModes')
|
||||
report.resources.channelCode = channel.channelCode
|
||||
|
||||
@@ -1812,7 +1827,7 @@ async function loadOrderMasterData(token, module) {
|
||||
destination,
|
||||
destinationCandidates: pageRecords(destinationWarehouses.json.data),
|
||||
channel,
|
||||
channelCandidates: arrayData(channels.json.data).filter((item) => arrayData(item.pricingTaxModes).length > 0),
|
||||
channelCandidates: pricedChannels,
|
||||
partner,
|
||||
}
|
||||
}
|
||||
@@ -2003,13 +2018,10 @@ async function softApiStep(module, name, request, validate, evidenceBuilder = de
|
||||
async function httpRequest({ method = 'GET', path, token, headers = {}, body, responseType = 'json' }) {
|
||||
const requestHeaders = { Accept: 'application/json', 'X-Request-Id': `client-e2e-${randomUUID()}`, ...headers }
|
||||
if (token) requestHeaders.Authorization = `Bearer ${token}`
|
||||
const normalizedBody = path === '/api/auth/login' && body?.username && !body?.loginId
|
||||
? { ...body, loginId: body.username, username: undefined }
|
||||
: body
|
||||
let requestBody = normalizedBody
|
||||
if (normalizedBody != null && !(normalizedBody instanceof FormData)) {
|
||||
let requestBody = body
|
||||
if (body != null && !(body instanceof FormData)) {
|
||||
requestHeaders['Content-Type'] = 'application/json'
|
||||
requestBody = JSON.stringify(normalizedBody)
|
||||
requestBody = JSON.stringify(body)
|
||||
}
|
||||
const response = await fetch(`${gateway}${path}`, {
|
||||
method,
|
||||
|
||||
Reference in New Issue
Block a user