test: Add snapshot for sublimeSearch and a first test (no-changelog) (#13794)

This commit is contained in:
Charlie Kolb
2025-04-14 11:56:11 +02:00
committed by GitHub
parent e1246ab65c
commit 00038be81a
5 changed files with 13293 additions and 2 deletions

View 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**

File diff suppressed because it is too large Load Diff

View 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);
});
},
);
});