Skip to content

Commit

Permalink
fix(editor): Update and add design system checkbox component to Editor (
Browse files Browse the repository at this point in the history
#6178)

* fix(editor): Update and add design system checkbox component to Editor

* test(editor): Test Checkbox design system component
  • Loading branch information
cstuncsik authored May 5, 2023
1 parent b0a1899 commit 13c143e
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
:value="value"
@change="onChange"
>
<slot></slot>
<n8n-input-label
v-if="label"
:label="label"
:tooltipText="tooltipText"
:bold="false"
Expand All @@ -32,15 +34,13 @@ export default defineComponent({
props: {
label: {
type: String,
required: true,
},
disabled: {
type: Boolean,
default: false,
},
tooltipText: {
type: String,
required: false,
},
indeterminate: {
type: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { render } from '@testing-library/vue';
import N8nCheckbox from '../Checkbox.vue';

describe('components', () => {
describe('N8nCheckbox', () => {
it('should render without label and child content', () => {
const { container } = render(N8nCheckbox);
expect(container).toMatchSnapshot();
});

it('should render with label', () => {
const { container } = render(N8nCheckbox, { props: { label: 'Checkbox' } });
expect(container).toMatchSnapshot();
});

it('should render with child', () => {
const { container } = render(N8nCheckbox, {
slots: { default: '<strong>Bold text</strong>' },
});
expect(container).toMatchSnapshot();
});

it('should render with both child and label', () => {
const { container } = render(N8nCheckbox, {
props: { label: 'Checkbox' },
slots: { default: '<strong>Bold text</strong>' },
});
expect(container).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// Vitest Snapshot v1

exports[`components > N8nCheckbox > should render with both child and label 1`] = `
<div>
<label
class="el-checkbox n8n-checkbox n8nCheckbox"
labelsize="medium"
>
<span
class="el-checkbox__input"
>
<span
class="el-checkbox__inner"
/>
<input
aria-hidden="false"
class="el-checkbox__original"
type="checkbox"
value="Checkbox"
/>
</span>
<span
class="el-checkbox__label"
>
<strong>
Bold text
</strong>
<div
class="container"
>
<label
class="n8n-input-label inputLabel heading medium"
>
<div
class="title"
>
<span
class="n8n-text size-medium regular"
>
Checkbox
<!---->
</span>
</div>
<!---->
<!---->
<!---->
</label>
</div>
<!---->
</span>
</label>
</div>
`;

exports[`components > N8nCheckbox > should render with child 1`] = `
<div>
<label
class="el-checkbox n8n-checkbox n8nCheckbox"
labelsize="medium"
>
<span
class="el-checkbox__input"
>
<span
class="el-checkbox__inner"
/>
<input
aria-hidden="false"
class="el-checkbox__original"
type="checkbox"
value=""
/>
</span>
<span
class="el-checkbox__label"
>
<strong>
Bold text
</strong>
<!---->
<!---->
</span>
</label>
</div>
`;

exports[`components > N8nCheckbox > should render with label 1`] = `
<div>
<label
class="el-checkbox n8n-checkbox n8nCheckbox"
labelsize="medium"
>
<span
class="el-checkbox__input"
>
<span
class="el-checkbox__inner"
/>
<input
aria-hidden="false"
class="el-checkbox__original"
type="checkbox"
value="Checkbox"
/>
</span>
<span
class="el-checkbox__label"
>
<div
class="container"
>
<label
class="n8n-input-label inputLabel heading medium"
>
<div
class="title"
>
<span
class="n8n-text size-medium regular"
>
Checkbox
<!---->
</span>
</div>
<!---->
<!---->
<!---->
</label>
</div>
<!---->
</span>
</label>
</div>
`;

exports[`components > N8nCheckbox > should render without label and child content 1`] = `
<div>
<label
class="el-checkbox n8n-checkbox n8nCheckbox"
labelsize="medium"
>
<span
class="el-checkbox__input"
>
<span
class="el-checkbox__inner"
/>
<input
aria-hidden="false"
class="el-checkbox__original"
type="checkbox"
value=""
/>
</span>
<!---->
</label>
</div>
`;
1 change: 1 addition & 0 deletions packages/design-system/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ export { default as N8nUserSelect } from './N8nUserSelect';
export { default as N8nUsersList } from './N8nUsersList';
export { default as N8nResizeWrapper } from './N8nResizeWrapper';
export { default as N8nRecycleScroller } from './N8nRecycleScroller';
export { default as N8nCheckbox } from './N8nCheckbox';
2 changes: 2 additions & 0 deletions packages/design-system/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
N8nUsersList,
N8nResizeWrapper,
N8nRecycleScroller,
N8nCheckbox,
} from './components';

export const N8nPlugin: PluginObject<{}> = {
Expand Down Expand Up @@ -103,5 +104,6 @@ export const N8nPlugin: PluginObject<{}> = {
app.component('n8n-user-select', N8nUserSelect);
app.component('n8n-resize-wrapper', N8nResizeWrapper);
app.component('n8n-recycle-scroller', N8nRecycleScroller);
app.component('n8n-checkbox', N8nCheckbox);
},
};

0 comments on commit 13c143e

Please sign in to comment.