fix(bridge): 商品价格按站点币种返回

This commit is contained in:
wangliang
2026-10-23 15:02:26 +08:00
parent 751d9d63cd
commit 7a9ecd0b8d
3 changed files with 31 additions and 1 deletions
+27
View File
@@ -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');
});