@open-mercato/search 0.7.1-develop.7194.1.ab4fc81f82 → 0.7.1-develop.7200.1.8ba2d93d3f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/search",
|
|
3
|
-
"version": "0.7.1-develop.
|
|
3
|
+
"version": "0.7.1-develop.7200.1.8ba2d93d3f",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -127,9 +127,9 @@
|
|
|
127
127
|
"zod": "^4.4.3"
|
|
128
128
|
},
|
|
129
129
|
"peerDependencies": {
|
|
130
|
-
"@open-mercato/core": "0.7.1-develop.
|
|
131
|
-
"@open-mercato/queue": "0.7.1-develop.
|
|
132
|
-
"@open-mercato/shared": "0.7.1-develop.
|
|
130
|
+
"@open-mercato/core": "0.7.1-develop.7200.1.8ba2d93d3f",
|
|
131
|
+
"@open-mercato/queue": "0.7.1-develop.7200.1.8ba2d93d3f",
|
|
132
|
+
"@open-mercato/shared": "0.7.1-develop.7200.1.8ba2d93d3f"
|
|
133
133
|
},
|
|
134
134
|
"devDependencies": {
|
|
135
135
|
"@types/jest": "^30.0.0",
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
1
3
|
import { formatEntityId, resolveEntityTypeLabel } from '../entityTypeLabel'
|
|
2
4
|
import type { TranslateFn } from '@open-mercato/shared/lib/i18n/context'
|
|
3
5
|
|
|
6
|
+
function loadModuleDictionary(relativeI18nDir: string): Record<string, string> {
|
|
7
|
+
const filePath = path.join(__dirname, relativeI18nDir, 'en.json')
|
|
8
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'))
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
describe('formatEntityId', () => {
|
|
5
12
|
it('humanizes module · entity', () => {
|
|
6
13
|
expect(formatEntityId('customers:customer_person_profile')).toBe('Customers · Customer Person Profile')
|
|
@@ -23,3 +30,33 @@ describe('resolveEntityTypeLabel', () => {
|
|
|
23
30
|
expect(resolveEntityTypeLabel(t, 'thirdparty:widget_thing')).toBe('Thirdparty · Widget Thing')
|
|
24
31
|
})
|
|
25
32
|
})
|
|
33
|
+
|
|
34
|
+
// Regression coverage for https://github.com/open-mercato/open-mercato/issues/6006:
|
|
35
|
+
// wms, eudr and documents shipped no `search.entityType.<module>.<entity>` keys,
|
|
36
|
+
// so their chips silently fell back to a humanized id instead of the real label.
|
|
37
|
+
// This loads each module's real `en.json` (not a mock) so a missing/renamed key
|
|
38
|
+
// fails here instead of only being visible in the rendered UI.
|
|
39
|
+
describe('resolveEntityTypeLabel against the real module dictionaries', () => {
|
|
40
|
+
const merged: Record<string, string> = {
|
|
41
|
+
...loadModuleDictionary('../../../../../../../core/src/modules/wms/i18n'),
|
|
42
|
+
...loadModuleDictionary('../../../../../../../core/src/modules/eudr/i18n'),
|
|
43
|
+
...loadModuleDictionary('../../../../../../../documents/src/modules/documents/i18n'),
|
|
44
|
+
}
|
|
45
|
+
const t: TranslateFn = (key, fallbackOrParams) =>
|
|
46
|
+
key in merged ? merged[key] : (typeof fallbackOrParams === 'string' ? fallbackOrParams : key)
|
|
47
|
+
|
|
48
|
+
it.each([
|
|
49
|
+
['wms:warehouse', 'Warehouse'],
|
|
50
|
+
['wms:warehouse_location', 'Location'],
|
|
51
|
+
['wms:product_inventory_profile', 'Inventory profile'],
|
|
52
|
+
['wms:inventory_lot', 'Inventory lot'],
|
|
53
|
+
['eudr:eudr_due_diligence_statement', 'DDS statement'],
|
|
54
|
+
['eudr:eudr_plot', 'Plot'],
|
|
55
|
+
['eudr:eudr_evidence_submission', 'Evidence submission'],
|
|
56
|
+
['documents:document', 'Document'],
|
|
57
|
+
])('resolves %s to its localized label, not a humanized fallback', (entityId, expectedLabel) => {
|
|
58
|
+
const resolved = resolveEntityTypeLabel(t, entityId)
|
|
59
|
+
expect(resolved).toBe(expectedLabel)
|
|
60
|
+
expect(resolved).not.toBe(formatEntityId(entityId))
|
|
61
|
+
})
|
|
62
|
+
})
|