Skip to content

Commit

Permalink
Remove classnames and dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
mutuajames committed Jun 30, 2023
1 parent 13362f9 commit f84152e
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 648 deletions.
409 changes: 0 additions & 409 deletions me.txt

This file was deleted.

2 changes: 0 additions & 2 deletions new

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@ const CareTeamForm: React.FC<CareTeamFormProps> = (props: CareTeamFormProps) =>
<Form.Item
name={name}
id="name"
className="name"
label={t('Name')}
rules={[{ required: true, message: t('Name is Required') }]}
>
<Input />
</Form.Item>

<Form.Item id="status" className="status" name={status} label={t('Status')}>
<Form.Item id="status" name={status} label={t('Status')}>
<Radio.Group name="status">
{statusOptions.map((e) => (
<Radio name="status" key={e.label} value={e.value}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('components/forms/CreateTeamForm', () => {

wrapper.update();
// name is required and has no default
expect(wrapper.find('.ant-form-item.name').text()).toMatchInlineSnapshot(
expect(wrapper.find('#name .ant-form-item').text()).toMatchInlineSnapshot(
`"NameName is Required"`
);
wrapper.unmount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ test('filter select by text able to create new careteam', async () => {

// simulate active change
wrapper
.find('.ant-form-item.status input')
.find('#status .ant-form-item input')
.first()
.simulate('change', {
target: { checked: true },
});

// simulate name change
wrapper
.find('.ant-form-item.name input')
.find('#name .ant-form-item input')
.simulate('change', { target: { name: 'name', value: 'Care team 1' } });

// simulate value selection for type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,16 @@ const CommodityForm = (props: GroupFormProps) => {
}}
initialValues={initialValues}
>
<FormItem hidden={true} className="id" id="id" name={id} label={t('Commodity Id')}>
<FormItem hidden={true} id="id" name={id} label={t('Commodity Id')}>
<Input placeholder={t('(Auto generated)')} disabled={true} />
</FormItem>

<FormItem
hidden={true}
className="identifier"
id="identifier"
name={identifier}
label={t('Identifier')}
>
<FormItem hidden={true} id="identifier" name={identifier} label={t('Identifier')}>
<Input placeholder={t('(Auto generated)')} disabled={true} />
</FormItem>

<FormItem
id={name}
className="name"
name={name}
rules={validationRules[name]}
label={t('Enter Commodity name')}
Expand All @@ -123,7 +116,6 @@ const CommodityForm = (props: GroupFormProps) => {

<FormItem
id={active}
className="active"
rules={validationRules[active]}
name={active}
label={t('Select Commodity status')}
Expand All @@ -133,7 +125,6 @@ const CommodityForm = (props: GroupFormProps) => {

<FormItem
id={type}
className="type"
name={type}
rules={validationRules[type]}
label={t('Select Commodity Type')}
Expand All @@ -148,7 +139,6 @@ const CommodityForm = (props: GroupFormProps) => {
</FormItem>

<FormItem
className="unitOfMeasure"
id={unitOfMeasure}
name={unitOfMeasure}
rules={validationRules[unitOfMeasure]}
Expand All @@ -165,17 +155,10 @@ const CommodityForm = (props: GroupFormProps) => {

<FormItem {...tailLayout}>
<Space>
<Button
type="primary"
id="submit-button"
className="submit-button"
disabled={isLoading}
htmlType="submit"
>
<Button type="primary" id="submit-button" disabled={isLoading} htmlType="submit">
{isLoading ? t('Saving') : t('save')}
</Button>
<Button
className="cancel-button"
id="cancel-button"
onClick={() => {
goTo(cancelUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,40 @@ describe('Health care form', () => {
wrapper.update();
});

expect(toJson(wrapper.find('.ant-form-item.id label'))).toMatchSnapshot('id label');
expect(toJson(wrapper.find('.ant-form-item.id input'))).toMatchSnapshot('id field');
expect(toJson(wrapper.find('#id .ant-form-item label'))).toMatchSnapshot('id label');
expect(toJson(wrapper.find('#id .ant-form-item input'))).toMatchSnapshot('id field');

expect(toJson(wrapper.find('.ant-form-item.identifier label'))).toMatchSnapshot(
expect(toJson(wrapper.find('#identifier .ant-form-item label'))).toMatchSnapshot(
'identifier label'
);
expect(toJson(wrapper.find('.ant-form-item.identifier input'))).toMatchSnapshot(
expect(toJson(wrapper.find('#identifier .ant-form-item input'))).toMatchSnapshot(
'identifier field'
);

expect(toJson(wrapper.find('.ant-form-item.name label'))).toMatchSnapshot('name label');
expect(toJson(wrapper.find('.ant-form-item.name input'))).toMatchSnapshot('name field');
expect(toJson(wrapper.find('#name .ant-form-item label'))).toMatchSnapshot('name label');
expect(toJson(wrapper.find('#name .ant-form-item input'))).toMatchSnapshot('name field');

expect(toJson(wrapper.find('.ant-form-item.active label').first())).toMatchSnapshot(
expect(toJson(wrapper.find('#active .ant-form-item label').first())).toMatchSnapshot(
'active label'
);
expect(toJson(wrapper.find('.ant-form-item.active input'))).toMatchSnapshot('active field');
expect(toJson(wrapper.find('#active .ant-form-item input'))).toMatchSnapshot('active field');

expect(toJson(wrapper.find('.ant-form-item.type label').first())).toMatchSnapshot('type label');
expect(toJson(wrapper.find('.ant-form-item.type input#type'))).toMatchSnapshot('type field');
expect(toJson(wrapper.find('#type .ant-form-item label').first())).toMatchSnapshot(
'type label'
);
expect(toJson(wrapper.find('#type .ant-form-item input#type'))).toMatchSnapshot('type field');

expect(toJson(wrapper.find('.ant-form-item.unitOfMeasure label').first())).toMatchSnapshot(
expect(toJson(wrapper.find('#unitOfMeasure .ant-form-item label').first())).toMatchSnapshot(
'unit of measure label'
);
expect(toJson(wrapper.find('.ant-form-item.unitOfMeasure input'))).toMatchSnapshot(
expect(toJson(wrapper.find('#unitOfMeasure .ant-form-item input'))).toMatchSnapshot(
'unit of measure field'
);

expect(toJson(wrapper.find('.submit-button button'))).toMatchSnapshot('submit button');
expect(toJson(wrapper.find('.cancel-button button'))).toMatchSnapshot('cancel button');
expect(toJson(wrapper.find('#submit-button button'))).toMatchSnapshot('submit button');
expect(toJson(wrapper.find('#cancel-button button'))).toMatchSnapshot('cancel button');

wrapper.find('button.cancel-button').simulate('click');
wrapper.find('button#cancel-button').simulate('click');
wrapper.unmount();
});

Expand Down Expand Up @@ -205,15 +207,15 @@ describe('Health care form', () => {

// simulate active change
wrapper
.find('.ant-form-item.active input')
.find('#active .ant-form-item input')
.first()
.simulate('change', {
target: { checked: true },
});

// simulate name change
wrapper
.find('.ant-form-item.name input')
.find('#name .ant-form-item input')
.simulate('change', { target: { name: 'name', value: 'Dettol' } });

// simulate value selection for type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`Health care form renders correctly: active label 1`] = `

exports[`Health care form renders correctly: cancel button 1`] = `
<button
className="ant-btn css-dev-only-do-not-override-k7429z ant-btn-default cancel-button"
className="ant-btn css-dev-only-do-not-override-k7429z ant-btn-default"
disabled={false}
id="cancel-button"
onClick={[Function]}
Expand Down Expand Up @@ -147,7 +147,7 @@ exports[`Health care form renders correctly: name label 1`] = `

exports[`Health care form renders correctly: submit button 1`] = `
<button
className="ant-btn css-dev-only-do-not-override-k7429z ant-btn-primary submit-button"
className="ant-btn css-dev-only-do-not-override-k7429z ant-btn-primary"
disabled={false}
id="submit-button"
onClick={[Function]}
Expand Down Expand Up @@ -266,7 +266,7 @@ exports[`Health care form renders correctly: unit of measure label 1`] = `

exports[`Health care form submits new group: asd 1`] = `
<div
className="ant-form-item type css-dev-only-do-not-override-k7429z"
className="ant-form-item css-dev-only-do-not-override-k7429z"
>
<Row
className="ant-form-item-row"
Expand All @@ -277,7 +277,7 @@ exports[`Health care form submits new group: asd 1`] = `
style={Object {}}
>
<FormItemLabel
className="type css-dev-only-do-not-override-k7429z"
className="css-dev-only-do-not-override-k7429z"
errors={Array []}
fieldId="type"
htmlFor="type"
Expand Down Expand Up @@ -352,7 +352,7 @@ exports[`Health care form submits new group: asd 1`] = `
</Col>
</FormItemLabel>
<FormItemInput
className="type css-dev-only-do-not-override-k7429z"
className="css-dev-only-do-not-override-k7429z"
errors={Array []}
fieldId="type"
id="type"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,15 @@ const HealthCareForm = (props: HealthCareFormProps) => {
<Input disabled={true} />
</FormItem>

<FormItem
id="name"
name={name}
className="name"
rules={validationRules.name}
label={t('Name')}
>
<FormItem id="name" name={name} rules={validationRules.name} label={t('Name')}>
<Input disabled={disabled.includes(name)} placeholder={t('Name')} />
</FormItem>

<FormItem
id="active"
className="active"
rules={validationRules.active}
name={active}
label={t('Status')}
>
<FormItem id="active" rules={validationRules.active} name={active} label={t('Status')}>
<Radio.Group disabled={disabled.includes(active)} options={statusOptions}></Radio.Group>
</FormItem>

<FormItem
id="comment"
className="comment"
rules={validationRules.comment}
name={comment}
label={t('Comment')}
>
<FormItem id="comment" rules={validationRules.comment} name={comment} label={t('Comment')}>
<Input.TextArea
disabled={disabled.includes(comment)}
rows={2}
Expand All @@ -134,7 +116,6 @@ const HealthCareForm = (props: HealthCareFormProps) => {
</FormItem>

<FormItem
className="extraDetails"
id="extraDetails"
rules={validationRules.extraDetails}
name={extraDetails}
Expand All @@ -148,7 +129,6 @@ const HealthCareForm = (props: HealthCareFormProps) => {
</FormItem>

<FormItem
className="providedBy"
id="providedBy"
name={providedBy}
rules={validationRules.providedBy}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,25 @@ describe('Health care form', () => {
wrapper.update();
});

expect(toJson(wrapper.find('.ant-form-item.name label'))).toMatchSnapshot('name label');
expect(toJson(wrapper.find('.ant-form-item.name input'))).toMatchSnapshot('name field');
expect(toJson(wrapper.find('#name .ant-form-item label'))).toMatchSnapshot('name label');
expect(toJson(wrapper.find('#name .ant-form-item input'))).toMatchSnapshot('name field');

expect(toJson(wrapper.find('.ant-form-item.active label').first())).toMatchSnapshot(
expect(toJson(wrapper.find('#active .ant-form-item label').first())).toMatchSnapshot(
'active label'
);
expect(toJson(wrapper.find('.ant-form-item.active input'))).toMatchSnapshot('active field');
expect(toJson(wrapper.find('#active .ant-form-item input'))).toMatchSnapshot('active field');

expect(toJson(wrapper.find('.ant-form-item.comment label').first())).toMatchSnapshot(
expect(toJson(wrapper.find('#comment .ant-form-item label').first())).toMatchSnapshot(
'comment label'
);
expect(toJson(wrapper.find('.ant-form-item.comment textarea'))).toMatchSnapshot(
expect(toJson(wrapper.find('#comment .ant-form-item textarea'))).toMatchSnapshot(
'comment field'
);

expect(toJson(wrapper.find('.ant-form-item.extra-details label').first())).toMatchSnapshot(
expect(toJson(wrapper.find('#extra-details .ant-form-item label').first())).toMatchSnapshot(
'extraDetails label'
);
expect(toJson(wrapper.find('.ant-form-item.extra-details textarea'))).toMatchSnapshot(
expect(toJson(wrapper.find('#extra-details .ant-form-item textarea'))).toMatchSnapshot(
'extraDetails field'
);

Expand Down Expand Up @@ -155,23 +155,23 @@ describe('Health care form', () => {
});

// name is required and has no default
expect(wrapper.find('.ant-form-item.name').text()).toMatchInlineSnapshot(`"NameRequired"`);
expect(wrapper.find('#name .ant-form-item').text()).toMatchInlineSnapshot(`"NameRequired"`);

// comment is not required required and has no default
expect(wrapper.find('.ant-form-item.comment').text()).toMatchInlineSnapshot(`"Comment"`);
expect(wrapper.find('#comment .ant-form-item').text()).toMatchInlineSnapshot(`"Comment"`);

// status has no
expect(wrapper.find('.ant-form-item.active').text()).toMatchInlineSnapshot(
expect(wrapper.find('#active .ant-form-item').text()).toMatchInlineSnapshot(
`"StatusInactiveactiveRequired"`
);

// not required
expect(wrapper.find('.ant-form-item.extraDetails').text()).toMatchInlineSnapshot(
expect(wrapper.find('#extraDetails .ant-form-item').text()).toMatchInlineSnapshot(
`"Extra details"`
);

// not required?
expect(wrapper.find('.ant-form-item.providedBy').text()).toMatchSnapshot(
expect(wrapper.find('#providedBy .ant-form-item').text()).toMatchSnapshot(
`"Practitioners Select user (practitioners only)"`
);

Expand Down Expand Up @@ -329,12 +329,12 @@ describe('Health care form', () => {

// simulate name change
wrapper
.find('.ant-form-item.name input')
.find('#name .ant-form-item input')
.simulate('change', { target: { name: 'name', value: 'Medieval healers' } });

// simulate active check to be active
wrapper
.find('.ant-form-item.active input')
.find('#active .ant-form-item input')
.first()
.simulate('change', {
target: { checked: true },
Expand All @@ -352,7 +352,7 @@ describe('Health care form', () => {
fireEvent.click(document.querySelector('[title="Test Team 4"]'));

wrapper
.find('.ant-form-item.comment textarea')
.find('#comment .ant-form-item textarea')
.simulate('change', { target: { name: 'alias', value: 'Eat shrubs' } });

await flushPromises();
Expand Down
Loading

0 comments on commit f84152e

Please sign in to comment.