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') const readme = read('./README.md') const agents = read('./AGENTS.md') 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*'[^']+'/) }) test('documentation names both external environment files and requires explicit selection', () => { for (const source of [readme, agents]) { assert.match(source, /chongchong-global-dev-acceptance\.env/) assert.match(source, /chongchong-global-test-acceptance\.env/) assert.match(source, /--env-file/) } assert.match(readme, /不会自行查找或加载上述文件/) assert.match(readme, /ADMIN_OVERSEAS_GATEWAY/) })