pebble-web 2.25.1 → 2.25.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/typings/Button.d.ts +1 -0
- package/dist/components/typings/Control.d.ts +1 -0
- package/dist/components/typings/DateInput.d.ts +1 -0
- package/dist/components/typings/Dropdown.d.ts +1 -0
- package/dist/components/typings/Input.d.ts +1 -0
- package/dist/components/typings/Loader.d.ts +1 -0
- package/dist/components/typings/Message.d.ts +1 -0
- package/dist/components/typings/OptionGroup.d.ts +1 -0
- package/dist/components/typings/OptionGroupCheckBox.d.ts +1 -0
- package/dist/components/typings/OptionGroupRadio.d.ts +1 -0
- package/dist/components/typings/PhoneNumberInput.d.ts +1 -0
- package/dist/components/typings/RadioGroup.d.ts +1 -0
- package/dist/components/typings/Search.d.ts +1 -0
- package/dist/components/typings/SecondaryInput.d.ts +1 -0
- package/dist/components/typings/Select.d.ts +1 -0
- package/dist/components/typings/Text.d.ts +1 -0
- package/dist/components/typings/Typeahead.d.ts +1 -0
- package/dist/pebble-web.dev.js +244 -112
- package/dist/pebble-web.dev.js.map +1 -1
- package/dist/pebble-web.es.dev.js +178 -57
- package/dist/pebble-web.es.dev.js.map +1 -1
- package/dist/pebble-web.es.js +173 -52
- package/dist/pebble-web.es.js.map +1 -1
- package/dist/pebble-web.js +239 -107
- package/dist/pebble-web.js.map +1 -1
- package/dist/pebble-web.module.dev.js +244 -112
- package/dist/pebble-web.module.dev.js.map +1 -1
- package/dist/pebble-web.module.js +239 -107
- package/dist/pebble-web.module.js.map +1 -1
- package/dist/pebble-web.umd.dev.js +244 -112
- package/dist/pebble-web.umd.dev.js.map +1 -1
- package/dist/pebble-web.umd.js +239 -107
- package/dist/pebble-web.umd.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/testIds.d.ts +53 -0
- package/package.json +1 -1
- package/src/components/Button.tsx +3 -1
- package/src/components/DateInput.tsx +3 -1
- package/src/components/DropDown.tsx +3 -1
- package/src/components/Input.tsx +13 -3
- package/src/components/Loader.tsx +3 -1
- package/src/components/Message.tsx +3 -1
- package/src/components/NativeDateInput.tsx +2 -1
- package/src/components/OptionGroupCheckBox.tsx +14 -2
- package/src/components/PhoneNumberInput.tsx +7 -1
- package/src/components/RadioGroup.tsx +20 -3
- package/src/components/Search.tsx +3 -1
- package/src/components/SecondaryInput.tsx +7 -2
- package/src/components/Select.tsx +13 -1
- package/src/components/Tabs.tsx +1 -1
- package/src/components/Text.tsx +7 -2
- package/src/components/TimePicker.tsx +2 -2
- package/src/components/Toast.tsx +2 -2
- package/src/components/TypeAhead.tsx +14 -3
- package/src/components/__tests__/__snapshots__/optionGroup.test.tsx.snap +0 -3
- package/src/components/__tests__/__snapshots__/select.test.tsx.snap +3 -0
- package/src/components/__tests__/__snapshots__/timepicker.test.tsx.snap +18 -18
- package/src/components/__tests__/select.test.tsx +19 -30
- package/src/components/__tests__/timepicker.test.tsx +4 -14
- package/src/components/shared/Control.tsx +3 -1
- package/src/components/shared/OptionGroup.tsx +23 -5
- package/src/components/typings/Button.ts +1 -0
- package/src/components/typings/Control.ts +1 -0
- package/src/components/typings/DateInput.ts +1 -0
- package/src/components/typings/Dropdown.ts +1 -0
- package/src/components/typings/Input.ts +1 -0
- package/src/components/typings/Loader.ts +1 -0
- package/src/components/typings/Message.ts +1 -0
- package/src/components/typings/OptionGroup.ts +1 -0
- package/src/components/typings/OptionGroupCheckBox.ts +1 -0
- package/src/components/typings/OptionGroupRadio.ts +1 -0
- package/src/components/typings/PhoneNumberInput.ts +1 -0
- package/src/components/typings/RadioGroup.ts +1 -0
- package/src/components/typings/Search.ts +1 -0
- package/src/components/typings/SecondaryInput.ts +1 -0
- package/src/components/typings/Select.ts +1 -0
- package/src/components/typings/Text.ts +1 -0
- package/src/components/typings/Typeahead.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/testIds.ts +98 -0
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
declare type TestIdMap = Record<string, string | object>;
|
|
2
|
+
declare type BaseSelectIds = {
|
|
3
|
+
inputId: string;
|
|
4
|
+
optionGroupId: string;
|
|
5
|
+
};
|
|
6
|
+
declare type OptionGroupCheckBoxIds = ReturnType<typeof getOptionGroupCheckBoxTestIds>;
|
|
7
|
+
declare type OptionGroupRadioIds = ReturnType<typeof getOptionGroupRadioTestIds>;
|
|
8
|
+
export declare function getTestIds<T extends TestIdMap>(id: string | undefined, builder: (_id: string) => Partial<T>): Partial<T>;
|
|
9
|
+
export declare function getOptionTestId(id: string, index: number): string;
|
|
10
|
+
export declare function getRadioGroupTestIds(id: string): {
|
|
11
|
+
optionId: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function getOptionGroupTestIds(id: string): {
|
|
14
|
+
searchBoxId: string;
|
|
15
|
+
optionId: string;
|
|
16
|
+
selectVisibleId: string;
|
|
17
|
+
clearVisibleId: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const getOptionGroupRadioTestIds: (id: string) => {
|
|
20
|
+
searchBoxId: string;
|
|
21
|
+
optionId: string;
|
|
22
|
+
selectVisibleId: string;
|
|
23
|
+
clearVisibleId: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function getOptionGroupCheckBoxTestIds(id: string): {
|
|
26
|
+
searchBoxId: string;
|
|
27
|
+
optionId: string;
|
|
28
|
+
selectVisibleId: string;
|
|
29
|
+
clearVisibleId: string;
|
|
30
|
+
applyButtonId: string;
|
|
31
|
+
clearButtonId: string;
|
|
32
|
+
};
|
|
33
|
+
export declare function getPhoneNumberInputTestIds(id: string): {
|
|
34
|
+
phoneId: string;
|
|
35
|
+
countryId: string;
|
|
36
|
+
countryInputIds: BaseSelectIds & {
|
|
37
|
+
searchBoxId: string;
|
|
38
|
+
optionId: string;
|
|
39
|
+
selectVisibleId: string;
|
|
40
|
+
clearVisibleId: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare function getSelectInputTestIds(id: string, multiSelect: true): BaseSelectIds & OptionGroupCheckBoxIds;
|
|
44
|
+
export declare function getSelectInputTestIds(id: string, multiSelect?: false): BaseSelectIds & OptionGroupRadioIds;
|
|
45
|
+
export declare function getSelectInputTestIds(id: string, multiSelect?: boolean): (BaseSelectIds & OptionGroupCheckBoxIds) | (BaseSelectIds & OptionGroupRadioIds);
|
|
46
|
+
export declare function getTypeaheadTestIds(id: string): {
|
|
47
|
+
searchBoxId: string;
|
|
48
|
+
optionId: string;
|
|
49
|
+
selectVisibleId: string;
|
|
50
|
+
clearVisibleId: string;
|
|
51
|
+
optionGroupId: string;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
package/package.json
CHANGED
|
@@ -23,7 +23,8 @@ const Button: React.FunctionComponent<ButtonProps> = ({
|
|
|
23
23
|
loading,
|
|
24
24
|
outline,
|
|
25
25
|
size = "small",
|
|
26
|
-
buttonProps
|
|
26
|
+
buttonProps,
|
|
27
|
+
testId
|
|
27
28
|
}: ButtonProps) => {
|
|
28
29
|
const disableAction = disabled || loading;
|
|
29
30
|
|
|
@@ -40,6 +41,7 @@ const Button: React.FunctionComponent<ButtonProps> = ({
|
|
|
40
41
|
onClick={!disableAction ? onClick : undefined}
|
|
41
42
|
style={{ width }}
|
|
42
43
|
disabled={disabled}
|
|
44
|
+
data-testid={testId}
|
|
43
45
|
{...buttonProps}
|
|
44
46
|
>
|
|
45
47
|
{loading ? <Loader color={colors.white.base} scale={0.4} /> : children}
|
|
@@ -94,7 +94,8 @@ export default class DateInput extends React.PureComponent<
|
|
|
94
94
|
initiallyOpen,
|
|
95
95
|
onOutsideClick,
|
|
96
96
|
controlled,
|
|
97
|
-
isOpen
|
|
97
|
+
isOpen,
|
|
98
|
+
testId
|
|
98
99
|
} = this.props;
|
|
99
100
|
|
|
100
101
|
const _wrapperClassName = cx(wrapperStyle, wrapperClassName);
|
|
@@ -131,6 +132,7 @@ export default class DateInput extends React.PureComponent<
|
|
|
131
132
|
}}
|
|
132
133
|
className={cx(inputStyle, inputProps && inputProps.className)}
|
|
133
134
|
disabled={disabled}
|
|
135
|
+
testId={testId}
|
|
134
136
|
/>
|
|
135
137
|
)}
|
|
136
138
|
</Rifm>
|
|
@@ -48,7 +48,8 @@ class DropDown extends React.PureComponent<DropdownProps, DropdownState> {
|
|
|
48
48
|
disabled,
|
|
49
49
|
labelClassName,
|
|
50
50
|
controlled,
|
|
51
|
-
onOutsideClick
|
|
51
|
+
onOutsideClick,
|
|
52
|
+
testId
|
|
52
53
|
} = this.props;
|
|
53
54
|
|
|
54
55
|
const _isDropDownOpen = controlled
|
|
@@ -82,6 +83,7 @@ class DropDown extends React.PureComponent<DropdownProps, DropdownState> {
|
|
|
82
83
|
onClick={this.toggleDropdown}
|
|
83
84
|
disabled={disabled}
|
|
84
85
|
className={labelClassName}
|
|
86
|
+
testId={testId}
|
|
85
87
|
>
|
|
86
88
|
{buttonLabel}
|
|
87
89
|
</DropDownButton>
|
package/src/components/Input.tsx
CHANGED
|
@@ -84,7 +84,8 @@ class Input extends React.PureComponent<InputProps, InputState> {
|
|
|
84
84
|
onClick,
|
|
85
85
|
loading,
|
|
86
86
|
leftElement,
|
|
87
|
-
rightElement
|
|
87
|
+
rightElement,
|
|
88
|
+
testId
|
|
88
89
|
} = this.props;
|
|
89
90
|
const { isFocused } = this.state;
|
|
90
91
|
|
|
@@ -152,9 +153,18 @@ class Input extends React.PureComponent<InputProps, InputState> {
|
|
|
152
153
|
{leftElement?.()}
|
|
153
154
|
|
|
154
155
|
{this.props.textArea ? (
|
|
155
|
-
<textarea
|
|
156
|
+
<textarea
|
|
157
|
+
{..._inputProps}
|
|
158
|
+
{...this.props.inputProps}
|
|
159
|
+
data-testid={testId}
|
|
160
|
+
/>
|
|
156
161
|
) : (
|
|
157
|
-
<input
|
|
162
|
+
<input
|
|
163
|
+
type={type}
|
|
164
|
+
{..._inputProps}
|
|
165
|
+
{...this.props.inputProps}
|
|
166
|
+
data-testid={testId}
|
|
167
|
+
/>
|
|
158
168
|
)}
|
|
159
169
|
|
|
160
170
|
{loading && (
|
|
@@ -7,7 +7,8 @@ import { cx } from "emotion";
|
|
|
7
7
|
const Loader: React.FunctionComponent<LoaderProps> = ({
|
|
8
8
|
color = colors.gray.darker,
|
|
9
9
|
scale = 1,
|
|
10
|
-
className
|
|
10
|
+
className,
|
|
11
|
+
testId
|
|
11
12
|
}) => {
|
|
12
13
|
const style = {
|
|
13
14
|
backgroundColor: color
|
|
@@ -16,6 +17,7 @@ const Loader: React.FunctionComponent<LoaderProps> = ({
|
|
|
16
17
|
<div
|
|
17
18
|
className={cx(spinnerStyle, className)}
|
|
18
19
|
style={{ transform: `scale(${scale})` }}
|
|
20
|
+
data-testid={testId}
|
|
19
21
|
>
|
|
20
22
|
<div style={style} />
|
|
21
23
|
<div style={style} />
|
|
@@ -7,7 +7,8 @@ import { AlertProps } from "./typings/Message";
|
|
|
7
7
|
const Message: React.FunctionComponent<AlertProps> = ({
|
|
8
8
|
intent,
|
|
9
9
|
className,
|
|
10
|
-
text
|
|
10
|
+
text,
|
|
11
|
+
testId
|
|
11
12
|
}) => {
|
|
12
13
|
const bColor = _colors[intent];
|
|
13
14
|
|
|
@@ -22,6 +23,7 @@ const Message: React.FunctionComponent<AlertProps> = ({
|
|
|
22
23
|
style={{
|
|
23
24
|
backgroundColor: bColor
|
|
24
25
|
}}
|
|
26
|
+
data-testid={testId}
|
|
25
27
|
>
|
|
26
28
|
<i className={iconClass} />
|
|
27
29
|
{text}
|
|
@@ -12,7 +12,7 @@ export default class NativeDateInput extends React.PureComponent<
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
render() {
|
|
15
|
-
const { inputProps, placeholder, value, disabled } = this.props;
|
|
15
|
+
const { inputProps, placeholder, value, disabled, testId } = this.props;
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<Input
|
|
@@ -26,6 +26,7 @@ export default class NativeDateInput extends React.PureComponent<
|
|
|
26
26
|
fixLabelAtTop
|
|
27
27
|
{...inputProps}
|
|
28
28
|
disabled={disabled}
|
|
29
|
+
testId={testId}
|
|
29
30
|
/>
|
|
30
31
|
);
|
|
31
32
|
}
|
|
@@ -6,6 +6,7 @@ import OptionGroup from "./shared/OptionGroup";
|
|
|
6
6
|
import { OptionGroupCheckBoxProps } from "./typings/OptionGroupCheckBox";
|
|
7
7
|
import * as styles from "../components/styles/OptionGroupCheckBox.styles";
|
|
8
8
|
import { OptionProps } from "./typings/Option";
|
|
9
|
+
import { getOptionGroupCheckBoxTestIds, getTestIds } from "../utils/testIds";
|
|
9
10
|
|
|
10
11
|
export default class OptionGroupCheckBox<
|
|
11
12
|
OptionType
|
|
@@ -52,6 +53,7 @@ export default class OptionGroupCheckBox<
|
|
|
52
53
|
onClear,
|
|
53
54
|
isSelected,
|
|
54
55
|
onChange,
|
|
56
|
+
testId,
|
|
55
57
|
...rest
|
|
56
58
|
} = this.props;
|
|
57
59
|
const advancedOptionsProps = {
|
|
@@ -59,6 +61,7 @@ export default class OptionGroupCheckBox<
|
|
|
59
61
|
clearVisible: this.clearVisible,
|
|
60
62
|
...this.props.advancedOptionsProps
|
|
61
63
|
};
|
|
64
|
+
const testIds = getTestIds(testId, getOptionGroupCheckBoxTestIds);
|
|
62
65
|
return (
|
|
63
66
|
<div className={cx(styles.optionGroupCheckBoxWrap, wrapClassName)}>
|
|
64
67
|
<OptionGroup<OptionType>
|
|
@@ -67,16 +70,25 @@ export default class OptionGroupCheckBox<
|
|
|
67
70
|
isSelected={isSelected || this.isSelected}
|
|
68
71
|
handleChange={this.handleChange}
|
|
69
72
|
multiSelect
|
|
73
|
+
testId={testId}
|
|
70
74
|
/>
|
|
71
75
|
|
|
72
76
|
{(onApply || onClear) && (
|
|
73
77
|
<div className={styles.optionGroupCheckBoxButtonWrap}>
|
|
74
78
|
{onClear && (
|
|
75
|
-
<Button
|
|
79
|
+
<Button
|
|
80
|
+
type="secondary"
|
|
81
|
+
onClick={onClear}
|
|
82
|
+
testId={testIds.clearButtonId}
|
|
83
|
+
>
|
|
76
84
|
Clear
|
|
77
85
|
</Button>
|
|
78
86
|
)}
|
|
79
|
-
{onApply &&
|
|
87
|
+
{onApply && (
|
|
88
|
+
<Button onClick={this.onApply} testId={testIds.applyButtonId}>
|
|
89
|
+
Apply
|
|
90
|
+
</Button>
|
|
91
|
+
)}
|
|
80
92
|
</div>
|
|
81
93
|
)}
|
|
82
94
|
</div>
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "./styles/PhoneNumberInput.styles";
|
|
11
11
|
import { labelStyle } from "./styles/Input.styles";
|
|
12
12
|
import { colors } from "pebble-shared";
|
|
13
|
+
import { getPhoneNumberInputTestIds, getTestIds } from "../utils/testIds";
|
|
13
14
|
|
|
14
15
|
export default class PhoneNumberInput<
|
|
15
16
|
OptionType = string
|
|
@@ -40,8 +41,11 @@ export default class PhoneNumberInput<
|
|
|
40
41
|
selectProps,
|
|
41
42
|
inputProps,
|
|
42
43
|
required,
|
|
43
|
-
placeholder
|
|
44
|
+
placeholder,
|
|
45
|
+
testId
|
|
44
46
|
} = this.props;
|
|
47
|
+
|
|
48
|
+
const testIds = getTestIds(testId, getPhoneNumberInputTestIds);
|
|
45
49
|
return (
|
|
46
50
|
<div className={cx(wrapper, className)}>
|
|
47
51
|
<label
|
|
@@ -61,6 +65,7 @@ export default class PhoneNumberInput<
|
|
|
61
65
|
selected={countryCode}
|
|
62
66
|
{...selectProps}
|
|
63
67
|
className={cx(selectStyle, selectProps && selectProps.className)}
|
|
68
|
+
testId={testIds.countryId}
|
|
64
69
|
>
|
|
65
70
|
{this.props.children}
|
|
66
71
|
</Select>
|
|
@@ -69,6 +74,7 @@ export default class PhoneNumberInput<
|
|
|
69
74
|
placeholder=""
|
|
70
75
|
value={phone}
|
|
71
76
|
{...inputProps}
|
|
77
|
+
testId={testIds.phoneId}
|
|
72
78
|
/>
|
|
73
79
|
</div>
|
|
74
80
|
);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { RadioProps } from "./typings/Radio";
|
|
3
3
|
import { RadioGroupProps } from "./typings/RadioGroup";
|
|
4
|
+
import {
|
|
5
|
+
getOptionTestId,
|
|
6
|
+
getRadioGroupTestIds,
|
|
7
|
+
getTestIds
|
|
8
|
+
} from "../utils/testIds";
|
|
4
9
|
|
|
5
10
|
export default class RadioGroup<OptionType> extends React.PureComponent<
|
|
6
11
|
RadioGroupProps<OptionType>
|
|
@@ -15,9 +20,18 @@ export default class RadioGroup<OptionType> extends React.PureComponent<
|
|
|
15
20
|
};
|
|
16
21
|
|
|
17
22
|
render() {
|
|
18
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
children,
|
|
25
|
+
selected,
|
|
26
|
+
className,
|
|
27
|
+
name,
|
|
28
|
+
disabled,
|
|
29
|
+
testId
|
|
30
|
+
} = this.props;
|
|
19
31
|
|
|
20
|
-
const
|
|
32
|
+
const testIds = getTestIds(testId, getRadioGroupTestIds);
|
|
33
|
+
|
|
34
|
+
const _children = React.Children.map(children, (_radio, i) => {
|
|
21
35
|
// `_radio as React.ReactElement<RadioProps>` is a hack
|
|
22
36
|
// Because React does not allow us to specify what sort of elements
|
|
23
37
|
// you can allow as children and leaves it on you to figure out
|
|
@@ -26,7 +40,10 @@ export default class RadioGroup<OptionType> extends React.PureComponent<
|
|
|
26
40
|
return React.cloneElement(radio, {
|
|
27
41
|
onChange: this.handleChange,
|
|
28
42
|
checked: selected === radio.props.value,
|
|
29
|
-
disabled
|
|
43
|
+
disabled,
|
|
44
|
+
testId: testIds.optionId
|
|
45
|
+
? getOptionTestId(testIds.optionId, i)
|
|
46
|
+
: undefined
|
|
30
47
|
});
|
|
31
48
|
});
|
|
32
49
|
|
|
@@ -27,7 +27,8 @@ class Search extends React.PureComponent<SearchProps> {
|
|
|
27
27
|
className,
|
|
28
28
|
clearable,
|
|
29
29
|
value,
|
|
30
|
-
loading
|
|
30
|
+
loading,
|
|
31
|
+
testId
|
|
31
32
|
} = this.props;
|
|
32
33
|
|
|
33
34
|
const wrapperClassName = cx(searchWrapperStyle, {
|
|
@@ -50,6 +51,7 @@ class Search extends React.PureComponent<SearchProps> {
|
|
|
50
51
|
ref={this.searchInputRef}
|
|
51
52
|
value={value}
|
|
52
53
|
{...inputProps}
|
|
54
|
+
data-testid={testId}
|
|
53
55
|
/>
|
|
54
56
|
{loading && <Loader scale={0.4} color={colors.violet.base} />}
|
|
55
57
|
{clearable && (
|
|
@@ -76,7 +76,8 @@ export default class SecondaryInput extends React.PureComponent<
|
|
|
76
76
|
message,
|
|
77
77
|
readOnly,
|
|
78
78
|
loading,
|
|
79
|
-
className
|
|
79
|
+
className,
|
|
80
|
+
testId
|
|
80
81
|
} = this.props;
|
|
81
82
|
const { isFocused } = this.state;
|
|
82
83
|
|
|
@@ -119,7 +120,11 @@ export default class SecondaryInput extends React.PureComponent<
|
|
|
119
120
|
onFocus={this.addFocus}
|
|
120
121
|
onBlur={this.removeFocus}
|
|
121
122
|
>
|
|
122
|
-
<input
|
|
123
|
+
<input
|
|
124
|
+
{..._inputProps}
|
|
125
|
+
{...this.props.inputProps}
|
|
126
|
+
data-testid={testId}
|
|
127
|
+
/>
|
|
123
128
|
<label className={placeholderClassName}>
|
|
124
129
|
{placeholder}
|
|
125
130
|
{required && (
|
|
@@ -16,6 +16,7 @@ import DropDown from "./DropDown";
|
|
|
16
16
|
import Input from "./Input";
|
|
17
17
|
import OptionGroupCheckBox from "./OptionGroupCheckBox";
|
|
18
18
|
import OptionGroupRadio from "./OptionGroupRadio";
|
|
19
|
+
import { getSelectInputTestIds, getTestIds } from "../utils/testIds";
|
|
19
20
|
|
|
20
21
|
function noop() {}
|
|
21
22
|
|
|
@@ -34,9 +35,17 @@ function Select<OptionType>(props: SelectProps<OptionType>) {
|
|
|
34
35
|
disabled,
|
|
35
36
|
isSelected,
|
|
36
37
|
placement,
|
|
37
|
-
modifiers
|
|
38
|
+
modifiers,
|
|
39
|
+
testId
|
|
38
40
|
} = props;
|
|
39
41
|
|
|
42
|
+
const singleSelectTestIds = getTestIds(testId, id =>
|
|
43
|
+
getSelectInputTestIds(id, false)
|
|
44
|
+
);
|
|
45
|
+
const multiSelectTestIds = getTestIds(testId, id =>
|
|
46
|
+
getSelectInputTestIds(id, true)
|
|
47
|
+
);
|
|
48
|
+
|
|
40
49
|
return (
|
|
41
50
|
<div
|
|
42
51
|
className={cx(selectWrapper, className, {
|
|
@@ -68,6 +77,7 @@ function Select<OptionType>(props: SelectProps<OptionType>) {
|
|
|
68
77
|
onDropdownToggle(isOpen);
|
|
69
78
|
}
|
|
70
79
|
}
|
|
80
|
+
data-testid={singleSelectTestIds.inputId}
|
|
71
81
|
>
|
|
72
82
|
<Input
|
|
73
83
|
className={selectInputWrapper}
|
|
@@ -153,6 +163,7 @@ function Select<OptionType>(props: SelectProps<OptionType>) {
|
|
|
153
163
|
})
|
|
154
164
|
}
|
|
155
165
|
{...commonProps}
|
|
166
|
+
testId={multiSelectTestIds.optionGroupId}
|
|
156
167
|
>
|
|
157
168
|
{children}
|
|
158
169
|
</OptionGroupCheckBox>
|
|
@@ -167,6 +178,7 @@ function Select<OptionType>(props: SelectProps<OptionType>) {
|
|
|
167
178
|
toggle();
|
|
168
179
|
}}
|
|
169
180
|
{...commonProps}
|
|
181
|
+
testId={singleSelectTestIds.optionGroupId}
|
|
170
182
|
>
|
|
171
183
|
{children}
|
|
172
184
|
</OptionGroupRadio>
|
package/src/components/Tabs.tsx
CHANGED
package/src/components/Text.tsx
CHANGED
|
@@ -7,14 +7,19 @@ const Text: React.FunctionComponent<TextProps> = ({
|
|
|
7
7
|
typography,
|
|
8
8
|
color = colors.gray.darker,
|
|
9
9
|
children,
|
|
10
|
-
className
|
|
10
|
+
className,
|
|
11
|
+
testId
|
|
11
12
|
}) => {
|
|
12
13
|
const _className = css({
|
|
13
14
|
...typography,
|
|
14
15
|
color
|
|
15
16
|
});
|
|
16
17
|
|
|
17
|
-
return
|
|
18
|
+
return (
|
|
19
|
+
<span className={cx(_className, className)} data-testid={testId}>
|
|
20
|
+
{children}
|
|
21
|
+
</span>
|
|
22
|
+
);
|
|
18
23
|
};
|
|
19
24
|
|
|
20
25
|
export default Text;
|
|
@@ -78,7 +78,7 @@ const TimePicker: React.FunctionComponent<TimePickerProps> = props => {
|
|
|
78
78
|
toggleDropdown();
|
|
79
79
|
}}
|
|
80
80
|
className={buttonStyle}
|
|
81
|
-
data-
|
|
81
|
+
data-testid="hour-label"
|
|
82
82
|
>
|
|
83
83
|
<span className={css({ marginRight: "15px" })}>
|
|
84
84
|
{selectedHour !== undefined
|
|
@@ -128,7 +128,7 @@ const TimePicker: React.FunctionComponent<TimePickerProps> = props => {
|
|
|
128
128
|
toggleDropdown();
|
|
129
129
|
}}
|
|
130
130
|
className={buttonStyle}
|
|
131
|
-
data-
|
|
131
|
+
data-testid="minute-label"
|
|
132
132
|
>
|
|
133
133
|
<span className={css({ marginRight: "15px" })}>
|
|
134
134
|
{selectedMinute !== undefined
|
package/src/components/Toast.tsx
CHANGED
|
@@ -124,12 +124,12 @@ class Toast extends React.PureComponent<ToastProps, ToastState> {
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
componentDidMount() {
|
|
127
|
-
emitter.on<EventType>("showToast", this.show);
|
|
127
|
+
emitter.on<EventType>("showToast", e => e && this.show(e));
|
|
128
128
|
emitter.on<EventType>("hideToast", this.hide);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
componentWillUnmount() {
|
|
132
|
-
emitter.off<EventType>("showToast", this.show);
|
|
132
|
+
emitter.off<EventType>("showToast", e => e && this.show(e));
|
|
133
133
|
emitter.off("hideToast", this.hide);
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -12,6 +12,7 @@ import OutsideClick from "./OutsideClick";
|
|
|
12
12
|
import OptionGroupRadio from "./OptionGroupRadio";
|
|
13
13
|
import { animated } from "react-spring/renderprops.cjs";
|
|
14
14
|
import MountTransition from "./shared/MountTransition";
|
|
15
|
+
import { getTestIds, getTypeaheadTestIds } from "../utils/testIds";
|
|
15
16
|
|
|
16
17
|
function defaultSearchBox<OptionType>(
|
|
17
18
|
{ registerChange, onFocus, value }: SearchBoxArgs,
|
|
@@ -44,6 +45,7 @@ function defaultSearchBox<OptionType>(
|
|
|
44
45
|
loading={props.loading}
|
|
45
46
|
required={props.required}
|
|
46
47
|
disabled={props.disabled}
|
|
48
|
+
testId={props.testId}
|
|
47
49
|
/>
|
|
48
50
|
);
|
|
49
51
|
}
|
|
@@ -97,9 +99,12 @@ export default class TypeAhead<OptionType> extends React.PureComponent<
|
|
|
97
99
|
className,
|
|
98
100
|
searchBox = defaultSearchBox,
|
|
99
101
|
dropdownClassName,
|
|
100
|
-
children
|
|
102
|
+
children,
|
|
103
|
+
testId
|
|
101
104
|
} = this.props;
|
|
102
105
|
|
|
106
|
+
const testIds = getTestIds(testId, getTypeaheadTestIds);
|
|
107
|
+
|
|
103
108
|
const { showSuggestions, value } = this.state;
|
|
104
109
|
|
|
105
110
|
return (
|
|
@@ -118,7 +123,10 @@ export default class TypeAhead<OptionType> extends React.PureComponent<
|
|
|
118
123
|
onFocus: this.onFocus,
|
|
119
124
|
value
|
|
120
125
|
},
|
|
121
|
-
|
|
126
|
+
{
|
|
127
|
+
...this.props,
|
|
128
|
+
testId: testIds.searchBoxId
|
|
129
|
+
}
|
|
122
130
|
)}
|
|
123
131
|
|
|
124
132
|
<MountTransition visible={showSuggestions} native>
|
|
@@ -127,7 +135,10 @@ export default class TypeAhead<OptionType> extends React.PureComponent<
|
|
|
127
135
|
style={transitionStyles}
|
|
128
136
|
className={cx(optionsWrapper, dropdownClassName)}
|
|
129
137
|
>
|
|
130
|
-
<OptionGroupRadio
|
|
138
|
+
<OptionGroupRadio
|
|
139
|
+
onChange={this.onSelect}
|
|
140
|
+
testId={testIds.optionGroupId}
|
|
141
|
+
>
|
|
131
142
|
{children}
|
|
132
143
|
</OptionGroupRadio>
|
|
133
144
|
</animated.div>
|
|
@@ -81,7 +81,6 @@ exports[`Component: OptionGroup default snapshot 1`] = `
|
|
|
81
81
|
|
|
82
82
|
<div
|
|
83
83
|
className="emotion-24"
|
|
84
|
-
data-test-id="optiongroup"
|
|
85
84
|
role="radiogroup"
|
|
86
85
|
style={
|
|
87
86
|
Object {
|
|
@@ -715,7 +714,6 @@ Array [
|
|
|
715
714
|
<div
|
|
716
715
|
aria-label="Search"
|
|
717
716
|
className="emotion-36"
|
|
718
|
-
data-test-id="optiongroup"
|
|
719
717
|
role="group"
|
|
720
718
|
style={
|
|
721
719
|
Object {
|
|
@@ -1380,7 +1378,6 @@ Array [
|
|
|
1380
1378
|
<div
|
|
1381
1379
|
aria-label="Search"
|
|
1382
1380
|
className="emotion-24"
|
|
1383
|
-
data-test-id="optiongroup"
|
|
1384
1381
|
role="radiogroup"
|
|
1385
1382
|
style={
|
|
1386
1383
|
Object {
|
|
@@ -172,6 +172,7 @@ exports[`Component: Select multi-select: snapshot 1`] = `
|
|
|
172
172
|
>
|
|
173
173
|
<div
|
|
174
174
|
className="emotion-6"
|
|
175
|
+
data-testid="test-multi-select-input"
|
|
175
176
|
onClick={[Function]}
|
|
176
177
|
>
|
|
177
178
|
<div
|
|
@@ -386,6 +387,7 @@ exports[`Component: Select single-select with searchbox: snapshot 1`] = `
|
|
|
386
387
|
>
|
|
387
388
|
<div
|
|
388
389
|
className="emotion-6"
|
|
390
|
+
data-testid="test-single-select-input"
|
|
389
391
|
onClick={[Function]}
|
|
390
392
|
>
|
|
391
393
|
<div
|
|
@@ -600,6 +602,7 @@ exports[`Component: Select single-select: snapshot 1`] = `
|
|
|
600
602
|
>
|
|
601
603
|
<div
|
|
602
604
|
className="emotion-6"
|
|
605
|
+
data-testid="test-single-select-input"
|
|
603
606
|
onClick={[Function]}
|
|
604
607
|
>
|
|
605
608
|
<div
|