From 7a9ecd0b8df11c9eab5e41e45e84563f35f0d1e1 Mon Sep 17 00:00:00 2001 From: wangliang Date: Fri, 23 Oct 2026 15:02:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(bridge):=20=E5=95=86=E5=93=81=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E6=8C=89=E7=AB=99=E7=82=B9=E5=B8=81=E7=A7=8D=E8=BF=94?= =?UTF-8?q?=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridge/config/sites.json | 3 +++ bridge/src/config.js | 2 +- bridge/test/tools.test.js | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/bridge/config/sites.json b/bridge/config/sites.json index 7259608..e35e498 100644 --- a/bridge/config/sites.json +++ b/bridge/config/sites.json @@ -5,6 +5,7 @@ "www": { "site": "www", "tenantId": 2, + "currencyCode": "EUR", "searchUrl": "https://www.yehwang.com/search.html?q=", "siteMap": "site-map.json", "language": "en" @@ -12,6 +13,7 @@ "us": { "site": "us", "tenantId": 2, + "currencyCode": "USD", "searchUrl": "https://us.yehwang.com/search.html?q=", "siteMap": "site-map-us.json", "language": "en" @@ -19,6 +21,7 @@ "eu": { "site": "www", "tenantId": 2, + "currencyCode": "EUR", "searchUrl": "https://www.yehwang.com/search.html?q=", "siteMap": "site-map.json", "language": "en" diff --git a/bridge/src/config.js b/bridge/src/config.js index e748064..7486c06 100644 --- a/bridge/src/config.js +++ b/bridge/src/config.js @@ -8,7 +8,7 @@ function loadSites(env) { const fallback = { defaultSite: 'www', profiles: { - www: { site: 'www', tenantId: null, languageId: null, currencyCode: 'USD', searchUrl: 'https://www.yehwang.com/search.html?q=', siteMap: 'site-map.json' }, + www: { site: 'www', tenantId: null, languageId: null, currencyCode: 'EUR', searchUrl: 'https://www.yehwang.com/search.html?q=', siteMap: 'site-map.json' }, }, inboxes: {}, }; diff --git a/bridge/test/tools.test.js b/bridge/test/tools.test.js index f7e9561..ee06b37 100644 --- a/bridge/test/tools.test.js +++ b/bridge/test/tools.test.js @@ -569,3 +569,30 @@ test('create_opportunity: creates opportunity + note + follow-up task', async () const personIdx = twenty.calls.findIndex((c) => c[0] === 'createPerson'); assert.ok(companyIdx >= 0 && personIdx > companyIdx, 'company must be created before person'); }); + +test('sites.json: www/eu -> EUR, us -> USD', () => { + const sites = require('../config/sites.json'); + assert.equal(sites.profiles.www.currencyCode, 'EUR'); + assert.equal(sites.profiles.eu.currencyCode, 'EUR'); + assert.equal(sites.profiles.us.currencyCode, 'USD'); +}); + +test('search_products: passes the site currency to the product RPC', async () => { + const rpc = fakeRpc(() => []); + const cfg = { + ...baseCfg, + sites: { + defaultSite: 'www', + profiles: { www: { site: 'www', tenantId: 2, languageId: 1, currencyCode: 'EUR', searchUrl: 'https://www.yehwang.com/search.html?q=' } }, + inboxes: { '1': 'www' }, + }, + }; + const tools = createTools(cfg, { rpc, twenty: fakeTwenty() }); + const tool = tools.find((t) => t.name === 'search_products'); + await tool.handler({ query: 'rings' }, { inboxId: '1' }); + const call = rpc.calls[0]; + assert.equal(call.method, '/product/list'); + assert.equal(call.params[0].currencyCode, 'EUR'); + assert.equal(call.params[0].tenantBaseCurrency, 'EUR'); + assert.equal(call.params[0].reqContext.currencyCode, 'EUR'); +});