import {N8NDemo} from '../n8n-demo.js';
import {fixture, assert} from '@open-wc/testing';
import {html} from 'lit/static-html.js';
suite('n8n-demo', () => {
test('is defined', () => {
const el = document.createElement('n8n-demo');
assert.instanceOf(el, N8NDemo);
});
test('renders with default values', async () => {
const el = await fixture(html``);
assert.shadowDom.equal(
el,
`
`
);
});
test('renders with theme', async () => {
const el = await fixture(html``);
assert.shadowDom.equal(
el,
`
`
);
});
test('renders with custom src', async () => {
const el = await fixture(
html``
);
assert.shadowDom.equal(
el,
`
`
);
});
test('renders with overlay and non-interactive canvas', async () => {
const el = await fixture(
html``
);
assert.shadowDom.equal(
el,
`
`
);
});
test('renders with frame', async () => {
const el = await fixture(html``);
assert.shadowDom.equal(
el,
`
💡 Double-click a node to see its settings, or paste
into n8n to import it
`
);
});
test('renders with frame, overlay and non-interactive canvas', async () => {
const el = await fixture(
html``
);
assert.shadowDom.equal(
el,
`
💡 Double-click a node to see its settings, or paste
into n8n to import it
`
);
});
test('expands json on click', async () => {
const el = (await fixture(
html``
)) as N8NDemo;
const button = el.shadowRoot!.querySelector('.embedded_tip > button')!;
if (button instanceof HTMLElement) {
button.click();
}
await el.updateComplete;
assert.shadowDom.equal(
el,
`
💡 Double-click a node to see its settings, or paste
into n8n to import it
`
);
});
test('handles invalid json when expanding', async () => {
const el = (await fixture(
html``
)) as N8NDemo;
const button = el.shadowRoot!.querySelector('.embedded_tip > button')!;
if (button instanceof HTMLElement) {
button.click();
}
await el.updateComplete;
assert.shadowDom.equal(
el,
`
💡 Double-click a node to see its settings, or paste
into n8n to import it
`
);
});
test('canvas is interactive after click ', async () => {
const el = (await fixture(
html``
)) as N8NDemo;
assert.shadowDom.equal(
el,
`
`
);
const button = el.shadowRoot!.querySelector('.overlay > button')!;
if (button instanceof HTMLElement) {
button.click();
}
await el.updateComplete;
assert.shadowDom.equal(
el,
`
`
);
});
test('when disableinteractivity=true renders with frame, overlay and non-interactive canvas', async () => {
const el = await fixture(
html``
);
assert.shadowDom.equal(
el,
`
💡 Double-click a node to see its settings, or paste
into n8n to import it
`
);
});
test('renders workflow correctly with escaped quotes', async () => {
const workflow = {nodes: [{ name: "\"test\""}]};
const el = (await fixture(
html``
)) as N8NDemo;
const button = el.shadowRoot!.querySelector('.embedded_tip > button')!;
if (button instanceof HTMLElement) {
button.click();
}
await el.updateComplete;
assert.shadowDom.equal(
el,
`
💡 Double-click a node to see its settings, or paste
into n8n to import it
Copy
{
"nodes": [
{
"name": "\\"test\\""
}
]
}
`
);
});
});