优化
This commit is contained in:
@@ -11,7 +11,7 @@ import process from 'node:process'
|
||||
const DEFAULT_GATEWAY = 'http://8.163.30.128:9000'
|
||||
const DEFAULT_USERNAME = 'platform_admin'
|
||||
const DEFAULT_PASSWORD = 'ChangeMe123!'
|
||||
const DEFAULT_MODULES = ['customers', 'system', 'master-data', 'orders', 'pricing', 'downloads', 'inbound-weight-ocr', 'inbound-measurement', 'supplemental']
|
||||
const DEFAULT_MODULES = ['customers', 'overseas-storage-fees', 'system', 'master-data', 'orders', 'pricing', 'downloads', 'inbound-weight-ocr', 'inbound-measurement', 'supplemental']
|
||||
const WEIGHT_IMAGE_PATH = 'C:/Users/BY-OY/Desktop/上传图片包/测量图片/测量图片/orig_1cf27695-b2c3-44b3-98e3-c0be8b80f79a.JPG'
|
||||
const CUSTOMER_FIELDS = [
|
||||
'id', 'tenantCode', 'tenantName', 'status', 'legalName', 'legalRepresentative',
|
||||
@@ -391,6 +391,45 @@ class AcceptanceRun {
|
||||
}
|
||||
}
|
||||
|
||||
async prepareInboundMeasurementFixture() {
|
||||
const originalMarker = this.marker
|
||||
const fixtureMarker = `${originalMarker}-MOJIA`
|
||||
const createdKeys = ['orders', 'ocrInbound', 'testInbound']
|
||||
const contextKeys = ['inboundWeightOcr', 'ocrInbound', 'testInbound', 'createdInbound']
|
||||
const createdSnapshot = new Map(createdKeys.map((key) => [key, {
|
||||
present: Object.hasOwn(this.createdResources, key), value: this.createdResources[key],
|
||||
}]))
|
||||
const contextSnapshot = new Map(contextKeys.map((key) => [key, {
|
||||
present: Object.hasOwn(this.context, key), value: this.context[key],
|
||||
}]))
|
||||
|
||||
this.marker = fixtureMarker
|
||||
const extension = await import(new URL('./admin-test-env-modules/orders.mjs', import.meta.url))
|
||||
await this.executeModule('orders-inbound-measurement-fixture', () => extension.run(this))
|
||||
const fixture = this.createdResources.orders
|
||||
this.createdResources.orchestrationFixtures = {
|
||||
...(this.createdResources.orchestrationFixtures || {}),
|
||||
inboundMeasurement: fixture ? {
|
||||
marker: fixtureMarker,
|
||||
tenantId: fixture.tenantId,
|
||||
orderId: fixture.orderId,
|
||||
inboundId: fixture.inboundId,
|
||||
} : { marker: fixtureMarker, failed: true },
|
||||
}
|
||||
|
||||
return () => {
|
||||
this.marker = originalMarker
|
||||
for (const [key, snapshot] of createdSnapshot) {
|
||||
if (snapshot.present) this.createdResources[key] = snapshot.value
|
||||
else delete this.createdResources[key]
|
||||
}
|
||||
for (const [key, snapshot] of contextSnapshot) {
|
||||
if (snapshot.present) this.context[key] = snapshot.value
|
||||
else delete this.context[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async run() {
|
||||
const loginResponse = await this.request('POST', '/api/auth/login', { username: this.options.username, password: this.options.password }, '')
|
||||
const login = this.apiSuccess('authentication', '平台管理员登录', loginResponse)
|
||||
@@ -398,7 +437,19 @@ class AcceptanceRun {
|
||||
else {
|
||||
this.token = login.accessToken
|
||||
const handlers = { customers: () => this.runCustomers() }
|
||||
for (const module of this.options.modules) {
|
||||
for (let moduleIndex = 0; moduleIndex < this.options.modules.length; moduleIndex += 1) {
|
||||
const module = this.options.modules[moduleIndex]
|
||||
let restoreFixture = null
|
||||
const ocrIndex = this.options.modules.indexOf('inbound-weight-ocr')
|
||||
if (module === 'inbound-measurement' && ocrIndex >= 0 && ocrIndex < moduleIndex) {
|
||||
try {
|
||||
restoreFixture = await this.prepareInboundMeasurementFixture()
|
||||
} catch (error) {
|
||||
const reason = error instanceof Error ? error.message : String(error)
|
||||
this.addStep('orders-inbound-measurement-fixture', '创建独立测量入库单', null, false, reason,
|
||||
{ scenario: 'inbound-resource-isolation' })
|
||||
}
|
||||
}
|
||||
let handler = handlers[module]
|
||||
if (!handler) {
|
||||
try {
|
||||
@@ -409,10 +460,15 @@ class AcceptanceRun {
|
||||
const reason = error instanceof Error ? error.message : String(error)
|
||||
this.addStep(module, '模块注册检查', null, false, `无法加载模块: ${reason}`)
|
||||
this.modules.push({ name: module, success: false, passed: 0, failed: 1, fatal: reason })
|
||||
if (restoreFixture) restoreFixture()
|
||||
continue
|
||||
}
|
||||
}
|
||||
await this.executeModule(module, handler)
|
||||
try {
|
||||
await this.executeModule(module, handler)
|
||||
} finally {
|
||||
if (restoreFixture) restoreFixture()
|
||||
}
|
||||
}
|
||||
}
|
||||
const failed = this.steps.filter((step) => !step.passed).length
|
||||
|
||||
Reference in New Issue
Block a user