fix(editor): Schema view shows checkbox in case of empty data (#4889)

* fix(editor): Schema view show nothing in case of empty data

* fix(editor): Schema view test for empty data
This commit is contained in:
Csaba Tuncsik
2022-12-12 10:08:29 +01:00
committed by GitHub
parent 07b2f7678c
commit b0c158c64f
4 changed files with 75 additions and 49 deletions

View File

@@ -1,59 +1,69 @@
import { PiniaVuePlugin } from 'pinia';
import { createTestingPinia } from '@pinia/testing';
import { render } from '@testing-library/vue';
import { render, cleanup } from '@testing-library/vue';
import RunDataJsonSchema from '@/components/RunDataSchema.vue';
import { STORES } from "@/constants";
describe('RunDataJsonSchema.vue', () => {
it('renders json schema properly', () => {
const { container } = render(RunDataJsonSchema, {
pinia: createTestingPinia({
initialState: {
[STORES.SETTINGS]: {
settings: {
templates: {
enabled: true,
host: 'https://api.n8n.io/api/',
},
},
const renderOptions = {
pinia: createTestingPinia({
initialState: {
[STORES.SETTINGS]: {
settings: {
templates: {
enabled: true,
host: 'https://api.n8n.io/api/',
},
},
}),
stubs: ['font-awesome-icon'],
props: {
mappingEnabled: true,
distanceFromActive: 1,
runIndex: 1,
totalRuns: 2,
node: {
parameters: {
keepOnlySet: false,
values: {},
options: {},
},
id: '820ea733-d8a6-4379-8e73-88a2347ea003',
name: 'Set',
type: 'n8n-nodes-base.set',
typeVersion: 1,
position: [
380,
1060,
],
disabled: false,
},
data: [{ name: 'John', age: 22, hobbies: ['surfing', 'traveling'] }, { name: 'Joe', age: 33, hobbies: ['skateboarding', 'gaming'] }],
},
mocks: {
$locale: {
baseText() {
return '';
},
},
$store: {
getters: {},
},
},
},
}),
stubs: ['font-awesome-icon'],
props: {
mappingEnabled: true,
distanceFromActive: 1,
runIndex: 1,
totalRuns: 2,
node: {
parameters: {
keepOnlySet: false,
values: {},
options: {},
},
id: '820ea733-d8a6-4379-8e73-88a2347ea003',
name: 'Set',
type: 'n8n-nodes-base.set',
typeVersion: 1,
position: [
380,
1060,
],
disabled: false,
},
data: [{}],
},
mocks: {
$locale: {
baseText() {
return '';
},
},
},
};
beforeEach(cleanup);
it('renders schema for empty data', () => {
const { container } = render(RunDataJsonSchema, renderOptions,
vue => {
vue.use(PiniaVuePlugin);
});
expect(container).toMatchSnapshot();
});
it('renders schema for data', () => {
renderOptions.props.data = [{ name: 'John', age: 22, hobbies: ['surfing', 'traveling'] }, { name: 'Joe', age: 33, hobbies: ['skateboarding', 'gaming'] }];
const { container } = render(RunDataJsonSchema, renderOptions,
vue => {
vue.use(PiniaVuePlugin);
});