Skip to content

Commit 08b517f

Browse files
committed
[#81] PR feedback
1 parent ad293b5 commit 08b517f

File tree

6 files changed

+43
-36
lines changed

6 files changed

+43
-36
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102

103103
- name: Run tests
104104
run: |
105-
npm run test-jest
105+
npm run test:jest
106106
env:
107107
CI: 'true'
108108

@@ -148,7 +148,7 @@ jobs:
148148
cd storybook-static/ && tar -xvf artifact.tar && cd ..
149149
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
150150
"npx http-server storybook-static --port 6006 --quiet" \
151-
"npx wait-on -l http://127.0.0.1:6006 && npm test -- --browsers ${{ matrix.browser }}"
151+
"npx wait-on -l http://127.0.0.1:6006 && npm run test:storybook -- --browsers ${{ matrix.browser }}"
152152
153153
deploy:
154154
runs-on: ubuntu-latest

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
"build:esm": "ttsc -p tsconfig.prod.json && tsc-alias -p tsconfig.prod.json",
1919
"build:cjs": "ttsc -p tsconfig.prod.json --module commonjs --outDir lib/cjs && tsc-alias -p tsconfig.prod.json --outDir lib/cjs",
2020
"build": "npm-run-all build:*",
21-
"test": "test-storybook",
22-
"test-jest": "jest",
21+
"test": "npm-run-all test:*",
22+
"test:storybook": "test-storybook",
23+
"test:jest": "jest",
2324
"format": "prettier --write 'src/**/*'",
2425
"checkformat": "prettier --check 'src/**/*'",
2526
"start": "npm run storybook",

src/components/ComponentEditForm.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ export interface ComponentEditFormProps {
2727
// don't know (yet), so we need to handle FallbackSchema.
2828
component: AnyComponentSchema | FallbackSchema;
2929
builderInfo: BuilderInfo;
30-
onCancel?: (e: React.MouseEvent<HTMLButtonElement>) => void;
31-
onRemove?: (e: React.MouseEvent<HTMLButtonElement>) => void;
32-
onSubmit?: (component: AnyComponentSchema | FallbackSchema) => void;
30+
onCancel: (e: React.MouseEvent<HTMLButtonElement>) => void;
31+
onRemove: (e: React.MouseEvent<HTMLButtonElement>) => void;
32+
onSubmit: (component: AnyComponentSchema | FallbackSchema) => void;
3333
}
3434

3535
const ComponentEditForm: React.FC<ComponentEditFormProps> = ({
3636
isNew,
3737
component,
3838
builderInfo,
39-
onCancel = () => {},
40-
onRemove = () => {},
41-
onSubmit = () => {},
39+
onCancel,
40+
onRemove,
41+
onSubmit,
4242
}) => {
4343
const intl = useIntl();
4444
const builderContext = useContext(BuilderContext);

src/registry/select/select-validation.spec.tsx

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,38 @@ import ComponentEditForm from '@/components/ComponentEditForm';
44
import {contextRender, screen} from '@/test-utils';
55

66
describe('Manual values: must have at least one non-empty value', () => {
7-
const args = {
8-
isNew: true,
9-
component: {
10-
id: 'wqimsadk',
11-
type: 'select',
12-
key: 'select',
13-
label: 'A select field',
14-
openForms: {
15-
dataSrc: 'manual',
16-
translations: {},
17-
},
18-
values: [{value: '', label: ''}],
19-
defaultValue: '',
20-
},
21-
builderInfo: {
22-
title: 'Select',
23-
icon: 'th-list',
24-
group: 'basic',
25-
weight: 70,
26-
schema: {},
7+
const component = {
8+
id: 'wqimsadk',
9+
type: 'select',
10+
key: 'select',
11+
label: 'A select field',
12+
openForms: {
13+
dataSrc: 'manual',
14+
translations: {},
2715
},
16+
values: [{value: '', label: ''}],
17+
defaultValue: '',
18+
};
19+
const builderInfo = {
20+
title: 'Select',
21+
icon: 'th-list',
22+
group: 'basic',
23+
weight: 70,
24+
schema: {},
2825
};
29-
30-
contextRender(<ComponentEditForm {...args} />);
3126

3227
test('Option values and labels are required fields', async () => {
28+
contextRender(
29+
<ComponentEditForm
30+
isNew
31+
component={component}
32+
builderInfo={builderInfo}
33+
onCancel={jest.fn()}
34+
onRemove={jest.fn()}
35+
onSubmit={jest.fn()}
36+
/>
37+
);
38+
3339
const labelInput = screen.getByLabelText('Option label');
3440
await userEvent.type(labelInput, 'Foo');
3541
await userEvent.clear(labelInput);

src/test-utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ const contextRender = (
207207
builderOptions: Partial<BuilderOptions> = {},
208208
renderOptions: RenderOptions = {}
209209
): RenderResult => {
210-
function Wrapper({children}: {children: React.ReactElement}) {
210+
function Wrapper({children}: {children: React.ReactNode}) {
211211
return (
212212
<IntlProvider locale={locale}>
213213
{!enableContext ? (

tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"noErrorTruncation": true,
2121
"paths": {
2222
"@/*": ["./*"],
23-
"@/sb-decorators": ["../.storybook/decorators.tsx"],
23+
"@/sb-decorators": ["../.storybook/decorators.tsx"]
2424
},
2525
"plugins": [
2626
{
@@ -31,8 +31,8 @@
3131
"ast": true
3232
}
3333
],
34-
"types": ["node", "jest", "@testing-library/jest-dom"],
34+
"types": ["node", "jest", "@testing-library/jest-dom"]
3535
},
3636
"include": ["src"],
37-
"exclude": ["node_modules", "lib"],
37+
"exclude": ["node_modules", "lib"]
3838
}

0 commit comments

Comments
 (0)