fix: use native ERP product search

This commit is contained in:
inman committed 2026-09-02 19:29:04 +08:00
1 parent a618d3dd9f
commit b5c727b6f9
20 files changed
+289 -58

No files matched your search

+6 -6
View File
@@ -1296,7 +1296,7 @@ test('passenger explicit server success is terminal without a post-save row requ
assert.doesNotMatch(passengerBranch, /passengerRequery|verifyLifecycleOperation/);
assert.doesNotMatch(background, /attemptAutomaticPassengerReconciliation/);
assert.match(background, /名单已取得 ERP 明确成功响应,按业务规则确认录入成功/);
assert.match(platformApp, /REQUIRED_EXTENSION_VERSION = '0\.5\.164'/);
assert.match(platformApp, /REQUIRED_EXTENSION_VERSION = '0\.5\.165'/);
});
test('uncertain lifecycle writes can only converge through a read-only plugin requery', async () => {
@@ -1926,7 +1926,7 @@ test('delete guard distinguishes independent, shared child, and shared parent ro
for (const operation of operations) assert.equal(plans.validateOperation(operation).ok, true, plans.validateOperation(operation).blockers.join('; '));
const mapping = JSON.parse(await readFile(new URL('../mappings/lifecycle.mapping.json', import.meta.url), 'utf8'));
assert.equal(mapping.current_extension_version, '0.5.164');
assert.equal(mapping.current_extension_version, '0.5.165');
assert.equal(
mapping.updates.order_update_independent.field_mapped_pending_live_validation['pax.child_no_bed'],
'ertrenshu'
@@ -2309,10 +2309,10 @@ test('schema and browser adapters contain the v2 safety fields and no confirm ov
assert.match(inpage, /`ys_danweiid\$\{index\}`, resolvedCustomerId/);
assert.doesNotMatch(inpage, /product_customer_source_region|sourceRegionCheck|source_reference/);
assert.doesNotMatch(teamBatchInpage, /product_customer_source_region|sourceRegionCheck/);
assert.equal(extensionManifest.version, '0.5.164');
assert.match(inpage, /version: '0\.5\.164'/);
assert.match(teamBatchInpage, /version: '0\.5\.164'/);
assert.match(platformApp, /REQUIRED_EXTENSION_VERSION = '0\.5\.164'/);
assert.equal(extensionManifest.version, '0.5.165');
assert.match(inpage, /version: '0\.5\.165'/);
assert.match(teamBatchInpage, /version: '0\.5\.165'/);
assert.match(platformApp, /REQUIRED_EXTENSION_VERSION = '0\.5\.165'/);
assert.match(inpage, /function strictIsoDate\(value\)/);
assert.match(inpage, /const startDate = strictIsoDate\(controlCanonicalValue\(form, 'riqi0'\)\)/);
assert.match(inpage, /const endDate = strictIsoDate\(controlCanonicalValue\(form, 'riqis0'\)\)/);
+33
View File
@@ -1,6 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import { readFileSync } from 'node:fs';
const require = createRequire(import.meta.url);
const lookup = require('../chrome-extension/ltjt-order-assistant/product-lookup.js');
@@ -36,6 +37,38 @@ test('preserves numeric product names while matching a duration suffix', () => {
assert.equal(result.rule, 'unique_contiguous');
});
test('uses the complete ERP product name as the first native search query', () => {
const keyword = '全国散--八天--版纳动车拉邦进万象出';
assert.deepEqual(lookup.nativeProductSearchQueries(keyword), [keyword, '']);
const matches = lookup.matchProductCandidates([
candidate('live-target', '全国散--八天--版纳动车拉邦进万象出 8D7N')
], keyword);
assert.equal(matches.length, 1);
assert.equal(matches[0].cpid, 'live-target');
});
test('removes only a trailing numeric duration from the native name query', () => {
assert.deepEqual(lookup.nativeProductSearchQueries('江西老挝10D'), ['江西老挝', '']);
assert.deepEqual(lookup.nativeProductSearchQueries('老挝广东8天'), ['老挝广东', '']);
assert.deepEqual(
lookup.nativeProductSearchQueries('全国散--八天--版纳动车拉邦进万象出 8D7N'),
['全国散--八天--版纳动车拉邦进万象出', '']
);
assert.deepEqual(lookup.nativeProductSearchQueries('尊享老挝3.10'), ['尊享老挝3.10', '']);
});
test('both S_chanpinming order adapters execute the planned native queries', () => {
const sources = [
readFileSync(new URL('../chrome-extension/ltjt-order-assistant/inpage.js', import.meta.url), 'utf8'),
readFileSync(new URL('../chrome-extension/ltjt-order-assistant/team-batch-inpage.js', import.meta.url), 'utf8')
];
for (const source of sources) {
assert.match(source, /for \(const nativeQuery of nativeProductSearchQueries\(/u);
assert.match(source, /reloadProductsForLocalMatch\([^\n]+nativeQuery\)/u);
assert.match(source, /native_query_then_local/u);
}
});
test('keeps unique-match safety when multiple candidates satisfy a shorthand', () => {
const matches = lookup.matchProductCandidates([
candidate('401', '老挝广东 8D7N'),