pebble-web 2.25.2 → 2.26.1-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/Calendar.d.ts +1 -0
- package/dist/components/typings/CheckboxGroup.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/PopUp.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/index.d.ts +1 -0
- package/dist/pebble-web.dev.js +358 -164
- package/dist/pebble-web.dev.js.map +1 -1
- package/dist/pebble-web.es.dev.js +239 -70
- package/dist/pebble-web.es.dev.js.map +1 -1
- package/dist/pebble-web.es.js +233 -64
- package/dist/pebble-web.es.js.map +1 -1
- package/dist/pebble-web.js +352 -158
- package/dist/pebble-web.js.map +1 -1
- package/dist/pebble-web.module.dev.js +347 -165
- package/dist/pebble-web.module.dev.js.map +1 -1
- package/dist/pebble-web.module.js +341 -159
- package/dist/pebble-web.module.js.map +1 -1
- package/dist/pebble-web.umd.dev.js +360 -166
- package/dist/pebble-web.umd.dev.js.map +1 -1
- package/dist/pebble-web.umd.js +354 -160
- package/dist/pebble-web.umd.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/testIds.d.ts +65 -0
- package/package.json +3 -2
- package/src/components/Button.tsx +3 -1
- package/src/components/Calendar.tsx +28 -4
- package/src/components/CheckboxGroup.tsx +13 -3
- package/src/components/DateInput.tsx +3 -1
- package/src/components/DropDown.tsx +3 -1
- package/src/components/Input.tsx +15 -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/PopUp.tsx +7 -1
- package/src/components/RadioGroup.tsx +20 -3
- package/src/components/Search.tsx +3 -1
- package/src/components/SecondaryInput.tsx +9 -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__/checkboxGroup.test.tsx.snap +88 -0
- 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__/calendar.test.tsx +6 -24
- package/src/components/__tests__/checkboxGroup.test.tsx +39 -8
- 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/Calendar.ts +1 -0
- package/src/components/typings/CheckboxGroup.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/PopUp.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/index.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/testIds.ts +119 -0
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
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 getMessageTestId(id: string): string;
|
|
44
|
+
export declare function getSelectInputTestIds(id: string, multiSelect: true): BaseSelectIds & OptionGroupCheckBoxIds;
|
|
45
|
+
export declare function getSelectInputTestIds(id: string, multiSelect?: false): BaseSelectIds & OptionGroupRadioIds;
|
|
46
|
+
export declare function getSelectInputTestIds(id: string, multiSelect?: boolean): (BaseSelectIds & OptionGroupCheckBoxIds) | (BaseSelectIds & OptionGroupRadioIds);
|
|
47
|
+
export declare function getTypeaheadTestIds(id: string): {
|
|
48
|
+
searchBoxId: string;
|
|
49
|
+
optionId: string;
|
|
50
|
+
selectVisibleId: string;
|
|
51
|
+
clearVisibleId: string;
|
|
52
|
+
optionGroupId: string;
|
|
53
|
+
};
|
|
54
|
+
export declare function getCalendarTestIds(id: string): {
|
|
55
|
+
leftIconId: string;
|
|
56
|
+
rightIconId: string;
|
|
57
|
+
applyButtonId: string;
|
|
58
|
+
clearButtonId: string;
|
|
59
|
+
};
|
|
60
|
+
export declare function getPopUpTestIds(id: string): {
|
|
61
|
+
closeButtonId: string;
|
|
62
|
+
approveButtonId: string;
|
|
63
|
+
rejectButtonId: string;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pebble-web",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.1-alpha.0",
|
|
4
4
|
"author": "ritz078 <rkritesh078@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/pebble-web.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"build:watch": "chokidar 'src/**/*.ts' 'src/**/*.tsx' -c 'yarn build'",
|
|
20
20
|
"pretest": "tslint ./src/**/*.{ts,tsx} ./stories/**/*.{ts,tsx} ./{tests,typings}/**/*.{ts,tsx}",
|
|
21
21
|
"test": "jest --coverage",
|
|
22
|
+
"prepublishOnly": "yarn build && yarn test",
|
|
22
23
|
"test:watch": "yarn jest --watchAll"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"utility-types": "^3.10.0"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"pebble-shared": "^2.
|
|
47
|
+
"pebble-shared": "^2.26.0"
|
|
47
48
|
},
|
|
48
49
|
"greenkeeper": {
|
|
49
50
|
"ignore": [
|
|
@@ -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}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "./styles/Calendar.styles";
|
|
14
14
|
import Button from "./Button";
|
|
15
15
|
import { isSameDay, endOfDay, startOfDay, addDays, subDays } from "date-fns";
|
|
16
|
+
import { getCalendarTestIds, getTestIds } from "../utils/testIds";
|
|
16
17
|
|
|
17
18
|
class Calendar extends React.PureComponent<CalendarProps, CalendarState> {
|
|
18
19
|
static defaultProps: Partial<CalendarProps> = {
|
|
@@ -136,9 +137,16 @@ class Calendar extends React.PureComponent<CalendarProps, CalendarState> {
|
|
|
136
137
|
onClear,
|
|
137
138
|
maxDate,
|
|
138
139
|
minDate,
|
|
140
|
+
testId,
|
|
139
141
|
...rest
|
|
140
142
|
} = this.props;
|
|
141
143
|
const { maxRangeDates } = this.state;
|
|
144
|
+
const {
|
|
145
|
+
leftIconId,
|
|
146
|
+
rightIconId,
|
|
147
|
+
clearButtonId,
|
|
148
|
+
applyButtonId
|
|
149
|
+
} = getTestIds(testId, id => getCalendarTestIds(id));
|
|
142
150
|
|
|
143
151
|
return (
|
|
144
152
|
<div
|
|
@@ -165,10 +173,18 @@ class Calendar extends React.PureComponent<CalendarProps, CalendarState> {
|
|
|
165
173
|
tileDisabled={this.getDisabledDays}
|
|
166
174
|
onClickDay={this.onDayClick}
|
|
167
175
|
prevLabel={
|
|
168
|
-
<i
|
|
176
|
+
<i
|
|
177
|
+
style={{ fontSize: 14 }}
|
|
178
|
+
className="pi pi-chevron-left"
|
|
179
|
+
data-testid={leftIconId}
|
|
180
|
+
/>
|
|
169
181
|
}
|
|
170
182
|
nextLabel={
|
|
171
|
-
<i
|
|
183
|
+
<i
|
|
184
|
+
style={{ fontSize: 14 }}
|
|
185
|
+
className="pi pi-arrow-right"
|
|
186
|
+
data-testid={rightIconId}
|
|
187
|
+
/>
|
|
172
188
|
}
|
|
173
189
|
maxDate={maxDate || (maxRangeDates && maxRangeDates.future)}
|
|
174
190
|
minDate={minDate || (maxRangeDates && maxRangeDates.past)}
|
|
@@ -177,11 +193,19 @@ class Calendar extends React.PureComponent<CalendarProps, CalendarState> {
|
|
|
177
193
|
{(onClear || onApply) && (
|
|
178
194
|
<div className={buttonsWrapper}>
|
|
179
195
|
{onClear && (
|
|
180
|
-
<Button
|
|
196
|
+
<Button
|
|
197
|
+
onClick={this.onClear}
|
|
198
|
+
type="secondary"
|
|
199
|
+
testId={clearButtonId}
|
|
200
|
+
>
|
|
181
201
|
Clear
|
|
182
202
|
</Button>
|
|
183
203
|
)}
|
|
184
|
-
{onApply &&
|
|
204
|
+
{onApply && (
|
|
205
|
+
<Button onClick={this.onApply} testId={applyButtonId}>
|
|
206
|
+
Apply
|
|
207
|
+
</Button>
|
|
208
|
+
)}
|
|
185
209
|
</div>
|
|
186
210
|
)}
|
|
187
211
|
</div>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { CheckboxGroupProps } from "./typings/CheckboxGroup";
|
|
3
3
|
import { CheckboxProps } from "./typings/Checkbox";
|
|
4
|
+
import { getOptionTestId } from "../utils/testIds";
|
|
4
5
|
import { getSelectedCheckboxes } from "./utils/getSelectedCheckboxes";
|
|
5
6
|
|
|
6
7
|
export default class CheckboxGroup<OptionType> extends React.PureComponent<
|
|
@@ -15,9 +16,17 @@ export default class CheckboxGroup<OptionType> extends React.PureComponent<
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
render() {
|
|
18
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
children,
|
|
21
|
+
selected,
|
|
22
|
+
className,
|
|
23
|
+
name,
|
|
24
|
+
disabled,
|
|
25
|
+
testId
|
|
26
|
+
} = this.props;
|
|
19
27
|
|
|
20
|
-
const _children = React.Children.map(children, _checkbox => {
|
|
28
|
+
const _children = React.Children.map(children, (_checkbox, i) => {
|
|
29
|
+
const index = typeof i === "number" ? i : 0;
|
|
21
30
|
// `_checkbox as React.ReactElement<CheckboxProps>` is a hack
|
|
22
31
|
// Because React does not allow us to specify what sort of elements
|
|
23
32
|
// you can allow as children and leaves it on you to figure out
|
|
@@ -28,7 +37,8 @@ export default class CheckboxGroup<OptionType> extends React.PureComponent<
|
|
|
28
37
|
return React.cloneElement(checkbox, {
|
|
29
38
|
onChange: this.handleChange,
|
|
30
39
|
checked: selected.indexOf(checkbox.props.value) >= 0,
|
|
31
|
-
disabled
|
|
40
|
+
disabled,
|
|
41
|
+
testId: testId ? getOptionTestId(testId, index) : undefined
|
|
32
42
|
});
|
|
33
43
|
});
|
|
34
44
|
|
|
@@ -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
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "./styles/Input.styles";
|
|
16
16
|
import { colors } from "pebble-shared";
|
|
17
17
|
import Loader from "./Loader";
|
|
18
|
+
import { getMessageTestId } from "../utils/testIds";
|
|
18
19
|
|
|
19
20
|
function getColor(
|
|
20
21
|
error: string | undefined,
|
|
@@ -84,7 +85,8 @@ class Input extends React.PureComponent<InputProps, InputState> {
|
|
|
84
85
|
onClick,
|
|
85
86
|
loading,
|
|
86
87
|
leftElement,
|
|
87
|
-
rightElement
|
|
88
|
+
rightElement,
|
|
89
|
+
testId
|
|
88
90
|
} = this.props;
|
|
89
91
|
const { isFocused } = this.state;
|
|
90
92
|
|
|
@@ -152,9 +154,18 @@ class Input extends React.PureComponent<InputProps, InputState> {
|
|
|
152
154
|
{leftElement?.()}
|
|
153
155
|
|
|
154
156
|
{this.props.textArea ? (
|
|
155
|
-
<textarea
|
|
157
|
+
<textarea
|
|
158
|
+
{..._inputProps}
|
|
159
|
+
{...this.props.inputProps}
|
|
160
|
+
data-testid={testId}
|
|
161
|
+
/>
|
|
156
162
|
) : (
|
|
157
|
-
<input
|
|
163
|
+
<input
|
|
164
|
+
type={type}
|
|
165
|
+
{..._inputProps}
|
|
166
|
+
{...this.props.inputProps}
|
|
167
|
+
data-testid={testId}
|
|
168
|
+
/>
|
|
158
169
|
)}
|
|
159
170
|
|
|
160
171
|
{loading && (
|
|
@@ -187,6 +198,7 @@ class Input extends React.PureComponent<InputProps, InputState> {
|
|
|
187
198
|
{_message && (
|
|
188
199
|
<div
|
|
189
200
|
className={messageStyle}
|
|
201
|
+
data-testid={testId ? getMessageTestId(testId) : undefined}
|
|
190
202
|
style={{ color: getColor(errorMessage, successMessage) }}
|
|
191
203
|
>
|
|
192
204
|
{_message}
|
|
@@ -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
|
);
|
package/src/components/PopUp.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
flexCenter
|
|
10
10
|
} from "./styles/PopUp.styles";
|
|
11
11
|
import { PopUpProps } from "./typings/PopUp";
|
|
12
|
+
import { getPopUpTestIds, getTestIds } from "../utils/testIds";
|
|
12
13
|
|
|
13
14
|
const PopUp: React.FunctionComponent<PopUpProps> = props => {
|
|
14
15
|
const {
|
|
@@ -20,8 +21,10 @@ const PopUp: React.FunctionComponent<PopUpProps> = props => {
|
|
|
20
21
|
rejectButtonText = "No",
|
|
21
22
|
children,
|
|
22
23
|
approveButtonProps,
|
|
23
|
-
rejectButtonProps
|
|
24
|
+
rejectButtonProps,
|
|
25
|
+
testId
|
|
24
26
|
} = props;
|
|
27
|
+
const {closeButtonId, approveButtonId, rejectButtonId} = getTestIds(testId, id => getPopUpTestIds(id));
|
|
25
28
|
return (
|
|
26
29
|
<Modal visible={visible} modalClassName={flexCenter}>
|
|
27
30
|
<div className={modalContainer}>
|
|
@@ -29,6 +32,7 @@ const PopUp: React.FunctionComponent<PopUpProps> = props => {
|
|
|
29
32
|
<i
|
|
30
33
|
className={cx("pi", "pi-close", iconCloseClassName)}
|
|
31
34
|
onClick={onClose}
|
|
35
|
+
data-testid={closeButtonId}
|
|
32
36
|
/>
|
|
33
37
|
)}
|
|
34
38
|
{children}
|
|
@@ -40,6 +44,7 @@ const PopUp: React.FunctionComponent<PopUpProps> = props => {
|
|
|
40
44
|
type="secondary"
|
|
41
45
|
onClick={onReject}
|
|
42
46
|
{...rejectButtonProps}
|
|
47
|
+
testId={rejectButtonId}
|
|
43
48
|
>
|
|
44
49
|
{rejectButtonText}
|
|
45
50
|
</Button>
|
|
@@ -50,6 +55,7 @@ const PopUp: React.FunctionComponent<PopUpProps> = props => {
|
|
|
50
55
|
type="primary"
|
|
51
56
|
onClick={onApprove}
|
|
52
57
|
{...approveButtonProps}
|
|
58
|
+
testId={approveButtonId}
|
|
53
59
|
>
|
|
54
60
|
{approveButtonText}
|
|
55
61
|
</Button>
|
|
@@ -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 && (
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
messageStyle,
|
|
13
13
|
placeholderStyle
|
|
14
14
|
} from "./styles/SecondaryInput.styles";
|
|
15
|
+
import { getMessageTestId } from "../utils/testIds";
|
|
15
16
|
import {
|
|
16
17
|
SecondaryInputProps,
|
|
17
18
|
SecondaryInputState
|
|
@@ -76,7 +77,8 @@ export default class SecondaryInput extends React.PureComponent<
|
|
|
76
77
|
message,
|
|
77
78
|
readOnly,
|
|
78
79
|
loading,
|
|
79
|
-
className
|
|
80
|
+
className,
|
|
81
|
+
testId
|
|
80
82
|
} = this.props;
|
|
81
83
|
const { isFocused } = this.state;
|
|
82
84
|
|
|
@@ -119,7 +121,11 @@ export default class SecondaryInput extends React.PureComponent<
|
|
|
119
121
|
onFocus={this.addFocus}
|
|
120
122
|
onBlur={this.removeFocus}
|
|
121
123
|
>
|
|
122
|
-
<input
|
|
124
|
+
<input
|
|
125
|
+
{..._inputProps}
|
|
126
|
+
{...this.props.inputProps}
|
|
127
|
+
data-testid={testId}
|
|
128
|
+
/>
|
|
123
129
|
<label className={placeholderClassName}>
|
|
124
130
|
{placeholder}
|
|
125
131
|
{required && (
|
|
@@ -134,6 +140,7 @@ export default class SecondaryInput extends React.PureComponent<
|
|
|
134
140
|
{_message && (
|
|
135
141
|
<div
|
|
136
142
|
className={messageStyle}
|
|
143
|
+
data-testid={testId ? getMessageTestId(testId) : undefined}
|
|
137
144
|
style={{ color: getColor(errorMessage, successMessage) }}
|
|
138
145
|
>
|
|
139
146
|
{_message}
|
|
@@ -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;
|