Skip to content

Commit

Permalink
fix tests and update name data-test-subj name
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Aug 9, 2019
1 parent 0427cd9 commit 120de8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('Create Rollup Job, step 5: Metrics', () => {
const { rows: [firstRow] } = table.getMetaData('rollupJobMetricsFieldList');
const columnWithMetricsCheckboxes = 2;
const metricsCheckboxes = firstRow.columns[columnWithMetricsCheckboxes].reactWrapper.find('input');
expect(metricsCheckboxes.length).toBe(numericTypeMetrics.length);
expect(metricsCheckboxes.length).toBe(numericTypeMetrics.length + 1 /* add one for select all */);
});

it('should have "max", "min", & "value count" metrics for *date* fields', () => {
Expand All @@ -217,7 +217,7 @@ describe('Create Rollup Job, step 5: Metrics', () => {
const { rows: [firstRow] } = table.getMetaData('rollupJobMetricsFieldList');
const columnWithMetricsCheckboxes = 2;
const metricsCheckboxes = firstRow.columns[columnWithMetricsCheckboxes].reactWrapper.find('input');
expect(metricsCheckboxes.length).toBe(dateTypeMetrics.length);
expect(metricsCheckboxes.length).toBe(dateTypeMetrics.length + 1 /* add one for select all */);
});

it('should not allow to go to the next step if at least one metric type is not selected', () => {
Expand Down Expand Up @@ -308,7 +308,7 @@ describe('Create Rollup Job, step 5: Metrics', () => {
});

it('should select all of the metric types across rows', () => {
const selectAllAvgCheckbox = find('rollupJobMetricsCheckbox-avg');
const selectAllAvgCheckbox = find('rollupJobMetricsSelectAllCheckbox-avg');
selectAllAvgCheckbox.first().simulate('change', { checked: true });

const rows = getFieldListTableRows();
Expand All @@ -331,7 +331,7 @@ describe('Create Rollup Job, step 5: Metrics', () => {
});

it('should deselect all of the metric types across rows', () => {
const selectAllAvgCheckbox = find('rollupJobMetricsCheckbox-avg');
const selectAllAvgCheckbox = find('rollupJobMetricsSelectAllCheckbox-avg');
selectAllAvgCheckbox.last().simulate('change', { checked: true });
selectAllAvgCheckbox.last().simulate('change', { checked: false });

Expand Down Expand Up @@ -360,18 +360,18 @@ describe('Create Rollup Job, step 5: Metrics', () => {
* 1. Select all avg column-wise
* 2. Select all max column-wise
* 3. Select and deselect row-wise the first numeric metric row
* 4. Expect the avg and max popover checkboxes to be unchecked
* 4. Expect the avg and max select all checkboxes to be unchecked
* 5. Select all on the last date metric row-wise
* 6. Deselect all max column-wise
* 6. Select then deselect all max column-wise
* 7. Expect everything but all and max to be selected on the last date metric row
*
* Let's a go!
*/

// 1.
find('rollupJobMetricsCheckbox-avg').first().simulate('change', { checked: true });
find('rollupJobMetricsSelectAllCheckbox-avg').first().simulate('change', { checked: true });
// 2.
find('rollupJobMetricsCheckbox-max').first().simulate('change', { checked: true });
find('rollupJobMetricsSelectAllCheckbox-max').first().simulate('change', { checked: true });

const selectAllCheckbox = getSelectAllInputForRow(0);

Expand All @@ -382,15 +382,16 @@ describe('Create Rollup Job, step 5: Metrics', () => {
selectAllCheckbox.simulate('change', { checked: false });

// 4.
expect(find('rollupJobMetricsCheckbox-avg').first().props().checked).toBe(false);
expect(find('rollupJobMetricsCheckbox-max').first().props().checked).toBe(false);
expect(find('rollupJobMetricsSelectAllCheckbox-avg').first().props().checked).toBe(false);
expect(find('rollupJobMetricsSelectAllCheckbox-max').first().props().checked).toBe(false);

let rows = getFieldListTableRows();
// 5.
getSelectAllInputForRow(rows.length - 1).simulate('change', { checked: true });

// 6.
find('rollupJobMetricsCheckbox-max').last().simulate('change', { checked: false });
find('rollupJobMetricsSelectAllCheckbox-max').first().simulate('change', { checked: true });
find('rollupJobMetricsSelectAllCheckbox-max').first().simulate('change', { checked: false });

rows = getFieldListTableRows();
const lastRowFieldChooserColumn = getFieldChooserColumnForRow(rows.length - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class StepMetricsUi extends Component {
return (
<EuiCheckbox
id={`${idx}-select-all-checkbox`}
data-test-subj={`rollupJobMetricsCheckbox-${metricType}`}
data-test-subj={`rollupJobMetricsSelectAllCheckbox-${metricType}`}
disabled={isDisabled}
label={<span style={{ whiteSpace: 'nowrap' }}>{label}</span>}
checked={!isDisabled && isChecked}
Expand Down Expand Up @@ -247,15 +247,13 @@ export class StepMetricsUi extends Component {
};

return (
<EuiFlexItem grow={false} key={`${fieldName}-selectAll-checkbox`}>
<EuiCheckbox
id={`${fieldName}-selectAll-checkbox`}
data-test-subj={`rollupJobMetricsCheckbox-selectAll`}
label={label}
checked={allSelected}
onChange={onChange}
/>
</EuiFlexItem>
<EuiCheckbox
id={`${fieldName}-selectAll-checkbox`}
data-test-subj={`rollupJobMetricsCheckbox-selectAll`}
label={label}
checked={allSelected}
onChange={onChange}
/>
);
}

Expand Down Expand Up @@ -293,7 +291,9 @@ export class StepMetricsUi extends Component {

return (
<EuiFlexGroup wrap gutterSize="m">
{this.renderRowSelectAll({ fieldName, fieldType, types })}
<EuiFlexItem grow={false} key={`${fieldName}-selectAll-checkbox`}>
{this.renderRowSelectAll({ fieldName, fieldType, types })}
</EuiFlexItem>
{checkboxes}
</EuiFlexGroup>
);
Expand Down

0 comments on commit 120de8e

Please sign in to comment.