2026-09-01 11:38:42 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
|
|
|
|
|
const read = (name) => readFileSync(new URL(name, import.meta.url), 'utf8')
|
|
|
|
|
const client = read('./client-test-env-acceptance.mjs')
|
|
|
|
|
const clientPhase2 = read('./client-phase2-test-env-acceptance.mjs')
|
|
|
|
|
const pendingOrders = read('./create-pending-review-orders.mjs')
|
2026-09-01 14:27:04 +08:00
|
|
|
const readme = read('./README.md')
|
|
|
|
|
const agents = read('./AGENTS.md')
|
2026-09-01 11:38:42 +08:00
|
|
|
|
|
|
|
|
const activeHttpScripts = [client, clientPhase2, pendingOrders]
|
|
|
|
|
const removedEnvironmentVariables = [
|
|
|
|
|
'CLIENT_TEST_GATEWAY', 'CLIENT_PHASE2_TEST_GATEWAY',
|
|
|
|
|
'PLATFORM_USERNAME', 'PLATFORM_PASSWORD',
|
|
|
|
|
'EXISTING_CLIENT_USERNAME', 'EXISTING_CLIENT_PASSWORD',
|
|
|
|
|
'CLIENT_PHASE2_USERNAME', 'CLIENT_PHASE2_PASSWORD',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
test('active Client and data-generation scripts share the canonical environment variables', () => {
|
|
|
|
|
for (const source of activeHttpScripts) {
|
|
|
|
|
assert.match(source, /process\.env\.ADMIN_TEST_GATEWAY/)
|
|
|
|
|
assert.match(source, /process\.env\.MERCHANT_TEST_USERNAME/)
|
|
|
|
|
assert.match(source, /process\.env\.MERCHANT_TEST_PASSWORD/)
|
|
|
|
|
}
|
|
|
|
|
assert.match(client, /process\.env\.ADMIN_TEST_USERNAME/)
|
|
|
|
|
assert.match(client, /process\.env\.ADMIN_TEST_PASSWORD/)
|
|
|
|
|
assert.match(clientPhase2, /process\.env\.ADMIN_TEST_USERNAME/)
|
|
|
|
|
assert.match(clientPhase2, /process\.env\.ADMIN_TEST_PASSWORD/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('active scripts no longer carry the retired variables, fixed Gateway, or source password config', () => {
|
|
|
|
|
for (const source of activeHttpScripts) {
|
|
|
|
|
for (const variable of removedEnvironmentVariables) assert.doesNotMatch(source, new RegExp(`process\\.env\\.${variable}`))
|
|
|
|
|
assert.doesNotMatch(source, /8\.163\.30\.128/)
|
|
|
|
|
}
|
|
|
|
|
assert.doesNotMatch(pendingOrders, /const CONFIG\s*=/)
|
|
|
|
|
assert.doesNotMatch(pendingOrders, /PASSWORD:\s*'[^']+'/)
|
|
|
|
|
})
|
2026-09-01 14:27:04 +08:00
|
|
|
|
2026-10-03 06:26:33 +08:00
|
|
|
test('TEST documentation requires explicit selection and keeps development configuration in its own instructions', () => {
|
2026-09-01 14:27:04 +08:00
|
|
|
for (const source of [readme, agents]) {
|
|
|
|
|
assert.match(source, /chongchong-global-test-acceptance\.env/)
|
|
|
|
|
assert.match(source, /--env-file/)
|
|
|
|
|
}
|
2026-10-03 06:26:33 +08:00
|
|
|
assert.match(agents, /chongchong-global-dev-acceptance\.env/)
|
2026-09-01 14:27:04 +08:00
|
|
|
assert.match(readme, /不会自行查找或加载上述文件/)
|
|
|
|
|
assert.match(readme, /ADMIN_OVERSEAS_GATEWAY/)
|
2026-10-03 06:26:33 +08:00
|
|
|
assert.match(readme, /移除环境文件中的 `ADMIN_OVERSEAS_GATEWAY`/)
|
2026-09-01 14:27:04 +08:00
|
|
|
})
|