Upgrade EUI to v14.9.0 (#49678)

* eui to 14.9.0

* euiswitch updtates

* misc snapshot

* x-pack functional fixes

* more euiswitch functional test fixes

* label-less switches for spaces management

* more euiswitch fixes

* telemetry form a11y

* snapshot update

* label updates

* more switch updates

* lint
This commit is contained in:
Greg Thompson 2019-11-13 14:54:21 -06:00 committed by GitHub
parent 1010f285b3
commit 998b0e6fd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 542 additions and 435 deletions

View file

@ -109,7 +109,7 @@
"@elastic/charts": "^14.0.0", "@elastic/charts": "^14.0.0",
"@elastic/datemath": "5.0.2", "@elastic/datemath": "5.0.2",
"@elastic/ems-client": "1.0.5", "@elastic/ems-client": "1.0.5",
"@elastic/eui": "14.8.0", "@elastic/eui": "14.9.0",
"@elastic/filesaver": "1.1.2", "@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana2", "@elastic/good": "8.1.1-kibana2",
"@elastic/numeral": "2.3.3", "@elastic/numeral": "2.3.3",

View file

@ -30,6 +30,7 @@ import {
EuiPopoverTitle, EuiPopoverTitle,
EuiSpacer, EuiSpacer,
EuiSwitch, EuiSwitch,
EuiSwitchEvent,
} from '@elastic/eui'; } from '@elastic/eui';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
@ -431,7 +432,7 @@ class FilterEditorUI extends Component<Props, State> {
this.setState({ selectedOperator, params }); this.setState({ selectedOperator, params });
}; };
private onCustomLabelSwitchChange = (event: React.ChangeEvent<HTMLInputElement>) => { private onCustomLabelSwitchChange = (event: EuiSwitchEvent) => {
const useCustomLabel = event.target.checked; const useCustomLabel = event.target.checked;
const customLabel = event.target.checked ? '' : null; const customLabel = event.target.checked ? '' : null;
this.setState({ useCustomLabel, customLabel }); this.setState({ useCustomLabel, customLabel });

View file

@ -236,7 +236,7 @@ test('handleCheckboxOptionChange - multiselect', async () => {
component.update(); component.update();
const checkbox = findTestSubject(component, 'listControlMultiselectInput'); const checkbox = findTestSubject(component, 'listControlMultiselectInput');
checkbox.simulate('change', { target: { checked: true } }); checkbox.simulate('click');
sinon.assert.notCalled(handleFieldNameChange); sinon.assert.notCalled(handleFieldNameChange);
sinon.assert.notCalled(handleIndexPatternChange); sinon.assert.notCalled(handleIndexPatternChange);
sinon.assert.notCalled(handleNumberOptionChange); sinon.assert.notCalled(handleNumberOptionChange);
@ -247,7 +247,9 @@ test('handleCheckboxOptionChange - multiselect', async () => {
expectedControlIndex, expectedControlIndex,
expectedOptionName, expectedOptionName,
sinon.match((evt) => { sinon.match((evt) => {
if (evt.target.checked === true) { // Synthetic `evt.target.checked` does not get altered by EuiSwitch,
// but its aria attribute is correctly updated
if (evt.target.getAttribute('aria-checked') === 'true') {
return true; return true;
} }
return false; return false;

View file

@ -47,8 +47,8 @@ describe('OptionsTab', () => {
it('should update updateFiltersOnChange', () => { it('should update updateFiltersOnChange', () => {
const component = mountWithIntl(<OptionsTab {...props} />); const component = mountWithIntl(<OptionsTab {...props} />);
const checkbox = component.find('[data-test-subj="inputControlEditorUpdateFiltersOnChangeCheckbox"] input[type="checkbox"]'); const checkbox = component.find('[data-test-subj="inputControlEditorUpdateFiltersOnChangeCheckbox"] button');
checkbox.simulate('change', { target: { checked: true } }); checkbox.simulate('click');
expect(props.setValue).toHaveBeenCalledTimes(1); expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('updateFiltersOnChange', true); expect(props.setValue).toHaveBeenCalledWith('updateFiltersOnChange', true);
@ -56,8 +56,8 @@ describe('OptionsTab', () => {
it('should update useTimeFilter', () => { it('should update useTimeFilter', () => {
const component = mountWithIntl(<OptionsTab {...props} />); const component = mountWithIntl(<OptionsTab {...props} />);
const checkbox = component.find('[data-test-subj="inputControlEditorUseTimeFilterCheckbox"] input[type="checkbox"]'); const checkbox = component.find('[data-test-subj="inputControlEditorUseTimeFilterCheckbox"] button');
checkbox.simulate('change', { target: { checked: true } }); checkbox.simulate('click');
expect(props.setValue).toHaveBeenCalledTimes(1); expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('useTimeFilter', true); expect(props.setValue).toHaveBeenCalledWith('useTimeFilter', true);
@ -65,8 +65,8 @@ describe('OptionsTab', () => {
it('should update pinFilters', () => { it('should update pinFilters', () => {
const component = mountWithIntl(<OptionsTab {...props} />); const component = mountWithIntl(<OptionsTab {...props} />);
const checkbox = component.find('[data-test-subj="inputControlEditorPinFiltersCheckbox"] input[type="checkbox"]'); const checkbox = component.find('[data-test-subj="inputControlEditorPinFiltersCheckbox"] button');
checkbox.simulate('change', { target: { checked: true } }); checkbox.simulate('click');
expect(props.setValue).toHaveBeenCalledTimes(1); expect(props.setValue).toHaveBeenCalledTimes(1);
expect(props.setValue).toHaveBeenCalledWith('pinFilters', true); expect(props.setValue).toHaveBeenCalledWith('pinFilters', true);

View file

@ -121,7 +121,7 @@ describe('DiscoverFieldSearch', () => {
// @ts-ignore // @ts-ignore
(aggregtableButtonGroup.props() as EuiButtonGroupProps).onChange('aggregatable-true', null); (aggregtableButtonGroup.props() as EuiButtonGroupProps).onChange('aggregatable-true', null);
}); });
missingSwitch.simulate('change', { target: { value: false } }); missingSwitch.simulate('click');
expect(onChange).toBeCalledTimes(2); expect(onChange).toBeCalledTimes(2);
}); });

View file

@ -29,6 +29,7 @@ import {
EuiPopoverTitle, EuiPopoverTitle,
EuiSelect, EuiSelect,
EuiSwitch, EuiSwitch,
EuiSwitchEvent,
EuiForm, EuiForm,
EuiFormRow, EuiFormRow,
EuiButtonGroup, EuiButtonGroup,
@ -154,7 +155,7 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) {
setActiveFiltersCount(activeFiltersCount + diff); setActiveFiltersCount(activeFiltersCount + diff);
}; };
const handleMissingChange = (e: React.ChangeEvent<HTMLInputElement>) => { const handleMissingChange = (e: EuiSwitchEvent) => {
const missingValue = e.target.checked; const missingValue = e.target.checked;
handleValueChange('missing', missingValue); handleValueChange('missing', missingValue);
}; };

View file

@ -34,6 +34,7 @@ exports[`TelemetryForm renders as expected when allows to change optIn status 1`
save={[Function]} save={[Function]}
setting={ setting={
Object { Object {
"ariaName": "Provide usage statistics",
"defVal": false, "defVal": false,
"description": <React.Fragment> "description": <React.Fragment>
<p> <p>

View file

@ -33,6 +33,7 @@ import { getConfigTelemetryDesc, PRIVACY_STATEMENT_URL } from '../../common/cons
import { OptInExampleFlyout } from './opt_in_details_component'; import { OptInExampleFlyout } from './opt_in_details_component';
import { Field } from 'ui/management'; import { Field } from 'ui/management';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
const SEARCH_TERMS = ['telemetry', 'usage', 'data', 'usage data']; const SEARCH_TERMS = ['telemetry', 'usage', 'data', 'usage data'];
@ -117,6 +118,7 @@ export class TelemetryForm extends Component {
value: telemetryOptInProvider.getOptIn() || false, value: telemetryOptInProvider.getOptIn() || false,
description: this.renderDescription(), description: this.renderDescription(),
defVal: false, defVal: false,
ariaName: i18n.translate('telemetry.provideUsageStatisticsLabel', { defaultMessage: 'Provide usage statistics' })
}} }}
save={this.toggleOptIn} save={this.toggleOptIn}
clear={this.toggleOptIn} clear={this.toggleOptIn}

View file

@ -23,7 +23,7 @@ import { EuiSwitch, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { AggParamEditorProps } from '..'; import { AggParamEditorProps } from '..';
function AutoPrecisionParamEditor({ value, setValue }: AggParamEditorProps<boolean>) { function AutoPrecisionParamEditor({ value = false, setValue }: AggParamEditorProps<boolean>) {
const label = i18n.translate('common.ui.aggTypes.changePrecisionLabel', { const label = i18n.translate('common.ui.aggTypes.changePrecisionLabel', {
defaultMessage: 'Change precision on map zoom', defaultMessage: 'Change precision on map zoom',
}); });

View file

@ -30,7 +30,7 @@ interface SwitchParamEditorProps extends AggParamEditorProps<boolean> {
} }
function SwitchParamEditor({ function SwitchParamEditor({
value, value = false,
setValue, setValue,
dataTestSubj, dataTestSubj,
displayToolTip, displayToolTip,

View file

@ -23,7 +23,7 @@ import { EuiSwitch, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
import { AggParamEditorProps } from '..'; import { AggParamEditorProps } from '..';
function UseGeocentroidParamEditor({ value, setValue }: AggParamEditorProps<boolean>) { function UseGeocentroidParamEditor({ value = false, setValue }: AggParamEditorProps<boolean>) {
const label = i18n.translate('common.ui.aggTypes.placeMarkersOffGridLabel', { const label = i18n.translate('common.ui.aggTypes.placeMarkersOffGridLabel', {
defaultMessage: 'Place markers off grid (use geocentroid)', defaultMessage: 'Place markers off grid (use geocentroid)',
}); });

View file

@ -173,7 +173,7 @@ test('Can set title to an empty string', async () => {
); );
const inputField = findTestSubject(component, 'customizePanelHideTitle'); const inputField = findTestSubject(component, 'customizePanelHideTitle');
inputField.simulate('change'); inputField.simulate('click');
findTestSubject(component, 'saveNewTitleButton').simulate('click'); findTestSubject(component, 'saveNewTitleButton').simulate('click');
expect(inputField.props().value).toBeUndefined(); expect(inputField.props().value).toBeUndefined();

View file

@ -18,7 +18,7 @@
*/ */
import React from 'react'; import React from 'react';
import { EuiFormRow, EuiSwitch } from '@elastic/eui'; import { EuiFormRow, EuiSwitch, EuiSwitchEvent } from '@elastic/eui';
import { FieldHook } from '../../hook_form_lib'; import { FieldHook } from '../../hook_form_lib';
import { getFieldValidityAndErrorMessage } from '../helpers'; import { getFieldValidityAndErrorMessage } from '../helpers';
@ -33,6 +33,14 @@ interface Props {
export const ToggleField = ({ field, euiFieldProps = {}, ...rest }: Props) => { export const ToggleField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field); const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);
// Shim for sufficient overlap between EuiSwitchEvent and FieldHook[onChange] event
const onChange = (e: EuiSwitchEvent) => {
const event = ({ ...e, value: `${e.target.checked}` } as unknown) as React.ChangeEvent<{
value: string;
}>;
field.onChange(event);
};
return ( return (
<EuiFormRow <EuiFormRow
helpText={field.helpText} helpText={field.helpText}
@ -45,7 +53,7 @@ export const ToggleField = ({ field, euiFieldProps = {}, ...rest }: Props) => {
<EuiSwitch <EuiSwitch
label={field.label} label={field.label}
checked={field.value as boolean} checked={field.value as boolean}
onChange={field.onChange} onChange={onChange}
data-test-subj="input" data-test-subj="input"
{...euiFieldProps} {...euiFieldProps}
/> />

View file

@ -32,6 +32,7 @@ import {
EuiOverlayMask, EuiOverlayMask,
EuiSpacer, EuiSpacer,
EuiSwitch, EuiSwitch,
EuiSwitchEvent,
EuiTextArea, EuiTextArea,
} from '@elastic/eui'; } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react';
@ -227,7 +228,7 @@ export class SavedObjectSaveModal extends React.Component<Props, State> {
}); });
}; };
private onCopyOnSaveChange = (event: React.ChangeEvent<HTMLInputElement>) => { private onCopyOnSaveChange = (event: EuiSwitchEvent) => {
this.setState({ this.setState({
copyOnSave: event.target.checked, copyOnSave: event.target.checked,
}); });

View file

@ -133,13 +133,13 @@ export default function ({ getService, getPageObjects }) {
describe('updateFiltersOnChange is true', () => { describe('updateFiltersOnChange is true', () => {
before(async () => { before(async () => {
await PageObjects.visualize.clickVisEditorTab('options'); await PageObjects.visualize.clickVisEditorTab('options');
await PageObjects.visualize.checkCheckbox('inputControlEditorUpdateFiltersOnChangeCheckbox'); await PageObjects.visualize.checkSwitch('inputControlEditorUpdateFiltersOnChangeCheckbox');
await PageObjects.visualize.clickGo(); await PageObjects.visualize.clickGo();
}); });
after(async () => { after(async () => {
await PageObjects.visualize.clickVisEditorTab('options'); await PageObjects.visualize.clickVisEditorTab('options');
await PageObjects.visualize.uncheckCheckbox('inputControlEditorUpdateFiltersOnChangeCheckbox'); await PageObjects.visualize.uncheckSwitch('inputControlEditorUpdateFiltersOnChangeCheckbox');
await PageObjects.visualize.clickGo(); await PageObjects.visualize.clickGo();
}); });

View file

@ -347,7 +347,7 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
async clickSave() { async clickSave() {
log.debug('DashboardPage.clickSave'); log.debug('DashboardPage.clickSave');
await testSubjects.clickWhenNotDisabled('confirmSaveSavedObjectButton'); await testSubjects.click('confirmSaveSavedObjectButton');
} }
async pressEnterKey() { async pressEnterKey() {
@ -543,9 +543,10 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
async setSaveAsNewCheckBox(checked) { async setSaveAsNewCheckBox(checked) {
log.debug('saveAsNewCheckbox: ' + checked); log.debug('saveAsNewCheckbox: ' + checked);
const saveAsNewCheckbox = await testSubjects.find('saveAsNewCheckbox'); const saveAsNewCheckbox = await testSubjects.find('saveAsNewCheckbox');
const isAlreadyChecked = (await saveAsNewCheckbox.getAttribute('checked') === 'true'); const isAlreadyChecked = (await saveAsNewCheckbox.getAttribute('aria-checked') === 'true');
if (isAlreadyChecked !== checked) { if (isAlreadyChecked !== checked) {
log.debug('Flipping save as new checkbox'); log.debug('Flipping save as new checkbox');
const saveAsNewCheckbox = await testSubjects.find('saveAsNewCheckbox');
await retry.try(() => saveAsNewCheckbox.click()); await retry.try(() => saveAsNewCheckbox.click());
} }
} }
@ -553,9 +554,10 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
async setStoreTimeWithDashboard(checked) { async setStoreTimeWithDashboard(checked) {
log.debug('Storing time with dashboard: ' + checked); log.debug('Storing time with dashboard: ' + checked);
const storeTimeCheckbox = await testSubjects.find('storeTimeWithDashboard'); const storeTimeCheckbox = await testSubjects.find('storeTimeWithDashboard');
const isAlreadyChecked = (await storeTimeCheckbox.getAttribute('checked') === 'true'); const isAlreadyChecked = (await storeTimeCheckbox.getAttribute('aria-checked') === 'true');
if (isAlreadyChecked !== checked) { if (isAlreadyChecked !== checked) {
log.debug('Flipping store time checkbox'); log.debug('Flipping store time checkbox');
const storeTimeCheckbox = await testSubjects.find('storeTimeWithDashboard');
await retry.try(() => storeTimeCheckbox.click()); await retry.try(() => storeTimeCheckbox.click());
} }
} }

View file

@ -372,6 +372,28 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
} }
} }
async isSwitchChecked(selector) {
const checkbox = await testSubjects.find(selector);
const isChecked = await checkbox.getAttribute('aria-checked');
return isChecked === 'true';
}
async checkSwitch(selector) {
const isChecked = await this.isSwitchChecked(selector);
if (!isChecked) {
log.debug(`checking switch ${selector}`);
await testSubjects.click(selector);
}
}
async uncheckSwitch(selector) {
const isChecked = await this.isSwitchChecked(selector);
if (isChecked) {
log.debug(`unchecking switch ${selector}`);
await testSubjects.click(selector);
}
}
async setSelectByOptionText(selectId, optionText) { async setSelectByOptionText(selectId, optionText) {
const selectField = await find.byCssSelector(`#${selectId}`); const selectField = await find.byCssSelector(`#${selectId}`);
const options = await find.allByCssSelector(`#${selectId} > option`); const options = await find.allByCssSelector(`#${selectId} > option`);
@ -1009,7 +1031,7 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
async setIsFilteredByCollarCheckbox(value = true) { async setIsFilteredByCollarCheckbox(value = true) {
await retry.try(async () => { await retry.try(async () => {
const isChecked = await this.isChecked('isFilteredByCollarCheckbox'); const isChecked = await this.isSwitchChecked('isFilteredByCollarCheckbox');
if (isChecked !== value) { if (isChecked !== value) {
await testSubjects.click('isFilteredByCollarCheckbox'); await testSubjects.click('isFilteredByCollarCheckbox');
throw new Error('isFilteredByCollar not set correctly'); throw new Error('isFilteredByCollar not set correctly');

View file

@ -118,15 +118,17 @@ export function SavedQueryManagementComponentProvider({ getService }: FtrProvide
await testSubjects.setValue('saveQueryFormDescription', description); await testSubjects.setValue('saveQueryFormDescription', description);
const currentIncludeFiltersValue = const currentIncludeFiltersValue =
(await testSubjects.getAttribute('saveQueryFormIncludeFiltersOption', 'checked')) === (await testSubjects.getAttribute('saveQueryFormIncludeFiltersOption', 'aria-checked')) ===
'true'; 'true';
if (currentIncludeFiltersValue !== includeFilters) { if (currentIncludeFiltersValue !== includeFilters) {
await testSubjects.click('saveQueryFormIncludeFiltersOption'); await testSubjects.click('saveQueryFormIncludeFiltersOption');
} }
const currentIncludeTimeFilterValue = const currentIncludeTimeFilterValue =
(await testSubjects.getAttribute('saveQueryFormIncludeTimeFilterOption', 'checked')) === (await testSubjects.getAttribute(
'true'; 'saveQueryFormIncludeTimeFilterOption',
'aria-checked'
)) === 'true';
if (currentIncludeTimeFilterValue !== includeTimeFilter) { if (currentIncludeTimeFilterValue !== includeTimeFilter) {
await testSubjects.click('saveQueryFormIncludeTimeFilterOption'); await testSubjects.click('saveQueryFormIncludeTimeFilterOption');
} }

View file

@ -7,7 +7,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@elastic/eui": "14.8.0", "@elastic/eui": "14.9.0",
"react": "^16.8.0", "react": "^16.8.0",
"react-dom": "^16.8.0" "react-dom": "^16.8.0"
} }

View file

@ -7,7 +7,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@elastic/eui": "14.8.0", "@elastic/eui": "14.9.0",
"react": "^16.8.0" "react": "^16.8.0"
} }
} }

View file

@ -8,7 +8,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@elastic/eui": "14.8.0", "@elastic/eui": "14.9.0",
"react": "^16.8.0" "react": "^16.8.0"
}, },
"scripts": { "scripts": {

View file

@ -8,7 +8,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@elastic/eui": "14.8.0", "@elastic/eui": "14.9.0",
"react": "^16.8.0" "react": "^16.8.0"
}, },
"scripts": { "scripts": {

View file

@ -13,23 +13,26 @@ exports[`Storyshots arguments/AxisConfig simple 1`] = `
<div <div
className="euiSwitch euiSwitch--compressed" className="euiSwitch euiSwitch--compressed"
> >
<input <button
checked={false} aria-checked={false}
className="euiSwitch__input" aria-label=""
className="euiSwitch__button"
id="generated-id" id="generated-id"
onChange={[Function]} onClick={[Function]}
type="checkbox" role="switch"
/> type="button"
<span
className="euiSwitch__body"
> >
<span <span
className="euiSwitch__thumb" className="euiSwitch__body"
/> >
<span <span
className="euiSwitch__track" className="euiSwitch__thumb"
/> />
</span> <span
className="euiSwitch__track"
/>
</span>
</button>
</div> </div>
</div> </div>
`; `;
@ -47,23 +50,26 @@ exports[`Storyshots arguments/AxisConfig/components simple template 1`] = `
<div <div
className="euiSwitch euiSwitch--compressed" className="euiSwitch euiSwitch--compressed"
> >
<input <button
checked={false} aria-checked={false}
className="euiSwitch__input" aria-label=""
className="euiSwitch__button"
id="generated-id" id="generated-id"
onChange={[Function]} onClick={[Function]}
type="checkbox" role="switch"
/> type="button"
<span
className="euiSwitch__body"
> >
<span <span
className="euiSwitch__thumb" className="euiSwitch__body"
/> >
<span <span
className="euiSwitch__track" className="euiSwitch__thumb"
/> />
</span> <span
className="euiSwitch__track"
/>
</span>
</button>
</div> </div>
</div> </div>
`; `;

View file

@ -19,6 +19,8 @@ export const SimpleTemplate: FunctionComponent<Props> = ({ onValueChange, argVal
compressed compressed
checked={Boolean(argValue)} checked={Boolean(argValue)}
onChange={() => onValueChange(!Boolean(argValue))} onChange={() => onValueChange(!Boolean(argValue))}
showLabel={false}
label=""
/> />
); );
}; };

View file

@ -111,7 +111,7 @@ describe('<App />', () => {
wrapper.update(); wrapper.update();
expect(footer(wrapper).prop('isHidden')).toEqual(false); expect(footer(wrapper).prop('isHidden')).toEqual(false);
expect(footer(wrapper).prop('isAutohide')).toEqual(false); expect(footer(wrapper).prop('isAutohide')).toEqual(false);
toolbarCheck(wrapper).simulate('change'); toolbarCheck(wrapper).simulate('click');
expect(footer(wrapper).prop('isAutohide')).toEqual(true); expect(footer(wrapper).prop('isAutohide')).toEqual(true);
canvas(wrapper).simulate('mouseEnter'); canvas(wrapper).simulate('mouseEnter');
expect(footer(wrapper).prop('isHidden')).toEqual(false); expect(footer(wrapper).prop('isHidden')).toEqual(false);
@ -132,7 +132,7 @@ describe('<App />', () => {
.simulate('click'); .simulate('click');
await tick(20); await tick(20);
wrapper.update(); wrapper.update();
toolbarCheck(wrapper).simulate('change'); toolbarCheck(wrapper).simulate('click');
await tick(20); await tick(20);
// Simulate the mouse leaving the container // Simulate the mouse leaving the container

View file

@ -25,49 +25,52 @@ exports[`Storyshots shareables/Footer/Settings/AutoplaySettings component: off,
<div <div
className="euiSwitch" className="euiSwitch"
> >
<input <button
checked={false} aria-checked={false}
className="euiSwitch__input" aria-describedby="generated-id"
className="euiSwitch__button"
id="cycle" id="cycle"
name="cycle" onClick={[Function]}
onChange={[Function]} role="switch"
type="checkbox" type="button"
/>
<span
className="euiSwitch__body"
> >
<span <span
className="euiSwitch__thumb" className="euiSwitch__body"
/>
<span
className="euiSwitch__track"
> >
<svg <span
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon" className="euiSwitch__thumb"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/> />
<span
className="euiSwitch__track"
>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</span>
</span> </span>
</span> </button>
<label <p
className="euiSwitch__label" className="euiSwitch__label"
htmlFor="cycle" id="generated-id"
onClick={[Function]}
> >
Cycle Slides Cycle Slides
</label> </p>
</div> </div>
<hr <hr
className="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginMedium" className="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginMedium"
@ -190,49 +193,52 @@ exports[`Storyshots shareables/Footer/Settings/AutoplaySettings component: on, 5
<div <div
className="euiSwitch" className="euiSwitch"
> >
<input <button
checked={true} aria-checked={true}
className="euiSwitch__input" aria-describedby="generated-id"
className="euiSwitch__button"
id="cycle" id="cycle"
name="cycle" onClick={[Function]}
onChange={[Function]} role="switch"
type="checkbox" type="button"
/>
<span
className="euiSwitch__body"
> >
<span <span
className="euiSwitch__thumb" className="euiSwitch__body"
/>
<span
className="euiSwitch__track"
> >
<svg <span
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon" className="euiSwitch__thumb"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/> />
<span
className="euiSwitch__track"
>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</span>
</span> </span>
</span> </button>
<label <p
className="euiSwitch__label" className="euiSwitch__label"
htmlFor="cycle" id="generated-id"
onClick={[Function]}
> >
Cycle Slides Cycle Slides
</label> </p>
</div> </div>
<hr <hr
className="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginMedium" className="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginMedium"
@ -355,49 +361,52 @@ exports[`Storyshots shareables/Footer/Settings/AutoplaySettings contextual 1`] =
<div <div
className="euiSwitch" className="euiSwitch"
> >
<input <button
checked={false} aria-checked={false}
className="euiSwitch__input" aria-describedby="generated-id"
className="euiSwitch__button"
id="cycle" id="cycle"
name="cycle" onClick={[Function]}
onChange={[Function]} role="switch"
type="checkbox" type="button"
/>
<span
className="euiSwitch__body"
> >
<span <span
className="euiSwitch__thumb" className="euiSwitch__body"
/>
<span
className="euiSwitch__track"
> >
<svg <span
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon" className="euiSwitch__thumb"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/> />
<span
className="euiSwitch__track"
>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</span>
</span> </span>
</span> </button>
<label <p
className="euiSwitch__label" className="euiSwitch__label"
htmlFor="cycle" id="generated-id"
onClick={[Function]}
> >
Cycle Slides Cycle Slides
</label> </p>
</div> </div>
<hr <hr
className="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginMedium" className="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginMedium"

View file

@ -31,53 +31,55 @@ exports[`Storyshots shareables/Footer/Settings/ToolbarSettings component: off 1`
<div <div
className="euiSwitch" className="euiSwitch"
> >
<input <button
aria-checked={false}
aria-describedby="generated-id-help" aria-describedby="generated-id-help"
checked={false} className="euiSwitch__button"
className="euiSwitch__input"
data-test-subj="hideToolbarSwitch" data-test-subj="hideToolbarSwitch"
id="generated-id" id="generated-id"
name="toolbarHide"
onBlur={[Function]} onBlur={[Function]}
onChange={[Function]} onClick={[Function]}
onFocus={[Function]} onFocus={[Function]}
type="checkbox" role="switch"
/> type="button"
<span
className="euiSwitch__body"
> >
<span <span
className="euiSwitch__thumb" className="euiSwitch__body"
/>
<span
className="euiSwitch__track"
> >
<svg <span
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon" className="euiSwitch__thumb"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/> />
<span
className="euiSwitch__track"
>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</span>
</span> </span>
</span> </button>
<label <p
className="euiSwitch__label" className="euiSwitch__label"
htmlFor="generated-id" id="generated-id"
onClick={[Function]}
> >
Hide Toolbar Hide Toolbar
</label> </p>
</div> </div>
<div <div
className="euiFormHelpText euiFormRow__text" className="euiFormHelpText euiFormRow__text"
@ -122,53 +124,55 @@ exports[`Storyshots shareables/Footer/Settings/ToolbarSettings component: on 1`]
<div <div
className="euiSwitch" className="euiSwitch"
> >
<input <button
aria-checked={true}
aria-describedby="generated-id-help" aria-describedby="generated-id-help"
checked={true} className="euiSwitch__button"
className="euiSwitch__input"
data-test-subj="hideToolbarSwitch" data-test-subj="hideToolbarSwitch"
id="generated-id" id="generated-id"
name="toolbarHide"
onBlur={[Function]} onBlur={[Function]}
onChange={[Function]} onClick={[Function]}
onFocus={[Function]} onFocus={[Function]}
type="checkbox" role="switch"
/> type="button"
<span
className="euiSwitch__body"
> >
<span <span
className="euiSwitch__thumb" className="euiSwitch__body"
/>
<span
className="euiSwitch__track"
> >
<svg <span
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon" className="euiSwitch__thumb"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/> />
<span
className="euiSwitch__track"
>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</span>
</span> </span>
</span> </button>
<label <p
className="euiSwitch__label" className="euiSwitch__label"
htmlFor="generated-id" id="generated-id"
onClick={[Function]}
> >
Hide Toolbar Hide Toolbar
</label> </p>
</div> </div>
<div <div
className="euiFormHelpText euiFormRow__text" className="euiFormHelpText euiFormRow__text"
@ -213,53 +217,55 @@ exports[`Storyshots shareables/Footer/Settings/ToolbarSettings contextual 1`] =
<div <div
className="euiSwitch" className="euiSwitch"
> >
<input <button
aria-checked={false}
aria-describedby="generated-id-help" aria-describedby="generated-id-help"
checked={false} className="euiSwitch__button"
className="euiSwitch__input"
data-test-subj="hideToolbarSwitch" data-test-subj="hideToolbarSwitch"
id="generated-id" id="generated-id"
name="toolbarHide"
onBlur={[Function]} onBlur={[Function]}
onChange={[Function]} onClick={[Function]}
onFocus={[Function]} onFocus={[Function]}
type="checkbox" role="switch"
/> type="button"
<span
className="euiSwitch__body"
> >
<span <span
className="euiSwitch__thumb" className="euiSwitch__body"
/>
<span
className="euiSwitch__track"
> >
<svg <span
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon" className="euiSwitch__thumb"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/> />
<span
className="euiSwitch__track"
>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
<svg
className="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height={16}
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</span>
</span> </span>
</span> </button>
<label <p
className="euiSwitch__label" className="euiSwitch__label"
htmlFor="generated-id" id="generated-id"
onClick={[Function]}
> >
Hide Toolbar Hide Toolbar
</label> </p>
</div> </div>
<div <div
className="euiFormHelpText euiFormRow__text" className="euiFormHelpText euiFormRow__text"

View file

@ -24,15 +24,15 @@ describe('<AutoplaySettings />', () => {
); );
test('renders as expected', () => { test('renders as expected', () => {
expect(checkbox(wrapper).props().checked).toEqual(false); expect(checkbox(wrapper).props()['aria-checked']).toEqual(false);
expect(input(wrapper).props().value).toBe('5s'); expect(input(wrapper).props().value).toBe('5s');
}); });
test('activates and deactivates', () => { test('activates and deactivates', () => {
checkbox(wrapper).simulate('change'); checkbox(wrapper).simulate('click');
expect(checkbox(wrapper).props().checked).toEqual(true); expect(checkbox(wrapper).props()['aria-checked']).toEqual(true);
checkbox(wrapper).simulate('change'); checkbox(wrapper).simulate('click');
expect(checkbox(wrapper).props().checked).toEqual(false); expect(checkbox(wrapper).props()['aria-checked']).toEqual(false);
}); });
test('changes properly with input', () => { test('changes properly with input', () => {

View file

@ -85,8 +85,8 @@ describe('<Settings />', () => {
// Click the Hide Toolbar switch // Click the Hide Toolbar switch
portal(wrapper) portal(wrapper)
.find('input[data-test-subj="hideToolbarSwitch"]') .find('button[data-test-subj="hideToolbarSwitch"]')
.simulate('change'); .simulate('click');
// Wait for the animation and DOM update // Wait for the animation and DOM update
await tick(20); await tick(20);

View file

@ -20,13 +20,13 @@ describe('<ToolbarSettings />', () => {
); );
test('renders as expected', () => { test('renders as expected', () => {
expect(checkbox(wrapper).props().checked).toEqual(false); expect(checkbox(wrapper).props()['aria-checked']).toEqual(false);
}); });
test('activates and deactivates', () => { test('activates and deactivates', () => {
checkbox(wrapper).simulate('change'); checkbox(wrapper).simulate('click');
expect(checkbox(wrapper).props().checked).toEqual(true); expect(checkbox(wrapper).props()['aria-checked']).toEqual(true);
checkbox(wrapper).simulate('change'); checkbox(wrapper).simulate('click');
expect(checkbox(wrapper).props().checked).toEqual(false); expect(checkbox(wrapper).props()['aria-checked']).toEqual(false);
}); });
}); });

View file

@ -21,7 +21,7 @@ export const getToolbarPanel = (wrapper: ReactWrapper) =>
export const getToolbarCheckbox = (wrapper: ReactWrapper) => export const getToolbarCheckbox = (wrapper: ReactWrapper) =>
getToolbarPanel(wrapper) getToolbarPanel(wrapper)
.find('EuiSwitch') .find('EuiSwitch')
.find('input[type="checkbox"]'); .find('button');
export const getAutoplayPanel = (wrapper: ReactWrapper) => export const getAutoplayPanel = (wrapper: ReactWrapper) =>
wrapper.find('AutoplaySettings > AutoplaySettingsComponent'); wrapper.find('AutoplaySettings > AutoplaySettingsComponent');
@ -29,7 +29,7 @@ export const getAutoplayPanel = (wrapper: ReactWrapper) =>
export const getAutoplayCheckbox = (wrapper: ReactWrapper) => export const getAutoplayCheckbox = (wrapper: ReactWrapper) =>
getAutoplayPanel(wrapper) getAutoplayPanel(wrapper)
.find('EuiSwitch') .find('EuiSwitch')
.find('input[type="checkbox"]'); .find('button');
export const getAutoplayTextField = (wrapper: ReactWrapper) => export const getAutoplayTextField = (wrapper: ReactWrapper) =>
getAutoplayPanel(wrapper) getAutoplayPanel(wrapper)

View file

@ -27,7 +27,7 @@ export const setup = (props) => {
}; };
const toggleAdvancedSettings = () => { const toggleAdvancedSettings = () => {
testBed.form.selectCheckBox('advancedSettingsToggle'); testBed.form.toggleEuiSwitch('advancedSettingsToggle');
}; };
return { return {

View file

@ -34,7 +34,7 @@ export const setup = (props) => {
}; };
const toggleAdvancedSettings = () => { const toggleAdvancedSettings = () => {
testBed.form.selectCheckBox('advancedSettingsToggle'); testBed.form.toggleEuiSwitch('advancedSettingsToggle');
}; };
return { return {

View file

@ -66,7 +66,7 @@ window.TextEncoder = null;
let component; let component;
const activatePhase = (rendered, phase) => { const activatePhase = (rendered, phase) => {
const testSubject = `enablePhaseSwitch-${phase}`; const testSubject = `enablePhaseSwitch-${phase}`;
findTestSubject(rendered, testSubject).simulate('change', { target: { checked: true } }); findTestSubject(rendered, testSubject).simulate('click');
rendered.update(); rendered.update();
}; };
const expectedErrorMessages = (rendered, expectedErrorMessages) => { const expectedErrorMessages = (rendered, expectedErrorMessages) => {
@ -83,7 +83,7 @@ const expectedErrorMessages = (rendered, expectedErrorMessages) => {
}); });
}; };
const noRollover = (rendered) => { const noRollover = (rendered) => {
findTestSubject(rendered, 'rolloverSwitch').simulate('change', { target: { checked: false } }); findTestSubject(rendered, 'rolloverSwitch').simulate('click');
rendered.update(); rendered.update();
}; };
const getNodeAttributeSelect = (rendered, phase) => { const getNodeAttributeSelect = (rendered, phase) => {
@ -155,7 +155,7 @@ describe('edit policy', () => {
</Provider> </Provider>
); );
const rendered = mountWithIntl(component); const rendered = mountWithIntl(component);
findTestSubject(rendered, 'saveAsNewSwitch').simulate('change', { target: { checked: true } }); findTestSubject(rendered, 'saveAsNewSwitch').simulate('click');
rendered.update(); rendered.update();
setPolicyName(rendered, 'testy0'); setPolicyName(rendered, 'testy0');
save(rendered); save(rendered);
@ -275,7 +275,7 @@ describe('edit policy', () => {
noRollover(rendered); noRollover(rendered);
setPolicyName(rendered, 'mypolicy'); setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'warm'); activatePhase(rendered, 'warm');
findTestSubject(rendered, 'shrinkSwitch').simulate('change', { target: { checked: true } }); findTestSubject(rendered, 'shrinkSwitch').simulate('click');
rendered.update(); rendered.update();
setPhaseAfter(rendered, 'warm', 1); setPhaseAfter(rendered, 'warm', 1);
const shrinkInput = rendered.find('input#warm-selectedPrimaryShardCount'); const shrinkInput = rendered.find('input#warm-selectedPrimaryShardCount');
@ -290,7 +290,7 @@ describe('edit policy', () => {
setPolicyName(rendered, 'mypolicy'); setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'warm'); activatePhase(rendered, 'warm');
setPhaseAfter(rendered, 'warm', 1); setPhaseAfter(rendered, 'warm', 1);
findTestSubject(rendered, 'shrinkSwitch').simulate('change', { target: { checked: true } }); findTestSubject(rendered, 'shrinkSwitch').simulate('click');
rendered.update(); rendered.update();
const shrinkInput = rendered.find('input#warm-selectedPrimaryShardCount'); const shrinkInput = rendered.find('input#warm-selectedPrimaryShardCount');
shrinkInput.simulate('change', { target: { value: '-1' } }); shrinkInput.simulate('change', { target: { value: '-1' } });
@ -304,7 +304,7 @@ describe('edit policy', () => {
setPolicyName(rendered, 'mypolicy'); setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'warm'); activatePhase(rendered, 'warm');
setPhaseAfter(rendered, 'warm', 1); setPhaseAfter(rendered, 'warm', 1);
findTestSubject(rendered, 'forceMergeSwitch').simulate('change', { target: { checked: true } }); findTestSubject(rendered, 'forceMergeSwitch').simulate('click');
rendered.update(); rendered.update();
const shrinkInput = rendered.find('input#warm-selectedForceMergeSegments'); const shrinkInput = rendered.find('input#warm-selectedForceMergeSegments');
shrinkInput.simulate('change', { target: { value: '0' } }); shrinkInput.simulate('change', { target: { value: '0' } });
@ -318,7 +318,7 @@ describe('edit policy', () => {
setPolicyName(rendered, 'mypolicy'); setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'warm'); activatePhase(rendered, 'warm');
setPhaseAfter(rendered, 'warm', 1); setPhaseAfter(rendered, 'warm', 1);
findTestSubject(rendered, 'forceMergeSwitch').simulate('change', { target: { checked: true } }); findTestSubject(rendered, 'forceMergeSwitch').simulate('click');
rendered.update(); rendered.update();
const shrinkInput = rendered.find('input#warm-selectedForceMergeSegments'); const shrinkInput = rendered.find('input#warm-selectedForceMergeSegments');
shrinkInput.simulate('change', { target: { value: '-1' } }); shrinkInput.simulate('change', { target: { value: '-1' } });

View file

@ -182,8 +182,8 @@ describe('index table', () => {
) )
.map(span => span.text()) .map(span => span.text())
); );
const switchControl = rendered.find('.euiSwitch__input'); const switchControl = rendered.find('.euiSwitch__button');
switchControl.simulate('change', { target: { checked: true } }); switchControl.simulate('click');
snapshot( snapshot(
rendered rendered
.find( .find(

View file

@ -16,6 +16,7 @@ import {
EuiPopoverTitle, EuiPopoverTitle,
EuiSpacer, EuiSpacer,
EuiSwitch, EuiSwitch,
EuiSwitchEvent,
EuiText, EuiText,
} from '@elastic/eui'; } from '@elastic/eui';
import { i18n } from '@kbn/i18n'; import { i18n } from '@kbn/i18n';
@ -48,8 +49,8 @@ export const LegendControls = ({ autoBounds, boundsOverride, onChange, dataBound
/> />
); );
const handleAutoChange = (e: SyntheticEvent<HTMLInputElement>) => { const handleAutoChange = (e: EuiSwitchEvent) => {
setDraftAuto(e.currentTarget.checked); setDraftAuto(e.target.checked);
}; };
const createBoundsHandler = (name: string) => (e: SyntheticEvent<HTMLInputElement>) => { const createBoundsHandler = (name: string) => (e: SyntheticEvent<HTMLInputElement>) => {

View file

@ -8,7 +8,7 @@ import React from 'react';
import { DateHistogramIndexPatternColumn } from './date_histogram'; import { DateHistogramIndexPatternColumn } from './date_histogram';
import { dateHistogramOperation } from '.'; import { dateHistogramOperation } from '.';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { EuiSwitch } from '@elastic/eui'; import { EuiSwitch, EuiSwitchEvent } from '@elastic/eui';
import { import {
UiSettingsClientContract, UiSettingsClientContract,
SavedObjectsClientContract, SavedObjectsClientContract,
@ -423,7 +423,7 @@ describe('date_histogram', () => {
); );
instance.find(EuiSwitch).prop('onChange')!({ instance.find(EuiSwitch).prop('onChange')!({
target: { checked: true }, target: { checked: true },
} as React.ChangeEvent<HTMLInputElement>); } as EuiSwitchEvent);
expect(setStateSpy).toHaveBeenCalled(); expect(setStateSpy).toHaveBeenCalled();
const newState = setStateSpy.mock.calls[0][0]; const newState = setStateSpy.mock.calls[0][0];
expect(newState).toHaveProperty('layers.third.columns.col1.params.interval', '30d'); expect(newState).toHaveProperty('layers.third.columns.col1.params.interval', '30d');

View file

@ -15,6 +15,7 @@ import {
EuiForm, EuiForm,
EuiFormRow, EuiFormRow,
EuiSwitch, EuiSwitch,
EuiSwitchEvent,
EuiFieldNumber, EuiFieldNumber,
EuiSelect, EuiSelect,
EuiFlexItem, EuiFlexItem,
@ -154,7 +155,7 @@ export const dateHistogramOperation: OperationDefinition<DateHistogramIndexPatte
restrictedInterval(field!.aggregationRestrictions) restrictedInterval(field!.aggregationRestrictions)
); );
function onChangeAutoInterval(ev: React.ChangeEvent<HTMLInputElement>) { function onChangeAutoInterval(ev: EuiSwitchEvent) {
const value = ev.target.checked ? autoIntervalFromDateRange(dateRange) : autoInterval; const value = ev.target.checked ? autoIntervalFromDateRange(dateRange) : autoInterval;
setState(updateColumnParam({ state, layerId, currentColumn, paramName: 'interval', value })); setState(updateColumnParam({ state, layerId, currentColumn, paramName: 'interval', value }));
} }

View file

@ -56,6 +56,6 @@ describe('Data Frame Analytics: <CreateAnalyticsForm />', () => {
expect(options.at(2).props().value).toBe('regression'); expect(options.at(2).props().value).toBe('regression');
const row2 = euiFormRows.at(1); const row2 = euiFormRows.at(1);
expect(row2.find('label').text()).toBe('Enable advanced editor'); expect(row2.find('p').text()).toBe('Enable advanced editor');
}); });
}); });

View file

@ -5,6 +5,7 @@
*/ */
import React, { FC, useState, useContext, useEffect } from 'react'; import React, { FC, useState, useContext, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSwitch } from '@elastic/eui'; import { EuiSwitch } from '@elastic/eui';
import { JobCreatorContext } from '../../../../../job_creator_context'; import { JobCreatorContext } from '../../../../../job_creator_context';
import { Description } from './description'; import { Description } from './description';
@ -29,6 +30,13 @@ export const DedicatedIndexSwitch: FC = () => {
checked={useDedicatedIndex} checked={useDedicatedIndex}
onChange={toggleModelPlot} onChange={toggleModelPlot}
data-test-subj="mlJobWizardSwitchUseDedicatedIndex" data-test-subj="mlJobWizardSwitchUseDedicatedIndex"
showLabel={false}
label={i18n.translate(
'xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.useDedicatedIndex.title',
{
defaultMessage: 'Use dedicated index',
}
)}
/> />
</Description> </Description>
); );

View file

@ -5,6 +5,7 @@
*/ */
import React, { FC, useState, useContext, useEffect } from 'react'; import React, { FC, useState, useContext, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSwitch } from '@elastic/eui'; import { EuiSwitch } from '@elastic/eui';
import { JobCreatorContext } from '../../../../../job_creator_context'; import { JobCreatorContext } from '../../../../../job_creator_context';
import { Description } from './description'; import { Description } from './description';
@ -29,6 +30,13 @@ export const ModelPlotSwitch: FC = () => {
checked={modelPlotEnabled} checked={modelPlotEnabled}
onChange={toggleModelPlot} onChange={toggleModelPlot}
data-test-subj="mlJobWizardSwitchModelPlot" data-test-subj="mlJobWizardSwitchModelPlot"
showLabel={false}
label={i18n.translate(
'xpack.ml.newJob.wizard.jobDetailsStep.advancedSection.enableModelPlot.title',
{
defaultMessage: 'Enable model plot',
}
)}
/> />
</Description> </Description>
); );

View file

@ -5,6 +5,7 @@
*/ */
import React, { FC, useState, useContext, useEffect } from 'react'; import React, { FC, useState, useContext, useEffect } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSwitch } from '@elastic/eui'; import { EuiSwitch } from '@elastic/eui';
import { JobCreatorContext } from '../../../job_creator_context'; import { JobCreatorContext } from '../../../job_creator_context';
import { Description } from './description'; import { Description } from './description';
@ -43,6 +44,10 @@ export const SparseDataSwitch: FC = () => {
checked={sparseData} checked={sparseData}
onChange={toggleSparseData} onChange={toggleSparseData}
data-test-subj="mlJobWizardSwitchSparseData" data-test-subj="mlJobWizardSwitchSparseData"
showLabel={false}
label={i18n.translate('xpack.ml.newJob.wizard.pickFieldsStep.sparseData.title', {
defaultMessage: 'Sparse data',
})}
/> />
</Description> </Description>
); );

View file

@ -247,6 +247,10 @@ export const JobSettingsForm: FC<JobSettingsFormProps> = ({
useDedicatedIndex: checked, useDedicatedIndex: checked,
}); });
}} }}
showLabel={false}
label={i18n.translate('xpack.ml.newJob.recognize.useDedicatedIndexLabel', {
defaultMessage: 'Use dedicated index',
})}
/> />
</EuiFormRow> </EuiFormRow>
</EuiDescribedFormGroup> </EuiDescribedFormGroup>

View file

@ -42,11 +42,11 @@ describe('Create Remote cluster', () => {
expect(exists('remoteClusterFormSkipUnavailableFormToggle')).toBe(true); expect(exists('remoteClusterFormSkipUnavailableFormToggle')).toBe(true);
// By default it should be set to "false" // By default it should be set to "false"
expect(find('remoteClusterFormSkipUnavailableFormToggle').props().checked).toBe(false); expect(find('remoteClusterFormSkipUnavailableFormToggle').props()['aria-checked']).toBe(false);
form.toggleEuiSwitch('remoteClusterFormSkipUnavailableFormToggle'); form.toggleEuiSwitch('remoteClusterFormSkipUnavailableFormToggle');
expect(find('remoteClusterFormSkipUnavailableFormToggle').props().checked).toBe(true); expect(find('remoteClusterFormSkipUnavailableFormToggle').props()['aria-checked']).toBe(true);
}); });
test('should display errors and disable the save button when clicking "save" without filling the form', () => { test('should display errors and disable the save button when clicking "save" without filling the form', () => {

View file

@ -64,7 +64,7 @@ describe('Edit Remote cluster', () => {
test('should populate the form fields with the values from the remote cluster loaded', () => { test('should populate the form fields with the values from the remote cluster loaded', () => {
expect(find('remoteClusterFormNameInput').props().value).toBe(REMOTE_CLUSTER_EDIT_NAME); expect(find('remoteClusterFormNameInput').props().value).toBe(REMOTE_CLUSTER_EDIT_NAME);
expect(find('remoteClusterFormSeedsInput').text()).toBe(REMOTE_CLUSTER_EDIT.seeds.join('')); expect(find('remoteClusterFormSeedsInput').text()).toBe(REMOTE_CLUSTER_EDIT.seeds.join(''));
expect(find('remoteClusterFormSkipUnavailableFormToggle').props().checked).toBe(REMOTE_CLUSTER_EDIT.skipUnavailable); expect(find('remoteClusterFormSkipUnavailableFormToggle').props()['aria-checked']).toBe(REMOTE_CLUSTER_EDIT.skipUnavailable);
}); });
test('should disable the form name input', () => { test('should disable the form name input', () => {

View file

@ -247,45 +247,49 @@ Array [
<div <div
class="euiSwitch" class="euiSwitch"
> >
<input <button
class="euiSwitch__input" aria-checked="false"
aria-describedby="mockId"
class="euiSwitch__button"
data-test-subj="remoteClusterFormSkipUnavailableFormToggle" data-test-subj="remoteClusterFormSkipUnavailableFormToggle"
id="mockId" id="mockId"
type="checkbox" role="switch"
/> type="button"
<span
class="euiSwitch__body"
> >
<span <span
class="euiSwitch__thumb" class="euiSwitch__body"
/>
<span
class="euiSwitch__track"
> >
<svg <span
class="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon" class="euiSwitch__thumb"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/> />
<span
class="euiSwitch__track"
>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</span>
</span> </span>
</span> </button>
<label <p
class="euiSwitch__label" class="euiSwitch__label"
for="mockId" id="mockId"
> >
Skip if unavailable Skip if unavailable
</label> </p>
</div> </div>
</div> </div>
</div> </div>
@ -502,45 +506,49 @@ Array [
<div <div
class="euiSwitch" class="euiSwitch"
> >
<input <button
class="euiSwitch__input" aria-checked="false"
aria-describedby="mockId"
class="euiSwitch__button"
data-test-subj="remoteClusterFormSkipUnavailableFormToggle" data-test-subj="remoteClusterFormSkipUnavailableFormToggle"
id="mockId" id="mockId"
type="checkbox" role="switch"
/> type="button"
<span
class="euiSwitch__body"
> >
<span <span
class="euiSwitch__thumb" class="euiSwitch__body"
/>
<span
class="euiSwitch__track"
> >
<svg <span
class="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon" class="euiSwitch__thumb"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/> />
<span
class="euiSwitch__track"
>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
<svg
class="euiIcon euiIcon--medium euiIcon-isLoading euiSwitch__icon euiSwitch__icon--checked"
focusable="false"
height="16"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
/>
</span>
</span> </span>
</span> </button>
<label <p
class="euiSwitch__label" class="euiSwitch__label"
for="mockId" id="mockId"
> >
Skip if unavailable Skip if unavailable
</label> </p>
</div> </div>
</div> </div>
</div>, </div>,

View file

@ -11,7 +11,9 @@ exports[`JobSwitch renders correctly against snapshot 1`] = `
checked={false} checked={false}
data-test-subj="job-switch" data-test-subj="job-switch"
disabled={false} disabled={false}
label=""
onChange={[Function]} onChange={[Function]}
showLabel={false}
/> />
</EuiFlexItem> </EuiFlexItem>
</EuiFlexGroup> </EuiFlexGroup>

View file

@ -42,9 +42,9 @@ describe('JobSwitch', () => {
); );
wrapper wrapper
.find('[data-test-subj="job-switch"] input') .find('button[data-test-subj="job-switch"]')
.first() .first()
.simulate('change', { .simulate('click', {
target: { checked: true }, target: { checked: true },
}); });

View file

@ -59,6 +59,8 @@ export const JobSwitch = React.memo<JobSwitchProps>(
setIsLoading(true); setIsLoading(true);
onJobStateChange(job, job.latestTimestampMs || 0, e.target.checked); onJobStateChange(job, job.latestTimestampMs || 0, e.target.checked);
}} }}
showLabel={false}
label=""
/> />
)} )}
</EuiFlexItem> </EuiFlexItem>

View file

@ -59,9 +59,9 @@ describe('JobsTable', () => {
<JobsTable isLoading={false} jobs={siemJobs} onJobStateChange={onJobStateChangeMock} /> <JobsTable isLoading={false} jobs={siemJobs} onJobStateChange={onJobStateChangeMock} />
); );
wrapper wrapper
.find('[data-test-subj="job-switch"] input') .find('button[data-test-subj="job-switch"]')
.first() .first()
.simulate('change', { .simulate('click', {
target: { checked: true }, target: { checked: true },
}); });
expect(onJobStateChangeMock.mock.calls[0]).toEqual([siemJobs[0], 1571022859393, true]); expect(onJobStateChangeMock.mock.calls[0]).toEqual([siemJobs[0], 1571022859393, true]);

View file

@ -31,9 +31,9 @@ describe('NetworkTopNFlow Select direction', () => {
const wrapper = mount(<IsPtrIncluded isPtrIncluded={false} onChange={mockOnChange} />); const wrapper = mount(<IsPtrIncluded isPtrIncluded={false} onChange={mockOnChange} />);
wrapper wrapper
.find('input') .find('button')
.first() .first()
.simulate('change', event); .simulate('click', event);
wrapper.update(); wrapper.update();

View file

@ -213,13 +213,7 @@ const AllRules = React.memo(() => {
field: 'activate', field: 'activate',
name: 'Activate', name: 'Activate',
render: (value: ColumnTypes['activate']) => ( render: (value: ColumnTypes['activate']) => (
// Michael: Uncomment props below when EUI 14.9.0 is added to Kibana. <EuiSwitch checked={value} label="Activate" onChange={() => {}} showLabel={false} />
<EuiSwitch
checked={value}
// label="Activate"
onChange={() => {}}
// showLabel={false}
/>
), ),
sortable: true, sortable: true,
width: '65px', width: '65px',

View file

@ -102,9 +102,8 @@ export class FeatureTable extends Component<Props, {}> {
id={record.feature.id} id={record.feature.id}
checked={checked} checked={checked}
onChange={this.onChange(record.feature.id) as any} onChange={this.onChange(record.feature.id) as any}
aria-label={ label={`${record.feature.name} visible`}
checked ? `${record.feature.name} visible` : `${record.feature.name} disabled` showLabel={false}
}
/> />
); );
}, },

View file

@ -233,8 +233,8 @@ function toggleFeature(wrapper: ReactWrapper<any, any>) {
wrapper wrapper
.find(EuiSwitch) .find(EuiSwitch)
.find('input') .find('button')
.simulate('change', { target: { checked: false } }); .simulate('click');
wrapper.update(); wrapper.update();
} }

View file

@ -47,7 +47,7 @@ export class DeprecationLoggingToggleUI extends React.Component<
id="xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingToggleSwitch" id="xpack.upgradeAssistant.overviewTab.steps.deprecationLogsStep.enableDeprecationLoggingToggleSwitch"
data-test-subj="upgradeAssistantDeprecationToggle" data-test-subj="upgradeAssistantDeprecationToggle"
label={this.renderLoggingState()} label={this.renderLoggingState()}
checked={loggingEnabled} checked={loggingEnabled || false}
onChange={this.toggleLogging} onChange={this.toggleLogging}
disabled={loadingState === LoadingState.Loading || loadingState === LoadingState.Error} disabled={loadingState === LoadingState.Loading || loadingState === LoadingState.Error}
/> />

View file

@ -184,7 +184,7 @@
"@elastic/ctags-langserver": "^0.1.11", "@elastic/ctags-langserver": "^0.1.11",
"@elastic/datemath": "5.0.2", "@elastic/datemath": "5.0.2",
"@elastic/ems-client": "1.0.5", "@elastic/ems-client": "1.0.5",
"@elastic/eui": "14.8.0", "@elastic/eui": "14.9.0",
"@elastic/filesaver": "1.1.2", "@elastic/filesaver": "1.1.2",
"@elastic/javascript-typescript-langserver": "^0.3.3", "@elastic/javascript-typescript-langserver": "^0.3.3",
"@elastic/lsp-extension": "^0.1.2", "@elastic/lsp-extension": "^0.1.2",

View file

@ -310,14 +310,13 @@ export function GisPageProvider({ getService, getPageObjects }) {
} }
async disableApplyGlobalQuery() { async disableApplyGlobalQuery() {
const element = await testSubjects.find('mapLayerPanelApplyGlobalQueryCheckbox'); const isSelected = await testSubjects.getAttribute('mapLayerPanelApplyGlobalQueryCheckbox', 'aria-checked');
const isSelected = await element.isSelected(); if(isSelected === 'true') {
if(isSelected) {
await retry.try(async () => { await retry.try(async () => {
log.debug(`disabling applyGlobalQuery`); log.debug(`disabling applyGlobalQuery`);
await testSubjects.click('mapLayerPanelApplyGlobalQueryCheckbox'); await testSubjects.click('mapLayerPanelApplyGlobalQueryCheckbox');
const isStillSelected = await element.isSelected(); const isStillSelected = await testSubjects.getAttribute('mapLayerPanelApplyGlobalQueryCheckbox', 'aria-checked');
if (isStillSelected) { if (isStillSelected === 'true') {
throw new Error('applyGlobalQuery not disabled'); throw new Error('applyGlobalQuery not disabled');
} }
}); });

View file

@ -45,7 +45,7 @@ export function UpgradeAssistantProvider({ getService, getPageObjects }) {
async expectDeprecationLoggingLabel(labelText) { async expectDeprecationLoggingLabel(labelText) {
return await retry.try(async () => { return await retry.try(async () => {
log.debug('expectDeprecationLoggingLabel()'); log.debug('expectDeprecationLoggingLabel()');
const label = await find.byCssSelector('[data-test-subj="upgradeAssistantDeprecationToggle"] ~ label'); const label = await find.byCssSelector('[data-test-subj="upgradeAssistantDeprecationToggle"] ~ p');
const value = await label.getVisibleText(); const value = await label.getVisibleText();
expect(value).to.equal(labelText); expect(value).to.equal(labelText);
}); });

View file

@ -181,11 +181,12 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
sectionOptions: SectionOptions = { withAdvancedSection: true } sectionOptions: SectionOptions = { withAdvancedSection: true }
): Promise<boolean> { ): Promise<boolean> {
let subj = 'mlJobWizardSwitchModelPlot'; let subj = 'mlJobWizardSwitchModelPlot';
const isSelected = await testSubjects.getAttribute(subj, 'aria-checked');
if (sectionOptions.withAdvancedSection === true) { if (sectionOptions.withAdvancedSection === true) {
await this.ensureAdvancedSectionOpen(); await this.ensureAdvancedSectionOpen();
subj = advancedSectionSelector(subj); subj = advancedSectionSelector(subj);
} }
return await testSubjects.isSelected(subj); return isSelected === 'true';
}, },
async assertModelPlotSwitchCheckedState( async assertModelPlotSwitchCheckedState(
@ -213,11 +214,12 @@ export function MachineLearningJobWizardCommonProvider({ getService }: FtrProvid
sectionOptions: SectionOptions = { withAdvancedSection: true } sectionOptions: SectionOptions = { withAdvancedSection: true }
): Promise<boolean> { ): Promise<boolean> {
let subj = 'mlJobWizardSwitchUseDedicatedIndex'; let subj = 'mlJobWizardSwitchUseDedicatedIndex';
const isSelected = await testSubjects.getAttribute(subj, 'aria-checked');
if (sectionOptions.withAdvancedSection === true) { if (sectionOptions.withAdvancedSection === true) {
await this.ensureAdvancedSectionOpen(); await this.ensureAdvancedSectionOpen();
subj = advancedSectionSelector(subj); subj = advancedSectionSelector(subj);
} }
return await testSubjects.isSelected(subj); return isSelected === 'true';
}, },
async assertDedicatedIndexSwitchCheckedState( async assertDedicatedIndexSwitchCheckedState(

View file

@ -174,7 +174,13 @@ export const registerTestBed = <T extends string = string>(
checkBox.simulate('change', { target: { checked: isChecked } }); checkBox.simulate('change', { target: { checked: isChecked } });
}; };
const toggleEuiSwitch: TestBed<T>['form']['toggleEuiSwitch'] = selectCheckBox; // Same API as "selectCheckBox" const toggleEuiSwitch: TestBed<T>['form']['toggleEuiSwitch'] = testSubject => {
const checkBox = find(testSubject);
if (!checkBox.length) {
throw new Error(`"${testSubject}" was not found.`);
}
checkBox.simulate('click');
};
const setComboBoxValue: TestBed<T>['form']['setComboBoxValue'] = ( const setComboBoxValue: TestBed<T>['form']['setComboBoxValue'] = (
comboBoxTestSubject, comboBoxTestSubject,

View file

@ -1151,10 +1151,10 @@
tabbable "^1.1.0" tabbable "^1.1.0"
uuid "^3.1.0" uuid "^3.1.0"
"@elastic/eui@14.8.0": "@elastic/eui@14.9.0":
version "14.8.0" version "14.9.0"
resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-14.8.0.tgz#777d29852998e52e8fc6dfb1869a4b32d74c72bb" resolved "https://registry.yarnpkg.com/@elastic/eui/-/eui-14.9.0.tgz#934ab8d51c56671635dc17ac20ec325f43ceda75"
integrity sha512-p6TZv6Z+ENzw6JnCyXVQtvEOo7eEct8Qb/S4aS4EXK1WIyGB35Ra/a/pb3bLQbbZ2mSZtCr1sk+XVUq0qDpytw== integrity sha512-0ZztvfRO3SNgHtS8a+4i6CSG3Yc+C0Kodzc7obY5wkOzissrnbwLZdU79hU/H6DHYCt/zYDdGcrDp6BeD67RtQ==
dependencies: dependencies:
"@types/lodash" "^4.14.116" "@types/lodash" "^4.14.116"
"@types/numeral" "^0.0.25" "@types/numeral" "^0.0.25"