Skip to content

Commit

Permalink
Merge branch 'master' into addCarbonTelemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwarwick authored Mar 19, 2021
2 parents 203203e + d648859 commit 9f0893f
Show file tree
Hide file tree
Showing 21 changed files with 332 additions and 156 deletions.
8 changes: 8 additions & 0 deletions packages/cdai/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.1.4](https://github.com/carbon-design-system/ibm-cloud-cognitive/compare/@carbon/ibm-cloud-cognitive-cdai@1.1.3...@carbon/ibm-cloud-cognitive-cdai@1.1.4) (2021-03-19)

**Note:** Version bump only for package @carbon/ibm-cloud-cognitive-cdai





## [1.1.3](https://github.com/carbon-design-system/ibm-cloud-cognitive/compare/@carbon/ibm-cloud-cognitive-cdai@1.1.2...@carbon/ibm-cloud-cognitive-cdai@1.1.3) (2021-03-18)


Expand Down
2 changes: 1 addition & 1 deletion packages/cdai/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@carbon/ibm-cloud-cognitive-cdai",
"description": "Carbon for Cloud & Cognitive CD&AI UI components",
"version": "1.1.3",
"version": "1.1.4",
"license": "Apache-2.0",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/cdai/src/components/IdeButton/IdeButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const IdeButton = React.forwardRef(
IdeButton.displayName = 'IdeButton';

IdeButton.propTypes = {
children: PropTypes.element,
children: PropTypes.node,
className: PropTypes.string,
iconAnimation: PropTypes.string,
};
Expand Down
4 changes: 4 additions & 0 deletions packages/cdai/src/components/IdeCreate/ide-create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ it('should not click on a disabled step when usePreCheck is set', () => {
});

it('validate no label on pre-check step', () => {
const spy = jest.spyOn(console, 'error').mockImplementation();

let wrapper;
try {
wrapper = mount(
Expand All @@ -476,10 +478,12 @@ it('validate no label on pre-check step', () => {
</IdeCreate>
);
} catch (e) {
expect(spy).toBeCalled();
expect(e.message).toEqual(
'Error: label should not be set on first step when usePreCheck is set'
);
} finally {
spy.mockRestore(); // Remove mock
if (wrapper) {
wrapper.unmount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const baseComponent = (props = {}) =>
const prefix = (value) => `test-prefix-${value}`;

describe('<IdeDataTable>', () => {
beforeAll(() => {
// ignore the required complaints coming out of DataTable
global.console = { warn: jest.fn(), error: jest.fn(), log: jest.fn() };
});

let componentUnderTest;

afterEach(() => {
Expand Down
17 changes: 10 additions & 7 deletions packages/cdai/src/components/IdeFilter/IdeFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,25 @@ const formatOptionLabel = (option, context, allOptions) => {
);
};

const parseTypeProps = (propsData) =>
!propsData.type || propsData.type === 'filter'
? { filter: true }
: { type: propsData.type };

// custom components
const MultiValueContainer = (props) => (
<Tag
type={props.data.type || 'filter'}
className={`${idePrefix}-filter--tag`}>
<Tag {...parseTypeProps(props.data)} className={`${idePrefix}-filter--tag`}>
{props.children}
</Tag>
);
const MultiValueRemove = (props) => {
const type = props.data.type || 'filter';
const typeProps = parseTypeProps(props.data);
return (
<button
type="button"
{...props.innerProps}
className={`${idePrefix}-filter--close${
type === 'filter'
typeProps.filter
? ` ${idePrefix}-filter--tag-filter`
: /* istanbul ignore next */ ''
}`}>
Expand Down Expand Up @@ -249,11 +252,11 @@ MultiValueRemove.propTypes = {
data: PropTypes.shape({
type: PropTypes.string,
}),
innerProps: PropTypes.node,
innerProps: PropTypes.object,
};

ClearIndicator.propTypes = {
innerProps: PropTypes.node,
innerProps: PropTypes.object,
};

export default IdeFilter;
34 changes: 26 additions & 8 deletions packages/cdai/src/components/IdeFilter/IdeFilter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ describe('IdeFilter', () => {
]}
/>
);
expect(wrapper.find('.ide-filter--tag').at(0).props().type).toEqual(
'filter'
);
expect(wrapper.find('.ide-filter--tag').at(0).props().filter).toEqual(true);
});
it('Renders options in menu', () => {
const wrapper = mount(
Expand Down Expand Up @@ -119,20 +117,28 @@ describe('IdeFilter', () => {
it('isLoading passed to component', () => {
const isLoading = true;
const wrapper = mount(
<IdeFilter options={options} menuIsOpen isLoading={isLoading} />
<IdeFilter
options={options}
menuIsOpen
isLoading={isLoading}
onChange={() => {}}
/>
);
const select = wrapper.find('.ide-filter--select').at(0);
expect(select.props().isLoading).toEqual(true);
});
it('isLoading false by default', () => {
const wrapper = mount(<IdeFilter options={options} menuIsOpen />);
const wrapper = mount(
<IdeFilter options={options} menuIsOpen onChange={() => {}} />
);
const select = wrapper.find('.ide-filter--select').at(0);
expect(select.props().isLoading).toEqual(false);
});
it('allowCreateWhileLoading passed to component', () => {
const allowCreateWhileLoading = false;
const wrapper = mount(
<IdeFilter
onChange={() => {}}
options={options}
menuIsOpen
allowCreateWhileLoading={allowCreateWhileLoading}
Expand All @@ -142,21 +148,33 @@ describe('IdeFilter', () => {
expect(select.props().allowCreateWhileLoading).toEqual(false);
});
it('allowCreateWhileLoading true by default', () => {
const wrapper = mount(<IdeFilter options={options} menuIsOpen />);
const wrapper = mount(
<IdeFilter onChange={() => {}} options={options} menuIsOpen />
);
const select = wrapper.find('.ide-filter--select').at(0);
expect(select.props().allowCreateWhileLoading).toEqual(true);
});
it('loadingMessage passed to component', () => {
const loadingMessage = jest.fn();
const wrapper = mount(
<IdeFilter options={options} menuIsOpen loadingMessage={loadingMessage} />
<IdeFilter
onChange={() => {}}
options={options}
menuIsOpen
loadingMessage={loadingMessage}
/>
);
const select = wrapper.find('.ide-filter--select').at(0);
expect(select.props().loadingMessage).toBe(loadingMessage);
});
it('searchForText passed to component', () => {
const wrapper = mount(
<IdeFilter options={options} menuIsOpen searchForText={'custom text'} />
<IdeFilter
onChange={() => {}}
options={options}
menuIsOpen
searchForText={'custom text'}
/>
);
const select = wrapper.find('.ide-filter--select').at(0);
expect(select.props().formatCreateLabel()).toContain('custom text');
Expand Down
9 changes: 9 additions & 0 deletions packages/cdai/src/components/IdeImporting/IdeImporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export default class IdeImporting extends React.Component {

this.handleFilesAdded = this.handleFilesAdded.bind(this);
}
componentDidMount() {
this.mounted = true;
}
componentWillUnmount() {
this.mounted = false;
}
countFiles() {
return countFiles(this.state.filesToUpload);
}
Expand Down Expand Up @@ -111,13 +117,16 @@ export default class IdeImporting extends React.Component {
);
}
async handleFileAdded(fileToUpload) {
if (!this.mounted) return;

if (fileToUpload.invalid) return;

try {
this.updateFileToUploadState(fileToUpload.uuid, {
status: FILE_UPLOAD_STATUS.UPLOADING,
});
await this.props.onFileAdded(fileToUpload);
if (!this.mounted) return;
if (
this.props.allowValidFileEditing ||
this.props.enableUpload === false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,10 @@ class IdeImportingWrapper {
// see https://airbnb.io/enzyme/docs/api/ReactWrapper/update.html
this.wrapper.update();
}
printDebug() {
// eslint-disable-next-line no-console
console.error(this.wrapper.debug());
}
strictFind(selector) {
const found = this.wrapper.find(selector);
if (found.length === 0) {
let name = typeof selector === 'string' ? selector : selector.name;
this.printDebug();
throw new Error(`${name} not found when using strictFind()`);
}
return found;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import { IdeSlideOverPanel } from '../IdeSlideOverPanel';
import { shallow } from 'enzyme';
import CloseIcon16 from '@carbon/icons-react/lib/close/16';

const requiredProps = { onClose: () => {} };

describe('IdeSlideOverPanel', () => {
describe('Renders common props as expected', () => {
const wrapper = shallow(
<IdeSlideOverPanel className="extra-class">
<IdeSlideOverPanel {...requiredProps} className="extra-class">
<div className="child">child</div>
<div className="child">child</div>
</IdeSlideOverPanel>
Expand All @@ -30,7 +32,7 @@ describe('IdeSlideOverPanel', () => {

describe('Renders the provided title', () => {
const wrapper = shallow(
<IdeSlideOverPanel title="Foo"></IdeSlideOverPanel>
<IdeSlideOverPanel {...requiredProps} title="Foo"></IdeSlideOverPanel>
);

it('Renders a header containing the provided title', () => {
Expand All @@ -40,12 +42,14 @@ describe('IdeSlideOverPanel', () => {

describe('Honours the open property', () => {
const openWrapper = shallow(
<IdeSlideOverPanel open={true}></IdeSlideOverPanel>
<IdeSlideOverPanel {...requiredProps} open={true}></IdeSlideOverPanel>
);
const closedWrapper = shallow(
<IdeSlideOverPanel open={false}></IdeSlideOverPanel>
<IdeSlideOverPanel {...requiredProps} open={false}></IdeSlideOverPanel>
);
const defaultWrapper = shallow(
<IdeSlideOverPanel {...requiredProps}></IdeSlideOverPanel>
);
const defaultWrapper = shallow(<IdeSlideOverPanel></IdeSlideOverPanel>);

it('Renders open when open is true', () => {
expect(openWrapper.find('.ide-slide-over-panel--open')).toHaveLength(1);
Expand All @@ -63,15 +67,17 @@ describe('IdeSlideOverPanel', () => {
});

describe('Honours the size property', () => {
const defaultWrapper = shallow(<IdeSlideOverPanel></IdeSlideOverPanel>);
const defaultWrapper = shallow(
<IdeSlideOverPanel {...requiredProps}></IdeSlideOverPanel>
);
const smallWrapper = shallow(
<IdeSlideOverPanel size="small"></IdeSlideOverPanel>
<IdeSlideOverPanel {...requiredProps} size="small"></IdeSlideOverPanel>
);
const mediumWrapper = shallow(
<IdeSlideOverPanel size="medium"></IdeSlideOverPanel>
<IdeSlideOverPanel {...requiredProps} size="medium"></IdeSlideOverPanel>
);
const largeWrapper = shallow(
<IdeSlideOverPanel size="large"></IdeSlideOverPanel>
<IdeSlideOverPanel {...requiredProps} size="large"></IdeSlideOverPanel>
);

it('Supports a small size', () => {
Expand Down Expand Up @@ -176,6 +182,7 @@ describe('IdeSlideOverPanel', () => {
describe('Renders the controls', () => {
const wrapper = shallow(
<IdeSlideOverPanel
{...requiredProps}
controls
primaryButtonText="Primary Button"
secondaryButtonText="Secondary Button"></IdeSlideOverPanel>
Expand All @@ -194,6 +201,7 @@ describe('IdeSlideOverPanel', () => {
it('renders primary button as danger, when set', () => {
const wrapper = shallow(
<IdeSlideOverPanel
{...requiredProps}
danger
controls
primaryButtonText="Primary Button"
Expand Down Expand Up @@ -221,6 +229,7 @@ describe('IdeSlideOverPanel', () => {
it('are merged correctly', () => {
const wrapper = shallow(
<IdeSlideOverPanel
{...requiredProps}
controls
withOverlay
primaryButtonText="Primary Button"
Expand All @@ -240,6 +249,7 @@ describe('IdeSlideOverPanel', () => {
it('override defaults correctly', () => {
const wrapper = shallow(
<IdeSlideOverPanel
{...requiredProps}
controls
withOverlay
primaryButtonText="Primary Button"
Expand Down
16 changes: 16 additions & 0 deletions packages/cloud-cognitive/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.1.119](https://github.com/carbon-design-system/ibm-cloud-cognitive/compare/@carbon/ibm-cloud-cognitive@0.1.118...@carbon/ibm-cloud-cognitive@0.1.119) (2021-03-18)

**Note:** Version bump only for package @carbon/ibm-cloud-cognitive





## [0.1.118](https://github.com/carbon-design-system/ibm-cloud-cognitive/compare/@carbon/ibm-cloud-cognitive@0.1.117...@carbon/ibm-cloud-cognitive@0.1.118) (2021-03-18)

**Note:** Version bump only for package @carbon/ibm-cloud-cognitive





## [0.1.117](https://github.com/carbon-design-system/ibm-cloud-cognitive/compare/@carbon/ibm-cloud-cognitive@0.1.116...@carbon/ibm-cloud-cognitive@0.1.117) (2021-03-18)

**Note:** Version bump only for package @carbon/ibm-cloud-cognitive
Expand Down
2 changes: 1 addition & 1 deletion packages/cloud-cognitive/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@carbon/ibm-cloud-cognitive",
"description": "Carbon for Cloud & Cognitive common UI components",
"version": "0.1.117",
"version": "0.1.119",
"license": "Apache-2.0",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
16 changes: 16 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.8.24](https://github.com/carbon-design-system/ibm-cloud-cognitive/compare/@carbon/ibm-cloud-cognitive-core@0.8.23...@carbon/ibm-cloud-cognitive-core@0.8.24) (2021-03-18)

**Note:** Version bump only for package @carbon/ibm-cloud-cognitive-core





## [0.8.23](https://github.com/carbon-design-system/ibm-cloud-cognitive/compare/@carbon/ibm-cloud-cognitive-core@0.8.22...@carbon/ibm-cloud-cognitive-core@0.8.23) (2021-03-18)

**Note:** Version bump only for package @carbon/ibm-cloud-cognitive-core





## [0.8.22](https://github.com/carbon-design-system/ibm-cloud-cognitive/compare/@carbon/ibm-cloud-cognitive-core@0.8.21...@carbon/ibm-cloud-cognitive-core@0.8.22) (2021-03-18)

**Note:** Version bump only for package @carbon/ibm-cloud-cognitive-core
Expand Down
Loading

0 comments on commit 9f0893f

Please sign in to comment.