bright-components 10.2.6 → 10.2.8
Sign up to get free protection for your applications and to get access to all the features.
- package/circle.yml +1 -2
- package/deploy.sh +6 -0
- package/dist/components/DayPicker/NewDayPicker/index.js +0 -28
- package/dist/components/DayPicker/index.js +2 -20
- package/dist/components/DayPickerPanel/HeaderDayPickerPanel/index.js +1 -18
- package/dist/components/DayPickerPanel/HeaderMonthPanel/index.js +0 -14
- package/dist/components/DayPickerPanel/HeaderYearPanel/index.js +2 -15
- package/dist/components/DayPickerPanel/Shortcuts/index.js +2 -16
- package/dist/components/DayPickerPanel/index.js +2 -74
- package/dist/components/EmployeeCard/index.js +1 -14
- package/dist/components/EmployeePicker/FilterBar/index.js +1 -28
- package/dist/components/EmployeePicker/Group/index.js +1 -41
- package/dist/components/FilterRadioGroup/index.js +2 -14
- package/dist/components/Form/index.js +4 -47
- package/dist/components/RadioBlock/index.js +10 -41
- package/dist/components/Time/OverlayBase/index.js +2 -25
- package/dist/components/Time/TimePicker/TimeOverlay/index.js +3 -26
- package/dist/components/TimePicker/Time/TimeOverlay/index.js +1 -58
- package/dist/setupTests.js +0 -7
- package/package.json +5 -7
- package/src/components/DayPicker/NewDayPicker/index.js +0 -21
- package/src/components/DayPicker/index.js +1 -16
- package/src/components/DayPicker/test.js +0 -85
- package/src/components/DayPickerPanel/HeaderDayPickerPanel/index.js +2 -22
- package/src/components/DayPickerPanel/HeaderDayPickerPanel/test.js +0 -34
- package/src/components/DayPickerPanel/HeaderMonthPanel/index.js +0 -10
- package/src/components/DayPickerPanel/HeaderMonthPanel/test.js +0 -25
- package/src/components/DayPickerPanel/HeaderYearPanel/index.js +3 -12
- package/src/components/DayPickerPanel/HeaderYearPanel/test.js +0 -17
- package/src/components/DayPickerPanel/Shortcuts/index.js +3 -17
- package/src/components/DayPickerPanel/Shortcuts/test.js +0 -39
- package/src/components/DayPickerPanel/index.js +1 -69
- package/src/components/DayPickerPanel/test.js +0 -177
- package/src/components/EmployeeCard/index.js +1 -15
- package/src/components/EmployeeCard/test.js +0 -20
- package/src/components/EmployeePicker/FilterBar/index.js +2 -26
- package/src/components/EmployeePicker/FilterBar/test.js +0 -29
- package/src/components/EmployeePicker/Group/index.js +1 -42
- package/src/components/EmployeePicker/Group/test.js +0 -21
- package/src/components/FilterRadioGroup/index.js +2 -14
- package/src/components/FilterRadioGroup/test.js +0 -13
- package/src/components/Form/index.js +1 -49
- package/src/components/Form/test.js +0 -73
- package/src/components/Modal/test.js +9 -9
- package/src/components/RadioBlock/index.js +14 -33
- package/src/components/RadioBlock/test.js +35 -155
- package/src/components/ResponsiveTabs/test.js +49 -86
- package/src/components/Time/OverlayBase/index.js +3 -21
- package/src/components/Time/OverlayBase/test.js +0 -50
- package/src/components/Time/TimePicker/TimeOverlay/index.js +4 -30
- package/src/components/Time/TimePicker/TimeOverlay/test.js +0 -24
- package/src/components/TimePicker/DayPart/test.js +1 -1
- package/src/components/TimePicker/Time/TimeOverlay/index.js +2 -50
- package/src/components/TimePicker/Time/TimeOverlay/test.js +1 -220
- package/src/index.js +1 -1
- package/src/setupTests.js +0 -2
- package/dist/components/TimePicker/utils/PickerGA/index.js +0 -24
- package/dist/utils/trackForm/index.js +0 -48
- package/src/components/TimePicker/utils/PickerGA/index.js +0 -6
- package/src/components/TimePicker/utils/PickerGA/test.js +0 -29
- package/src/utils/trackForm/index.js +0 -36
- package/src/utils/trackForm/test.js +0 -110
@@ -9,7 +9,6 @@ import {
|
|
9
9
|
string,
|
10
10
|
array
|
11
11
|
} from 'prop-types';
|
12
|
-
import { event } from 'react-ga';
|
13
12
|
import autoBind from 'react-autobind';
|
14
13
|
import { format, subYears, addYears } from 'date-fns';
|
15
14
|
import styled, { css } from 'styled-components';
|
@@ -26,7 +25,6 @@ import WhiteOutlineButton from '../Button/WhiteOutlineButton';
|
|
26
25
|
import getYearRangeChunks from './utils/getYearRangeChunks';
|
27
26
|
import getYearRangeIndex from './utils/getYearRangeIndex';
|
28
27
|
|
29
|
-
const friendlyShort = 'EEE dd MMM';
|
30
28
|
const friendlyShortWithYear = 'EEE dd MMM yyyy';
|
31
29
|
|
32
30
|
const DayPickerWrapper = styled.div`
|
@@ -127,7 +125,6 @@ class DayPickerPanel extends React.Component {
|
|
127
125
|
range: newRange
|
128
126
|
},
|
129
127
|
() => {
|
130
|
-
this.applyDatesGaEvent('selected');
|
131
128
|
onApply(newRange);
|
132
129
|
}
|
133
130
|
);
|
@@ -168,34 +165,6 @@ class DayPickerPanel extends React.Component {
|
|
168
165
|
this.setState({ view: CALENDAR });
|
169
166
|
}
|
170
167
|
|
171
|
-
applyDatesGaEvent(selectedDay) {
|
172
|
-
const {
|
173
|
-
GA: { category, actionId },
|
174
|
-
dateRange,
|
175
|
-
recordValue
|
176
|
-
} = this.props;
|
177
|
-
const {
|
178
|
-
range: { from, to }
|
179
|
-
} = this.state;
|
180
|
-
|
181
|
-
const actionEvent = selectedDay ? 'Set via Date Picker' : 'Apply';
|
182
|
-
|
183
|
-
if (category) {
|
184
|
-
const label = dateRange
|
185
|
-
? `${format(from, friendlyShort)} - ${format(
|
186
|
-
to || from,
|
187
|
-
friendlyShort
|
188
|
-
)} ${format(to || from, 'yyyy')}`
|
189
|
-
: `${format(from, friendlyShort)} ${format(from, 'yyyy')}`;
|
190
|
-
|
191
|
-
event({
|
192
|
-
category,
|
193
|
-
action: `${actionId} - ${actionEvent}`,
|
194
|
-
...(recordValue ? { label } : {})
|
195
|
-
});
|
196
|
-
}
|
197
|
-
}
|
198
|
-
|
199
168
|
render() {
|
200
169
|
const {
|
201
170
|
onCancel,
|
@@ -207,7 +176,6 @@ class DayPickerPanel extends React.Component {
|
|
207
176
|
disabledDays,
|
208
177
|
shortcuts,
|
209
178
|
close,
|
210
|
-
GA,
|
211
179
|
isDateSelect
|
212
180
|
} = this.props;
|
213
181
|
const {
|
@@ -266,15 +234,10 @@ class DayPickerPanel extends React.Component {
|
|
266
234
|
this.setState({
|
267
235
|
view: CALENDAR
|
268
236
|
});
|
269
|
-
event({
|
270
|
-
category: GA.category,
|
271
|
-
action: `${GA.actionId} - Cancel Month`
|
272
|
-
});
|
273
237
|
}}
|
274
238
|
setMonth={this.setMonth}
|
275
239
|
switchBackToCalendarView={this.switchBackToCalendarView}
|
276
240
|
setYear={this.setYear}
|
277
|
-
GA={GA}
|
278
241
|
isViewingCurrentYear={
|
279
242
|
startDate && startDate.getFullYear() === year
|
280
243
|
}
|
@@ -297,12 +260,7 @@ class DayPickerPanel extends React.Component {
|
|
297
260
|
this.setState({
|
298
261
|
view: CALENDAR
|
299
262
|
});
|
300
|
-
event({
|
301
|
-
category: GA.category,
|
302
|
-
action: `${GA.actionId} - Cancel Year`
|
303
|
-
});
|
304
263
|
}}
|
305
|
-
GA={GA}
|
306
264
|
/>
|
307
265
|
)}
|
308
266
|
{view === CALENDAR && (
|
@@ -312,37 +270,20 @@ class DayPickerPanel extends React.Component {
|
|
312
270
|
yearRange={yearRange}
|
313
271
|
onMonthClick={() => {
|
314
272
|
this.setState({ view: MONTH });
|
315
|
-
event({
|
316
|
-
category: GA.category,
|
317
|
-
action: `${GA.actionId} - Month Picker`
|
318
|
-
});
|
319
273
|
}}
|
320
274
|
onYearClick={() => {
|
321
275
|
this.setState({ view: YEAR });
|
322
|
-
event({
|
323
|
-
category: GA.category,
|
324
|
-
action: `${GA.actionId} - Year Picker`
|
325
|
-
});
|
326
276
|
}}
|
327
277
|
onMonthChange={e => {
|
328
278
|
this.setMonth(+e.target.value);
|
329
|
-
event({
|
330
|
-
category: GA.category,
|
331
|
-
action: `${GA.actionId} - Month Changed`
|
332
|
-
});
|
333
279
|
}}
|
334
280
|
onYearChange={e => {
|
335
281
|
this.setYear(+e.target.value);
|
336
|
-
event({
|
337
|
-
category: GA.category,
|
338
|
-
action: `${GA.actionId} - Year Changed`
|
339
|
-
});
|
340
282
|
}}
|
341
283
|
setMonth={this.setMonth}
|
342
284
|
setYear={this.setYear}
|
343
285
|
dateRange={dateRange}
|
344
286
|
onApply={() => {
|
345
|
-
this.applyDatesGaEvent();
|
346
287
|
onApply(range);
|
347
288
|
}}
|
348
289
|
onCancel={onCancel}
|
@@ -352,15 +293,11 @@ class DayPickerPanel extends React.Component {
|
|
352
293
|
range={range}
|
353
294
|
shortcuts={shortcuts}
|
354
295
|
onSelectedDay={this.onSelectedDay}
|
355
|
-
GA={GA}
|
356
296
|
isDateSelect={isDateSelect}
|
357
297
|
/>
|
358
298
|
)}
|
359
299
|
{close && (
|
360
|
-
<CloseButton
|
361
|
-
gaAction={`${GA.actionId} Day picker close`}
|
362
|
-
onClick={close}
|
363
|
-
>
|
300
|
+
<CloseButton onClick={close}>
|
364
301
|
<CloseIcon size={16} />
|
365
302
|
</CloseButton>
|
366
303
|
)}
|
@@ -392,11 +329,6 @@ DayPickerPanel.propTypes = {
|
|
392
329
|
close: func,
|
393
330
|
disabledDays: array, // eslint-disable-line react/forbid-prop-types
|
394
331
|
shortcuts: oneOf(['today', 'current', 'last']),
|
395
|
-
GA: shape({
|
396
|
-
category: string,
|
397
|
-
actionId: string
|
398
|
-
}).isRequired,
|
399
|
-
recordValue: bool.isRequired,
|
400
332
|
onMonthSelected: func,
|
401
333
|
isDateSelect: bool
|
402
334
|
};
|
@@ -1,12 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { mount, shallow } from 'enzyme';
|
3
|
-
import { event } from 'react-ga';
|
4
3
|
import { format, startOfMonth, addMonths } from 'date-fns';
|
5
4
|
|
6
5
|
import DayPicker from '.';
|
7
6
|
|
8
|
-
jest.mock('react-ga');
|
9
|
-
|
10
7
|
const getNextMonth = () => addMonths(startOfMonth(new Date()), 1);
|
11
8
|
|
12
9
|
describe('Month Year and Calendar view', () => {
|
@@ -21,10 +18,6 @@ describe('Month Year and Calendar view', () => {
|
|
21
18
|
range={{ from: new Date(2018, 3, 1), to: new Date(2018, 3, 7) }}
|
22
19
|
dateRange
|
23
20
|
recordValue
|
24
|
-
GA={{
|
25
|
-
category: 'Cat',
|
26
|
-
actionId: 'Action ID'
|
27
|
-
}}
|
28
21
|
{...props}
|
29
22
|
/>
|
30
23
|
);
|
@@ -36,141 +29,6 @@ describe('Month Year and Calendar view', () => {
|
|
36
29
|
.find('.DayPicker-Day')
|
37
30
|
.not('.DayPicker-Day--outside');
|
38
31
|
|
39
|
-
describe('GA event tracking', () => {
|
40
|
-
it('should be passed a GA prop with an object and it should be passed to HeaderDayPickerPanel', () => {
|
41
|
-
const comp = getComp();
|
42
|
-
expect(comp.find('HeaderDayPickerPanel').prop('GA')).toEqual({
|
43
|
-
category: 'Cat',
|
44
|
-
actionId: 'Action ID'
|
45
|
-
});
|
46
|
-
});
|
47
|
-
|
48
|
-
it('should trigger a GA event when Apply is clicked passing a single date, an action with ID and a category ', () => {
|
49
|
-
const comp = getComp();
|
50
|
-
comp.setProps({
|
51
|
-
range: { from: new Date(2018, 3, 1) },
|
52
|
-
dateRange: false
|
53
|
-
});
|
54
|
-
comp.find('HeaderDayPickerPanel').prop('onApply')();
|
55
|
-
|
56
|
-
expect(event).toHaveBeenCalledWith({
|
57
|
-
category: 'Cat',
|
58
|
-
action: 'Action ID - Apply',
|
59
|
-
label: 'Sun 01 Apr 2018'
|
60
|
-
});
|
61
|
-
});
|
62
|
-
|
63
|
-
it('should trigger a GA event when Set Date is clicked passing a single date, an action with ID and a category ', () => {
|
64
|
-
const comp = getComp();
|
65
|
-
comp.setProps({
|
66
|
-
range: { from: new Date(2018, 3, 1) },
|
67
|
-
dateRange: false
|
68
|
-
});
|
69
|
-
comp.find('HeaderDayPickerPanel').prop('onSelectedDay')({
|
70
|
-
from: new Date(2018, 3, 3),
|
71
|
-
to: new Date(2018, 3, 7)
|
72
|
-
});
|
73
|
-
|
74
|
-
expect(event).toHaveBeenCalledWith({
|
75
|
-
category: 'Cat',
|
76
|
-
action: 'Action ID - Set via Date Picker',
|
77
|
-
label: 'Tue 03 Apr 2018'
|
78
|
-
});
|
79
|
-
});
|
80
|
-
|
81
|
-
it('Shows range of one day if user only selects start date and then applies', () => {
|
82
|
-
const comp = mount(
|
83
|
-
<DayPicker
|
84
|
-
month={0}
|
85
|
-
year={2018}
|
86
|
-
yearRange={{ min: 2017, max: 2019 }}
|
87
|
-
onApply={() => {}}
|
88
|
-
onCancel={() => {}}
|
89
|
-
range={{ from: new Date(2018, 3, 1), to: undefined }}
|
90
|
-
dateRange
|
91
|
-
recordValue
|
92
|
-
GA={{
|
93
|
-
category: 'Cat',
|
94
|
-
actionId: 'Action ID'
|
95
|
-
}}
|
96
|
-
/>
|
97
|
-
);
|
98
|
-
|
99
|
-
comp.find('HeaderDayPickerPanel').prop('onApply')();
|
100
|
-
|
101
|
-
expect(event).toHaveBeenCalledWith({
|
102
|
-
category: 'Cat',
|
103
|
-
action: 'Action ID - Apply',
|
104
|
-
label: 'Sun 01 Apr - Sun 01 Apr 2018'
|
105
|
-
});
|
106
|
-
});
|
107
|
-
|
108
|
-
it('should trigger a GA event when Apply is clicked passing a date range, an action with ID and a category', () => {
|
109
|
-
const comp = getComp();
|
110
|
-
comp.find('HeaderDayPickerPanel').prop('onApply')();
|
111
|
-
|
112
|
-
expect(event).toHaveBeenCalledWith({
|
113
|
-
category: 'Cat',
|
114
|
-
action: 'Action ID - Apply',
|
115
|
-
label: 'Sun 01 Apr - Sat 07 Apr 2018'
|
116
|
-
});
|
117
|
-
});
|
118
|
-
|
119
|
-
it('should fire a GA event when the month and year is clicked', () => {
|
120
|
-
const comp = getComp();
|
121
|
-
comp.find('HeaderDayPickerPanel').prop('onMonthClick')();
|
122
|
-
|
123
|
-
expect(event).toHaveBeenCalledWith({
|
124
|
-
category: 'Cat',
|
125
|
-
action: 'Action ID - Month Picker'
|
126
|
-
});
|
127
|
-
|
128
|
-
comp.find('HeaderDayPickerPanel').prop('onYearClick')();
|
129
|
-
|
130
|
-
expect(event).toHaveBeenCalledWith({
|
131
|
-
category: 'Cat',
|
132
|
-
action: 'Action ID - Year Picker'
|
133
|
-
});
|
134
|
-
});
|
135
|
-
|
136
|
-
it('should not record a label if recordValue is set to false', () => {
|
137
|
-
const comp = getComp();
|
138
|
-
comp.setProps({ recordValue: false });
|
139
|
-
|
140
|
-
comp.find('HeaderDayPickerPanel').prop('onApply')();
|
141
|
-
|
142
|
-
expect(event).toHaveBeenCalledWith({
|
143
|
-
category: 'Cat',
|
144
|
-
action: 'Action ID - Apply'
|
145
|
-
});
|
146
|
-
});
|
147
|
-
|
148
|
-
it('calls GA events if user selects month or year', () => {
|
149
|
-
const comp = getComp();
|
150
|
-
comp.setProps({
|
151
|
-
isDateSelect: true,
|
152
|
-
onYearChange: jest.fn(),
|
153
|
-
onMonthChange: jest.fn()
|
154
|
-
});
|
155
|
-
|
156
|
-
comp.find('[data-e2e="select-month"]')
|
157
|
-
.first()
|
158
|
-
.simulate('change');
|
159
|
-
expect(event).toHaveBeenCalledWith({
|
160
|
-
category: 'Cat',
|
161
|
-
action: 'Action ID - Month Changed'
|
162
|
-
});
|
163
|
-
|
164
|
-
comp.find('[data-e2e="select-year"]')
|
165
|
-
.first()
|
166
|
-
.simulate('change');
|
167
|
-
expect(event).toHaveBeenCalledWith({
|
168
|
-
category: 'Cat',
|
169
|
-
action: 'Action ID - Year Changed'
|
170
|
-
});
|
171
|
-
});
|
172
|
-
});
|
173
|
-
|
174
32
|
describe('Header Month and Year ', () => {
|
175
33
|
it('should display the calendar panel by default', () => {
|
176
34
|
const comp = getComp();
|
@@ -389,35 +247,12 @@ describe('Month Year and Calendar view', () => {
|
|
389
247
|
expect(comp.state('view')).toEqual('calendar');
|
390
248
|
});
|
391
249
|
|
392
|
-
it('should fire a GA event when the month panel cancel element has been clicked', () => {
|
393
|
-
const comp = getComp();
|
394
|
-
|
395
|
-
comp.find('MonthDisplay').simulate('click');
|
396
|
-
comp.find('CancelBtn').simulate('click');
|
397
|
-
|
398
|
-
expect(event).toHaveBeenCalledWith({
|
399
|
-
category: 'Cat',
|
400
|
-
action: 'Action ID - Cancel Month'
|
401
|
-
});
|
402
|
-
});
|
403
|
-
|
404
250
|
it('should set the view to calendar when the Year panel cancel element has been clicked', () => {
|
405
251
|
const comp = getComp();
|
406
252
|
comp.find('YearDisplay').simulate('click');
|
407
253
|
comp.find('CancelBtn').simulate('click');
|
408
254
|
expect(comp.state('view')).toEqual('calendar');
|
409
255
|
});
|
410
|
-
it('should fire a GA event when the year panel cancel element has been clicked', () => {
|
411
|
-
const comp = getComp();
|
412
|
-
|
413
|
-
comp.find('YearDisplay').simulate('click');
|
414
|
-
comp.find('CancelBtn').simulate('click');
|
415
|
-
|
416
|
-
expect(event).toHaveBeenCalledWith({
|
417
|
-
category: 'Cat',
|
418
|
-
action: 'Action ID - Cancel Year'
|
419
|
-
});
|
420
|
-
});
|
421
256
|
});
|
422
257
|
|
423
258
|
describe('close icon', () => {
|
@@ -438,10 +273,6 @@ describe('Month Year and Calendar view', () => {
|
|
438
273
|
dateRange
|
439
274
|
close={() => {}}
|
440
275
|
recordValue
|
441
|
-
GA={{
|
442
|
-
category: 'Cat',
|
443
|
-
actionId: 'Action ID'
|
444
|
-
}}
|
445
276
|
/>
|
446
277
|
);
|
447
278
|
expect(comp.find('CloseButton')).toHaveLength(1);
|
@@ -461,10 +292,6 @@ describe('single day mode', () => {
|
|
461
292
|
onApply={applyMock}
|
462
293
|
onCancel={() => {}}
|
463
294
|
recordValue
|
464
|
-
GA={{
|
465
|
-
category: 'Cat',
|
466
|
-
actionId: 'Action ID'
|
467
|
-
}}
|
468
295
|
/>
|
469
296
|
);
|
470
297
|
|
@@ -492,10 +319,6 @@ describe('month only', () => {
|
|
492
319
|
recordValue
|
493
320
|
onMonthSelected={onMonthSelected}
|
494
321
|
close={close}
|
495
|
-
GA={{
|
496
|
-
category: 'Cat',
|
497
|
-
actionId: 'Action ID'
|
498
|
-
}}
|
499
322
|
view="month"
|
500
323
|
/>
|
501
324
|
);
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import ReactGA from 'react-ga';
|
3
2
|
import { string, func } from 'prop-types';
|
4
3
|
import styled from 'styled-components';
|
5
4
|
import spacing from 'constants/spacing';
|
@@ -17,21 +16,12 @@ const LinkContainer = styled.div`
|
|
17
16
|
`;
|
18
17
|
LinkContainer.displayName = 'LinkContainer';
|
19
18
|
|
20
|
-
const EmployeeCard = ({
|
21
|
-
name,
|
22
|
-
imageHref,
|
23
|
-
link,
|
24
|
-
category,
|
25
|
-
action,
|
26
|
-
onClick,
|
27
|
-
...rest
|
28
|
-
}) => (
|
19
|
+
const EmployeeCard = ({ name, imageHref, link, onClick, ...rest }) => (
|
29
20
|
<Container {...rest}>
|
30
21
|
<Avatar employeeName={name} employeeImageHref={imageHref} />
|
31
22
|
<LinkContainer>
|
32
23
|
<A
|
33
24
|
onClick={() => {
|
34
|
-
ReactGA.event({ category, action });
|
35
25
|
if (onClick) {
|
36
26
|
onClick();
|
37
27
|
}
|
@@ -48,15 +38,11 @@ EmployeeCard.propTypes = {
|
|
48
38
|
name: string.isRequired,
|
49
39
|
imageHref: string,
|
50
40
|
link: string.isRequired,
|
51
|
-
category: string,
|
52
|
-
action: string,
|
53
41
|
onClick: func
|
54
42
|
};
|
55
43
|
|
56
44
|
EmployeeCard.defaultProps = {
|
57
45
|
imageHref: undefined,
|
58
|
-
category: 'Employee',
|
59
|
-
action: 'Employee card name is clicked',
|
60
46
|
onClick: undefined
|
61
47
|
};
|
62
48
|
export default EmployeeCard;
|
@@ -1,10 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import ReactGA from 'react-ga';
|
3
2
|
import { render, fireEvent } from '@testing-library/react';
|
4
3
|
import EmployeeCard from '.';
|
5
4
|
|
6
|
-
const GASpy = jest.spyOn(ReactGA, 'event');
|
7
|
-
|
8
5
|
describe('<EmployeeCard />', () => {
|
9
6
|
const employee = {
|
10
7
|
name: 'John Smith',
|
@@ -56,21 +53,4 @@ describe('<EmployeeCard />', () => {
|
|
56
53
|
fireEvent.click(contactCard);
|
57
54
|
expect(onClick).not.toHaveBeenCalled();
|
58
55
|
});
|
59
|
-
|
60
|
-
it('Should fire a GA tracking event when category and action is passed in as a prop', () => {
|
61
|
-
props.category = 'Settings';
|
62
|
-
props.action = 'blah blah';
|
63
|
-
|
64
|
-
wrapper.rerender(<EmployeeCard {...props} />);
|
65
|
-
|
66
|
-
expect(GASpy).not.toHaveBeenCalled();
|
67
|
-
|
68
|
-
const contactCard = wrapper.getByText(employee.name);
|
69
|
-
fireEvent.click(contactCard);
|
70
|
-
|
71
|
-
expect(GASpy).toHaveBeenLastCalledWith({
|
72
|
-
action: 'blah blah',
|
73
|
-
category: 'Settings'
|
74
|
-
});
|
75
|
-
});
|
76
56
|
});
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import React, { createRef } from 'react';
|
2
2
|
import styled from 'styled-components';
|
3
|
-
import { func, string, bool
|
3
|
+
import { func, string, bool } from 'prop-types';
|
4
4
|
import breakpoints from 'constants/breakpoints';
|
5
|
-
import { event } from 'react-ga';
|
6
5
|
|
7
6
|
import Input from 'components/Input';
|
8
7
|
import LinkButton from 'components/LinkButton';
|
@@ -56,7 +55,6 @@ export const focusObj = obj => {
|
|
56
55
|
};
|
57
56
|
|
58
57
|
const FilterBar = ({
|
59
|
-
GA,
|
60
58
|
value,
|
61
59
|
update,
|
62
60
|
type,
|
@@ -76,22 +74,13 @@ const FilterBar = ({
|
|
76
74
|
onChange={e => {
|
77
75
|
updateType(e.target.value);
|
78
76
|
focusObj(textInput);
|
79
|
-
event({
|
80
|
-
action: `Search by ${e.target.value}`,
|
81
|
-
category: GA.category
|
82
|
-
});
|
83
77
|
}}
|
84
78
|
>
|
85
79
|
<Option value="name">Search by name</Option>
|
86
80
|
<Option value="group">Search by group</Option>
|
87
81
|
</StyledSelect>
|
88
82
|
<StyledInput
|
89
|
-
onBlur={() => {
|
90
|
-
event({
|
91
|
-
action: 'Enter Name',
|
92
|
-
category: GA.category
|
93
|
-
});
|
94
|
-
}}
|
83
|
+
onBlur={() => {}}
|
95
84
|
value={value}
|
96
85
|
onChange={e => update(e.target.value)}
|
97
86
|
placeholder="Enter name"
|
@@ -102,10 +91,6 @@ const FilterBar = ({
|
|
102
91
|
{value && (
|
103
92
|
<ClearButton
|
104
93
|
onClick={() => {
|
105
|
-
event({
|
106
|
-
action: 'Clear Filter',
|
107
|
-
category: GA.category
|
108
|
-
});
|
109
94
|
update('');
|
110
95
|
}}
|
111
96
|
>
|
@@ -118,10 +103,6 @@ const FilterBar = ({
|
|
118
103
|
disabled={disableSelect}
|
119
104
|
onClick={() => {
|
120
105
|
selectAll();
|
121
|
-
event({
|
122
|
-
action: 'Select All',
|
123
|
-
category: GA.category
|
124
|
-
});
|
125
106
|
}}
|
126
107
|
>
|
127
108
|
Select all
|
@@ -130,10 +111,6 @@ const FilterBar = ({
|
|
130
111
|
disabled={disableDeselect}
|
131
112
|
onClick={() => {
|
132
113
|
deselectAll();
|
133
|
-
event({
|
134
|
-
action: 'Deselect All',
|
135
|
-
category: GA.category
|
136
|
-
});
|
137
114
|
}}
|
138
115
|
>
|
139
116
|
Deselect all
|
@@ -147,7 +124,6 @@ const FilterBar = ({
|
|
147
124
|
FilterBar.displayName = 'FilterBar';
|
148
125
|
|
149
126
|
FilterBar.propTypes = {
|
150
|
-
GA: shape({ category: string }).isRequired,
|
151
127
|
value: string,
|
152
128
|
update: func.isRequired,
|
153
129
|
type: string.isRequired,
|
@@ -1,12 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { render, fireEvent } from '@testing-library/react';
|
3
3
|
import userEvent from '@testing-library/user-event';
|
4
|
-
import { event } from 'react-ga';
|
5
|
-
|
6
4
|
import Bar from '.';
|
7
5
|
|
8
|
-
jest.mock('react-ga');
|
9
|
-
|
10
6
|
describe('EmployeePickerFilterBar', () => {
|
11
7
|
let element;
|
12
8
|
let update;
|
@@ -21,7 +17,6 @@ describe('EmployeePickerFilterBar', () => {
|
|
21
17
|
selectAll = jest.fn();
|
22
18
|
deselectAll = jest.fn();
|
23
19
|
props = {
|
24
|
-
GA: { category: 'category' },
|
25
20
|
value: '',
|
26
21
|
update,
|
27
22
|
type: 'name',
|
@@ -42,19 +37,11 @@ describe('EmployeePickerFilterBar', () => {
|
|
42
37
|
|
43
38
|
userEvent.selectOptions(select, 'name');
|
44
39
|
expect(props.updateType).toHaveBeenLastCalledWith('name');
|
45
|
-
expect(event).toHaveBeenLastCalledWith({
|
46
|
-
action: 'Search by name',
|
47
|
-
category: 'category'
|
48
|
-
});
|
49
40
|
|
50
41
|
input.blur();
|
51
42
|
|
52
43
|
userEvent.selectOptions(select, 'group');
|
53
44
|
expect(props.updateType).toHaveBeenLastCalledWith('group');
|
54
|
-
expect(event).toHaveBeenLastCalledWith({
|
55
|
-
action: 'Search by group',
|
56
|
-
category: 'category'
|
57
|
-
});
|
58
45
|
});
|
59
46
|
|
60
47
|
it('should focus the input when the filter type changes', () => {
|
@@ -78,10 +65,6 @@ describe('EmployeePickerFilterBar', () => {
|
|
78
65
|
fireEvent.blur(input);
|
79
66
|
|
80
67
|
expect(update).toHaveBeenCalledWith('John');
|
81
|
-
expect(event).toHaveBeenLastCalledWith({
|
82
|
-
action: 'Enter Name',
|
83
|
-
category: 'category'
|
84
|
-
});
|
85
68
|
});
|
86
69
|
|
87
70
|
it('should allow the user to clear the filter', () => {
|
@@ -95,26 +78,14 @@ describe('EmployeePickerFilterBar', () => {
|
|
95
78
|
fireEvent.click(clearBtn);
|
96
79
|
|
97
80
|
expect(update).toHaveBeenCalledWith('');
|
98
|
-
expect(event).toHaveBeenLastCalledWith({
|
99
|
-
action: 'Clear Filter',
|
100
|
-
category: 'category'
|
101
|
-
});
|
102
81
|
});
|
103
82
|
|
104
83
|
it('should allow the user to select and deselect all when no filter is present', () => {
|
105
84
|
fireEvent.click(element.getByText('Select all'));
|
106
85
|
expect(selectAll).toHaveBeenCalledTimes(1);
|
107
|
-
expect(event).toHaveBeenLastCalledWith({
|
108
|
-
action: 'Select All',
|
109
|
-
category: 'category'
|
110
|
-
});
|
111
86
|
|
112
87
|
fireEvent.click(element.getByText('Deselect all'));
|
113
88
|
expect(deselectAll).toHaveBeenCalledTimes(1);
|
114
|
-
expect(event).toHaveBeenLastCalledWith({
|
115
|
-
action: 'Deselect All',
|
116
|
-
category: 'category'
|
117
|
-
});
|
118
89
|
});
|
119
90
|
|
120
91
|
it('should disable the select all button if the prop is passed', () => {
|