Skip to content

Commit

Permalink
Updated reference to mixins Sass file.
Browse files Browse the repository at this point in the history
Updated snapshots for Jest Test Suite #5 to account for EuiButton Emotion conversion. Updated unit tests that target EuiButton to simulate click events. These tests have been updated to target a button element to prevent undefined click event errors
  • Loading branch information
breehall committed Sep 28, 2022
1 parent fe7286e commit 0870bfe
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('SearchTimeoutError', () => {
const component = mount(e.getErrorMessage(startMock.application));

expect(component.find('EuiButton').length).toBe(1);
component.find('EuiButton').simulate('click');
component.find('button[data-test-subj="searchTimeoutError"]').simulate('click');
expect(startMock.application.navigateToApp).toHaveBeenCalledWith('management', {
path: '/kibana/settings',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import { SavedObjectFinderCreateNew } from '../saved_object_finder_create_new';
import { shallow } from 'enzyme';
import { EuiButton, EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '@elastic/eui';
import { EuiContextMenuItem, EuiContextMenuPanel, EuiPopover } from '@elastic/eui';
import { mountWithIntl } from '@kbn/test-jest-helpers';

describe('SavedObjectFinderCreateNew', () => {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useState, ChangeEvent } from 'react';
import PropTypes from 'prop-types';
import { EuiFlexGroup, EuiFlexItem, EuiFormRow, EuiButton, EuiFieldText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { ButtonSize } from '@elastic/eui/src/components/button/button';
import { EuiButtonSize } from '@elastic/eui/src/components/button/button';
import { FlexGroupGutterSize } from '@elastic/eui/src/components/flex/flex_group';
import { getTimeInterval } from '../../../lib/time_interval';

Expand All @@ -36,7 +36,7 @@ const strings = {

interface Props {
gutterSize: FlexGroupGutterSize;
buttonSize: ButtonSize;
buttonSize: EuiButtonSize;
onSubmit: (interval: number) => void;
defaultValue: any;
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
}

@mixin euiFlyout {
border-left: $euiFlyoutBorder;
border-left: $euiBorderThin;
// The mixin augments the above
// sass-lint:disable mixins-before-declarations
@include euiBottomShadowLarge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe('ConfigPanel', () => {
});

act(() => {
instance.find('[data-test-subj="lnsLayerAddButton"]').first().simulate('click');
instance.find('button[data-test-subj="lnsLayerAddButton"]').first().simulate('click');
});
const focusedEl = document.activeElement;
expect(focusedEl?.children[0].getAttribute('data-test-subj')).toEqual('lns-layerPanel-1');
Expand All @@ -269,7 +269,7 @@ describe('ConfigPanel', () => {
layerType: LayerType = layerTypes.REFERENCELINE
) {
act(() => {
instance.find('[data-test-subj="lnsLayerAddButton"]').first().simulate('click');
instance.find('button[data-test-subj="lnsLayerAddButton"]').first().simulate('click');
});
instance.update();
act(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('chart_switch', () => {
}

function showFlyout(instance: ReactWrapper) {
instance.find('[data-test-subj="lnsChartSwitchPopover"]').first().simulate('click');
instance.find('button[data-test-subj="lnsChartSwitchPopover"]').first().simulate('click');
}

function switchTo(subType: string, instance: ReactWrapper) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '../../../mixins';
@import '../../mixins';

.lnsPalettePanelContainer {
// Use the EuiFlyout style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { mountWithIntl } from '@kbn/test-jest-helpers';
import { DataTableToolbar } from './toolbar';
import { DatatableVisualizationState } from '../visualization';
import { FramePublicAPI, VisualizationToolbarProps } from '../../../types';
import { ToolbarButton } from '@kbn/kibana-react-plugin/public';
import { ReactWrapper } from 'enzyme';
import { PagingState } from '../../../../common/expressions';
import { EuiButtonGroup, EuiRange } from '@elastic/eui';
Expand All @@ -35,7 +34,7 @@ class Harness {
}

togglePopover() {
this.wrapper.find(ToolbarButton).simulate('click');
this.wrapper.find('button[data-test-subj="lnsVisualOptionsButton"]').simulate('click');
}

public get rowHeight() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import React, { FormEvent } from 'react';
import { mountWithIntl } from '@kbn/test-jest-helpers';
import { ToolbarButton } from '@kbn/kibana-react-plugin/public';
import { ReactWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { FramePublicAPI, VisualizationToolbarProps } from '../../../types';
Expand All @@ -31,7 +30,7 @@ class Harness {
}

togglePopover() {
this.wrapper.find(ToolbarButton).simulate('click');
this.wrapper.find('button[data-test-subj="lnsVisualOptionsButton"]').simulate('click');
}

public get titleLabel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { MetricVisualizationState } from './visualization';
import { createMockFramePublicAPI } from '../../mocks';
import { HTMLAttributes, ReactWrapper } from 'enzyme';
import { EuiFieldText } from '@elastic/eui';
import { ToolbarButton } from '@kbn/kibana-react-plugin/public';
import { act } from 'react-dom/test-utils';

jest.mock('lodash', () => {
Expand Down Expand Up @@ -64,7 +63,7 @@ describe('metric toolbar', () => {
}

public get textOptionsButton() {
const toolbarButtons = this._wrapper.find(ToolbarButton);
const toolbarButtons = this._wrapper.find('button[data-test-subj="lnsLabelsButton"]');
return toolbarButtons.at(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ describe('SessionView component', () => {
render();

await waitFor(() => {
expect(renderResult.queryByTestId('sessionView:TTYPlayerToggle')).toHaveClass(
'euiButtonIcon-isDisabled'
expect(renderResult.queryByTestId('sessionView:TTYPlayerToggle')?.classList[2]).toContain(
'disabled'
);
});
});
Expand Down

0 comments on commit 0870bfe

Please sign in to comment.