mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
test: Add snapshot for sublimeSearch and a first test (no-changelog) (#13794)
This commit is contained in:
13
packages/@n8n/utils/src/search/snapshots/README.md
Normal file
13
packages/@n8n/utils/src/search/snapshots/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Search snapshots
|
||||
|
||||
This directory contains snapshots containing real data fed into the sublimeSearch function.
|
||||
|
||||
These were obtained via `console.log(items)` right before the sublimeSearch call in `editor-ui` (currently in `packages/frontend/editor-ui/src/components/Node/NodeCreator/utils.ts`)
|
||||
Which is triggered by typing in the search bar in varying states of the application:
|
||||
|
||||
- toplevel: From an empty workflow (so missing e.g. tools)
|
||||
|
||||
|
||||
After typing in the search bar you should see an object in the console you can copy via `Right Click->Copy Object" which will cleanly paste to json.
|
||||
|
||||
**Please use Chrome for capturing these - the recovered object in Chrome is about 3x larger than in Firefox due to Firefox dropping some nested values**
|
||||
13255
packages/@n8n/utils/src/search/snapshots/toplevel.snapshot.json
Normal file
13255
packages/@n8n/utils/src/search/snapshots/toplevel.snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
21
packages/@n8n/utils/src/search/sublimeSearch.test.ts
Normal file
21
packages/@n8n/utils/src/search/sublimeSearch.test.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import topLevel from './snapshots/toplevel.snapshot.json';
|
||||
import { sublimeSearch } from './sublimeSearch';
|
||||
|
||||
describe('sublimeSearch', () => {
|
||||
const testCases = [{ filter: 'agent', expectedOrder: ['Magento 2', 'AI Agent'] }];
|
||||
|
||||
test.each(testCases)(
|
||||
'should return results in the correct order for filter "$filter"',
|
||||
({ filter, expectedOrder }) => {
|
||||
const results = sublimeSearch(filter, topLevel, [
|
||||
{ key: 'properties.displayName', weight: 1.3 },
|
||||
{ key: 'properties.codex.alias', weight: 1 },
|
||||
]);
|
||||
|
||||
const resultNames = results.map((result) => result.item.properties.displayName);
|
||||
expectedOrder.forEach((expectedName, index) => {
|
||||
expect(resultNames[index]).toBe(expectedName);
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user