fix: 回调配置, 调整信用位置, 套餐
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 6m55s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 6m55s
This commit is contained in:
@@ -50,13 +50,13 @@ async function importBundledActions() {
|
||||
}
|
||||
}
|
||||
|
||||
test('pending agent recharge exposes reject action for admins with rejection permission', async () => {
|
||||
test('pending offline recharge exposes reject action for admins with rejection permission', async () => {
|
||||
const { module, cleanup } = await importBundledActions()
|
||||
const { buildAgentRechargeActions } = module
|
||||
const row = {
|
||||
id: 42,
|
||||
status: 1,
|
||||
payment_method: 'wechat',
|
||||
payment_method: 'offline',
|
||||
payment_voucher_key: []
|
||||
}
|
||||
const handledRows = []
|
||||
@@ -108,3 +108,27 @@ test('non-pending agent recharge does not expose reject action', async () => {
|
||||
await cleanup()
|
||||
}
|
||||
})
|
||||
|
||||
test('pending online recharge does not expose offline reject action', async () => {
|
||||
const { module, cleanup } = await importBundledActions()
|
||||
const { buildAgentRechargeActions } = module
|
||||
const row = {
|
||||
id: 42,
|
||||
status: 1,
|
||||
payment_method: 'wechat',
|
||||
payment_voucher_key: []
|
||||
}
|
||||
|
||||
try {
|
||||
const actions = buildAgentRechargeActions(row, {
|
||||
hasAuth: (permission) => permission === 'agent_recharge:reject',
|
||||
onViewPaymentVoucher: () => {},
|
||||
onConfirmPayment: () => {},
|
||||
onReject: () => {}
|
||||
})
|
||||
|
||||
assert.deepEqual(actions, [])
|
||||
} finally {
|
||||
await cleanup()
|
||||
}
|
||||
})
|
||||
|
||||
72
scripts/tests/agentRechargeOnline.test.mjs
Normal file
72
scripts/tests/agentRechargeOnline.test.mjs
Normal file
@@ -0,0 +1,72 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { mkdtemp, rm, stat } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import * as esbuild from 'esbuild'
|
||||
|
||||
async function importBundledOnlineHelpers() {
|
||||
const tempDir = await mkdtemp(join(tmpdir(), 'agent-recharge-online-'))
|
||||
const bundlePath = join(tempDir, 'agentRechargeOnline.mjs')
|
||||
|
||||
await esbuild.build({
|
||||
entryPoints: ['src/views/finance/agent-recharge/agentRechargeOnline.ts'],
|
||||
bundle: true,
|
||||
outfile: bundlePath,
|
||||
format: 'esm',
|
||||
platform: 'node',
|
||||
absWorkingDir: process.cwd(),
|
||||
plugins: [
|
||||
{
|
||||
name: 'alias-src',
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^@\// }, async (args) => {
|
||||
const resolvedPath = join(process.cwd(), 'src', args.path.slice(2))
|
||||
try {
|
||||
if ((await stat(resolvedPath)).isDirectory())
|
||||
return { path: join(resolvedPath, 'index.ts') }
|
||||
} catch {
|
||||
// Let esbuild report the original resolution failure.
|
||||
}
|
||||
return { path: resolvedPath }
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const module = await import(pathToFileURL(bundlePath).href)
|
||||
return {
|
||||
module,
|
||||
cleanup: () => rm(tempDir, { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
|
||||
test('online recharge helpers convert yuan to integer fen and identify terminal states', async () => {
|
||||
const { module, cleanup } = await importBundledOnlineHelpers()
|
||||
|
||||
try {
|
||||
assert.equal(module.amountYuanToFen(100.01), 10001)
|
||||
assert.equal(module.isOnlineRechargeTerminal(1), false)
|
||||
assert.equal(module.isOnlineRechargeTerminal(2), false)
|
||||
assert.equal(module.isOnlineRechargeTerminal(3), true)
|
||||
assert.equal(module.isOnlineRechargeTerminal(6), true)
|
||||
} finally {
|
||||
await cleanup()
|
||||
}
|
||||
})
|
||||
|
||||
test('online recharge request IDs are unique and namespaced', async () => {
|
||||
const { module, cleanup } = await importBundledOnlineHelpers()
|
||||
|
||||
try {
|
||||
const first = module.createOnlineRechargeRequestId()
|
||||
const second = module.createOnlineRechargeRequestId()
|
||||
assert.match(first, /^recharge-/)
|
||||
assert.match(second, /^recharge-/)
|
||||
assert.notEqual(first, second)
|
||||
} finally {
|
||||
await cleanup()
|
||||
}
|
||||
})
|
||||
@@ -20,6 +20,17 @@ test('agent recharge rejection posts the rejection reason to the order rejection
|
||||
post(options) {
|
||||
calls.push(options)
|
||||
return Promise.resolve({ code: 0, data: undefined })
|
||||
},
|
||||
get(options) {
|
||||
calls.push(options)
|
||||
return Promise.resolve({
|
||||
code: 0,
|
||||
data: {
|
||||
methods: ['wechat', 'alipay'],
|
||||
min_amount: 10000,
|
||||
max_amount: 100000000
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
`,
|
||||
@@ -53,6 +64,8 @@ test('agent recharge rejection posts the rejection reason to the order rejection
|
||||
await AgentRechargeService.rejectAgentRecharge(42, {
|
||||
rejection_reason: '支付凭证不符合要求'
|
||||
})
|
||||
await AgentRechargeService.getPaymentMethods()
|
||||
await AgentRechargeService.getPaymentStatus(42)
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
{
|
||||
@@ -60,6 +73,14 @@ test('agent recharge rejection posts the rejection reason to the order rejection
|
||||
data: {
|
||||
rejection_reason: '支付凭证不符合要求'
|
||||
}
|
||||
},
|
||||
{
|
||||
url: '/api/admin/agent-recharges/payment-methods',
|
||||
params: undefined
|
||||
},
|
||||
{
|
||||
url: '/api/admin/agent-recharges/42/payment-status',
|
||||
params: undefined
|
||||
}
|
||||
])
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user