Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Emotion] Pre-emptively fix/regression test form components with tricky className/css locations #6254

Merged
merged 4 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update EuiDualRange ahead of time to accept custom css
see previous EuiCheckbox commit message for rationale
  • Loading branch information
cee-chen committed Sep 20, 2022
commit be53f60da3603ff5da13213fc8e135e4e9ae3423
28 changes: 14 additions & 14 deletions src/components/form/range/__snapshots__/dual_range.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`EuiDualRange allows value prop to accept empty strings 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand All @@ -24,7 +24,7 @@ exports[`EuiDualRange allows value prop to accept empty strings 1`] = `

exports[`EuiDualRange allows value prop to accept numbers 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -54,7 +54,7 @@ exports[`EuiDualRange allows value prop to accept numbers 1`] = `

exports[`EuiDualRange input props can be applied to min and max inputs 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
class="euiFormControlLayout"
Expand Down Expand Up @@ -129,7 +129,7 @@ exports[`EuiDualRange input props can be applied to min and max inputs 1`] = `

exports[`EuiDualRange is rendered 1`] = `
<div
class="euiRangeWrapper euiDualRange testClass1 testClass2"
class="euiRangeWrapper euiDualRange testClass1 testClass2 emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -162,7 +162,7 @@ exports[`EuiDualRange is rendered 1`] = `

exports[`EuiDualRange props compressed should render 1`] = `
<div
class="euiRangeWrapper euiRangeWrapper--compressed euiDualRange"
class="euiRangeWrapper euiRangeWrapper--compressed euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -192,7 +192,7 @@ exports[`EuiDualRange props compressed should render 1`] = `

exports[`EuiDualRange props custom ticks should render 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -251,7 +251,7 @@ exports[`EuiDualRange props custom ticks should render 1`] = `

exports[`EuiDualRange props disabled should render 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -282,7 +282,7 @@ exports[`EuiDualRange props disabled should render 1`] = `

exports[`EuiDualRange props fullWidth should render 1`] = `
<div
class="euiRangeWrapper euiRangeWrapper--fullWidth euiDualRange"
class="euiRangeWrapper euiRangeWrapper--fullWidth euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -312,7 +312,7 @@ exports[`EuiDualRange props fullWidth should render 1`] = `

exports[`EuiDualRange props inputs should render 1`] = `
<div
class="euiRangeWrapper euiDualRange testClass1 testClass2"
class="euiRangeWrapper euiDualRange testClass1 testClass2 emotion-euiDualRange"
>
<div
class="euiFormControlLayout"
Expand Down Expand Up @@ -389,7 +389,7 @@ exports[`EuiDualRange props inputs should render 1`] = `

exports[`EuiDualRange props isDraggable should render 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -419,7 +419,7 @@ exports[`EuiDualRange props isDraggable should render 1`] = `

exports[`EuiDualRange props labels should render 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<label
class="euiRangeLabel euiRangeLabel--min"
Expand Down Expand Up @@ -459,7 +459,7 @@ exports[`EuiDualRange props labels should render 1`] = `

exports[`EuiDualRange props levels should render 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -556,7 +556,7 @@ exports[`EuiDualRange props loading should display when showInput="inputWithPopo

exports[`EuiDualRange props range should render 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down Expand Up @@ -632,7 +632,7 @@ exports[`EuiDualRange props slider should display in popover 1`] = `

exports[`EuiDualRange props ticks should render 1`] = `
<div
class="euiRangeWrapper euiDualRange"
class="euiRangeWrapper euiDualRange emotion-euiDualRange"
>
<div
aria-hidden="false"
Expand Down
10 changes: 10 additions & 0 deletions src/components/form/range/dual_range.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../../test/required_props';
import { shouldRenderCustomStyles } from '../../../test/internal';

import { EuiDualRange } from './dual_range';

Expand All @@ -17,6 +18,15 @@ const props = {
};

describe('EuiDualRange', () => {
shouldRenderCustomStyles(
<EuiDualRange {...props} value={['1', '8']} />,
{ skipStyles: true } // styles get applied to the underlying slider instead of the className wrapper
);
shouldRenderCustomStyles(
<EuiDualRange {...props} value={['1', '8']} showInput />,
{ childProps: ['minInputProps', 'maxInputProps'], skipParentTest: true }
);

test('is rendered', () => {
const component = render(
<EuiDualRange
Expand Down
7 changes: 7 additions & 0 deletions src/components/form/range/dual_range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import React, { Component } from 'react';
import { css } from '@emotion/react';
import classNames from 'classnames';

import { keys } from '../../../services';
Expand Down Expand Up @@ -501,6 +502,7 @@ export class EuiDualRange extends Component<EuiDualRangeProps> {
render() {
const {
className,
css: customCss,
compressed,
disabled,
fullWidth,
Expand Down Expand Up @@ -613,8 +615,13 @@ export class EuiDualRange extends Component<EuiDualRangeProps> {
this.state.rangeWidth
)
: { left: '0' };

const styles = { euiDualRange: css`` }; // TODO: Emotion conversion
const cssStyles = [styles.euiDualRange, customCss];

const theRange = (
<EuiRangeWrapper
css={cssStyles}
className={classes}
fullWidth={fullWidth}
compressed={compressed}
Expand Down