diff --git a/config/runtime.js b/config/runtime.js index 817b83b..c1edabb 100644 --- a/config/runtime.js +++ b/config/runtime.js @@ -1,6 +1,4 @@ -const configuredApiRoot = typeof import.meta !== 'undefined' - ? import.meta.env?.VITE_API_BASE_URL - : '' +const configuredApiRoot = import.meta.env.VITE_API_BASE_URL || '' export const API_ROOT = String(configuredApiRoot || '/api').replace(/\/$/, '') export const PLATFORM_API_ROOT = `${API_ROOT}/platform/v1` diff --git a/tests/page-contract.test.mjs b/tests/page-contract.test.mjs index f74c82f..7890cb5 100644 --- a/tests/page-contract.test.mjs +++ b/tests/page-contract.test.mjs @@ -23,7 +23,9 @@ test('application uses the Vue 3 uni-app entry and no unused Android permissions }) test('login uses the real auth endpoint and relaunches to the modular workbench', async () => { - const [login, auth, session] = await Promise.all([read('../pages/login/login.vue'), read('../api/auth.js'), read('../stores/session.js')]) + const [login, auth, session, runtime] = await Promise.all([ + read('../pages/login/login.vue'), read('../api/auth.js'), read('../stores/session.js'), read('../config/runtime.js') + ]) for (const text of ['柏悦物流 · PDA作业端', '工号 / 用户名', '登录中']) assert.match(login, new RegExp(text)) assert.doesNotMatch(login, /DEMO_ACCOUNTS|快捷登录|作业仓库/) assert.match(auth, /\/auth\/login/) @@ -31,6 +33,8 @@ test('login uses the real auth endpoint and relaunches to the modular workbench' assert.match(login, /signInWithTokens\(tokens\)/) assert.match(session, /pda-auth-session/) assert.match(session, /claims\.app_code !== 'PLATFORM'/) + assert.match(runtime, /import\.meta\.env\.VITE_API_BASE_URL/) + assert.doesNotMatch(runtime, /typeof\s+import\.meta/) assert.match(login, /uni\.reLaunch\(\{ url: '\/pages\/home\/home' \}\)/) })