mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
fix(editor): Make search work for "rendered" display type (#16910)
This commit is contained in:
@@ -46,6 +46,29 @@ describe('RunDataParsedAiContent', () => {
|
||||
expect(rendered.getByText('markdown', { selector: 'em' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('highlight matches to the search keyword in markdown', () => {
|
||||
const rendered = renderComponent({
|
||||
renderType: 'rendered',
|
||||
content: [
|
||||
{
|
||||
raw: {},
|
||||
parsedContent: {
|
||||
type: 'markdown',
|
||||
data: 'The **quick** brown fox jumps over the ~~lazy~~ dog',
|
||||
parsed: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
search: 'the',
|
||||
});
|
||||
|
||||
const marks = rendered.container.querySelectorAll('mark');
|
||||
|
||||
expect(marks).toHaveLength(2);
|
||||
expect(marks[0]).toHaveTextContent('The');
|
||||
expect(marks[1]).toHaveTextContent('the');
|
||||
});
|
||||
|
||||
it('renders AI content parsed as JSON', () => {
|
||||
const rendered = renderComponent({
|
||||
renderType: 'rendered',
|
||||
@@ -71,4 +94,83 @@ describe('RunDataParsedAiContent', () => {
|
||||
rendered.getByText('{ "key": "value" }', { selector: 'code', exact: false }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('highlight matches to the search keyword in inline code in markdown', () => {
|
||||
const rendered = renderComponent({
|
||||
renderType: 'rendered',
|
||||
content: [
|
||||
{
|
||||
raw: {},
|
||||
parsedContent: {
|
||||
type: 'markdown',
|
||||
data: 'The `quick brown fox` jumps over the lazy dog',
|
||||
parsed: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
search: 'fox',
|
||||
});
|
||||
|
||||
const marks = rendered.container.querySelectorAll('mark');
|
||||
|
||||
expect(marks).toHaveLength(1);
|
||||
expect(marks[0]).toHaveTextContent('fox');
|
||||
});
|
||||
|
||||
it('highlight matches to the search keyword in a code block in markdown', () => {
|
||||
const rendered = renderComponent({
|
||||
renderType: 'rendered',
|
||||
content: [
|
||||
{
|
||||
raw: {},
|
||||
parsedContent: {
|
||||
type: 'markdown',
|
||||
data: 'Code:\n\n quickFox.jump({ over: lazyDog });\n',
|
||||
parsed: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
search: 'fox',
|
||||
});
|
||||
|
||||
const marks = rendered.container.querySelectorAll('mark');
|
||||
|
||||
expect(marks).toHaveLength(1);
|
||||
expect(marks[0]).toHaveTextContent('Fox');
|
||||
});
|
||||
|
||||
it('highlight matches to the search keyword in fence syntax in markdown', () => {
|
||||
const rendered = renderComponent({
|
||||
renderType: 'rendered',
|
||||
content: [
|
||||
{
|
||||
raw: {},
|
||||
parsedContent: {
|
||||
type: 'markdown',
|
||||
data: '```\nquickFox.jump({ over: lazyDog });\n```',
|
||||
parsed: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
search: 'fox',
|
||||
});
|
||||
|
||||
const marks = rendered.container.querySelectorAll('mark');
|
||||
|
||||
expect(marks).toHaveLength(1);
|
||||
expect(marks[0]).toHaveTextContent('Fox');
|
||||
});
|
||||
|
||||
it('highlight matches to the search keyword in raw data', () => {
|
||||
const rendered = renderComponent({
|
||||
renderType: 'rendered',
|
||||
content: [{ raw: { key: 'value' }, parsedContent: null }],
|
||||
search: 'key',
|
||||
});
|
||||
|
||||
const marks = rendered.container.querySelectorAll('mark');
|
||||
|
||||
expect(marks).toHaveLength(1);
|
||||
expect(marks[0]).toHaveTextContent('key');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user