Skip to content

Commit

Permalink
STSMACOM-799 - Make helpText prop as optional for all types of custom…
Browse files Browse the repository at this point in the history
… field components (#1432)

* STSMACOM-799 - Make helpText prop as optional for all types of custom field components

* STSMACOM-799 - add test for checkbox type custom field

* STSMACOM-799 - update unit test

* STSMACOM-799 - cleanup

* STSMACOM-799 - update tests

* STSMACOM-799 - updates tests

* STSMACOM-799 - add unit test

* STSMACOM-799 - update unit test
  • Loading branch information
Terala-Priyanka authored Jan 19, 2024
1 parent e46b4d6 commit fb4a2dc
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Export new `advancedSearchQueryToRows` helper to be used in Inventory app to reduce code duplication. Refs STSMACOM-787.
* Show the username in the "last updated" accordion in the Note editing pane. Fixes STSMACOM-748.
* Added `indexRef` and `inputRef` props to `<SearchAndSort>`. Refs STSMACOM-788.
* Extend NotesAccordion and NotesSmartAccodion components to accept a prop hideNewButton. Refs STSMACOM-789.
* Extend NotesAccordion and NotesSmartAccordion components to accept a prop hideNewButton. Refs STSMACOM-789.
* Extend `Tags` component to accept `mutateEntity` prop. Refs STSMACOM-792.
* Refactor CSS away from postcss-color-function. Refs STSMACOM-791.
* `<EditCustomFieldsSettings>` now passes the `entityType` when making PUT requests to `/custom-fields`. Refs FCFIELDS-44.
Expand All @@ -15,6 +15,7 @@
* Show successful toast notifications for Create and Edit actions in `<ControlledVocab>`. Refs STSMACOM-796.
* `<ControlledVocab>` - last updated by column - show "System" when items are created by system user. Refs STSMACOM-797.
* Add field type `DATE_PICKER` to custom fields components. Refs STSMACOM-800.
* Make `helpText` prop as optional for all types of custom field components. Refs STSMACOM-799.

## [9.0.0](https://github.com/folio-org/stripes-smart-components/tree/v9.0.0) (2023-10-11)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v8.0.0...v9.0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
} from './shared-values';

const propTypes = {
helpText: PropTypes.string.isRequired,
helpText: PropTypes.string,
name: PropTypes.string.isRequired,
};

const CheckboxSection = props => (
<Row>
<NameValue value={props.name} />
<HelpTextValue value={props.helpText} />
{ props.helpText && <HelpTextValue value={props.helpText} /> }
</Row>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from './shared-values';

const propTypes = {
helpText: PropTypes.string.isRequired,
helpText: PropTypes.string,
name: PropTypes.string.isRequired,
selectField: PropTypes.shape({
defaults: PropTypes.arrayOf(PropTypes.string),
Expand All @@ -29,7 +29,7 @@ const RadioButtonSetSections = ({
<>
<Row>
<NameValue value={name} />
<HelpTextValue value={helpText} />
{ helpText && <HelpTextValue value={helpText} /> }
</Row>
<Row>
<Options selectField={selectField} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { fieldTypes } from '../../../constants';

const propTypes = {
helpText: PropTypes.string.isRequired,
helpText: PropTypes.string,
name: PropTypes.string.isRequired,
required: PropTypes.bool.isRequired,
selectField: PropTypes.shape({
Expand All @@ -32,7 +32,7 @@ const SelectDropdownSection = props => {
<>
<Row>
<NameValue value={props.name} />
<HelpTextValue value={props.helpText} />
{ props.helpText && <HelpTextValue value={props.helpText} /> }
<RequiredValue value={props.required} />
</Row>
<Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {
} from './shared-values';

const propTypes = {
helpText: PropTypes.string.isRequired,
helpText: PropTypes.string,
name: PropTypes.string.isRequired,
required: PropTypes.bool.isRequired,
};

const TextboxSection = props => (
<Row>
<NameValue value={props.name} />
<HelpTextValue value={props.helpText} />
{ props.helpText && <HelpTextValue value={props.helpText} /> }
<RequiredValue value={props.required} />
</Row>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
const propTypes = { value: PropTypes.string.isRequired };

const HelpTextValue = ({ value }) => (
value.length
value?.length
? (
<Col data-test-custom-field-help-text xs={3}>
<KeyValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('EditCustomFieldsRecord', () => {
});

it('should show all visible custom fields', () => {
expect(editCustomFields.customFields().length).to.equal(6);
expect(editCustomFields.customFields().length).to.equal(7);
});

describe('when Single Select field has a default option', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ describe('EditCustomFieldsSettings', () => {
describe('when creating a custom field with options', () => {
beforeEach(async () => {
await editCustomFields.addFieldButton.selectCustomFieldType(2);
await editCustomFields.customFields(6).fillName('Test field');
await editCustomFields.customFields(6).options(0).fillOptionName('beta');
await editCustomFields.customFields(6).options(1).fillOptionName('alpha');
await editCustomFields.customFields(7).fillName('Test field');
await editCustomFields.customFields(7).options(0).fillOptionName('beta');
await editCustomFields.customFields(7).options(1).fillOptionName('alpha');
await editCustomFields.save();
});

Expand All @@ -237,7 +237,7 @@ describe('EditCustomFieldsSettings', () => {
const {
name,
selectField,
} = body.customFields[6];
} = body.customFields[7];

expect({ name, selectField }).to.deep.equal({
name: 'Test field',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('ViewCustomFieldsRecord', () => {
});

it('should display current number of fields', () => {
expect(viewCustomFields.fields().length).to.equal(6);
expect(viewCustomFields.fields().length).to.equal(7);
});

it('should display value for fields with a value', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,14 @@ describe('ViewCustomFieldsSettings', () => {
expect(disabledStates).to.deep.equal([true, true]);
});
});

describe('when custom field is checkbox', () => {
it('should display checkbox name', () => {
expect(viewCustomFields.customFields(6).fields(0).value).to.equal('Checkbox');
});

it('should not show help text section', () => {
expect(viewCustomFields.customFields(6).fields(1).value).to.equal('checkbox help text');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import MultiColumnListInteractor from '@folio/stripes-components/lib/MultiColumnList/tests/interactor';

export default interactor(class ViewCustomFieldsSettings {
customFields = collection('[data-test-accordion-section', {
customFields = collection('[data-test-accordion-section]', {
openAccordion: triggerable('[class^="defaultCollapseButton"]'),
fields: collection('[class^="col-"]', {
label: text('[class^="kvLabel--"]'),
Expand Down
16 changes: 15 additions & 1 deletion tests/network/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default function config() {
}
}
}, {
'id': '6',
'id':'6',
'name': 'Date',
'refId': 'date1',
'type': 'DATE_PICKER',
Expand All @@ -235,6 +235,20 @@ export default function config() {
'required': false,
'order': 6,
'helpText': 'Enter a date here',
}, {
'id': '7',
'name': 'Checkbox',
'refId': 'cb_1',
'type': 'SINGLE_CHECKBOX',
'entityType': 'user',
'visible': true,
'required': false,
'isRepeatable': false,
'order': 7,
'helpText': 'checkbox help text',
'checkboxField': {
'default': false
},
}],
});

Expand Down

0 comments on commit fb4a2dc

Please sign in to comment.