Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kravets-levko committed Nov 23, 2019
1 parent ad114f8 commit 94e5ac1
Show file tree
Hide file tree
Showing 20 changed files with 109 additions and 92 deletions.
1 change: 0 additions & 1 deletion client/app/components/ColorPicker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default function ColorPicker({
{addonBefore}
<Popover
arrowPointAtCenter
destroyTooltipOnHide
overlayClassName={`color-picker ${interactive ? 'color-picker-interactive' : 'color-picker-with-actions'}`}
overlayStyle={{ '--color-picker-selected-color': currentColor }}
content={(
Expand Down
44 changes: 24 additions & 20 deletions client/app/components/TextAlignmentSelect/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { pickBy, startsWith } from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
Expand All @@ -9,26 +10,29 @@ import './index.less';

export default function TextAlignmentSelect({ className, ...props }) {
return (
<Radio.Group
className={cx('text-alignment-select', className)}
{...props}
>
<Tooltip title="Align left" mouseEnterDelay={0} mouseLeaveDelay={0}>
<Radio.Button value="left" data-test="TextAlignmentSelect.Left">
<Icon type="align-left" />
</Radio.Button>
</Tooltip>
<Tooltip title="Align center" mouseEnterDelay={0} mouseLeaveDelay={0}>
<Radio.Button value="center" data-test="TextAlignmentSelect.Center">
<Icon type="align-center" />
</Radio.Button>
</Tooltip>
<Tooltip title="Align right" mouseEnterDelay={0} mouseLeaveDelay={0}>
<Radio.Button value="right" data-test="TextAlignmentSelect.Right">
<Icon type="align-right" />
</Radio.Button>
</Tooltip>
</Radio.Group>
// Antd RadioGroup does not use any custom attributes
<div {...pickBy(props, (v, k) => startsWith(k, 'data-'))}>
<Radio.Group
className={cx('text-alignment-select', className)}
{...props}
>
<Tooltip title="Align left" mouseEnterDelay={0} mouseLeaveDelay={0}>
<Radio.Button value="left" data-test="TextAlignmentSelect.Left">
<Icon type="align-left" />
</Radio.Button>
</Tooltip>
<Tooltip title="Align center" mouseEnterDelay={0} mouseLeaveDelay={0}>
<Radio.Button value="center" data-test="TextAlignmentSelect.Center">
<Icon type="align-center" />
</Radio.Button>
</Tooltip>
<Tooltip title="Align right" mouseEnterDelay={0} mouseLeaveDelay={0}>
<Radio.Button value="right" data-test="TextAlignmentSelect.Right">
<Icon type="align-right" />
</Radio.Button>
</Tooltip>
</Radio.Group>
</div>
);
}

Expand Down
29 changes: 19 additions & 10 deletions client/app/visualizations/chart/Editor/ColorsSettings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ describe('Visualizations -> Chart -> Editor -> Colors Settings', () => {
columnMapping: { a: 'x', b: 'y' },
}, done);

findByTestID(el, 'Chart.Series.v.Color').first().simulate('click');
findByTestID(el, 'ColorPicker').first().find('input')
findByTestID(el, 'Chart.Series.v.Color')
.find('.color-picker-trigger').last()
.simulate('click');
findByTestID(el, 'ColorPicker').last().find('input')
.simulate('change', { target: { value: 'red' } });
});
});
Expand All @@ -48,8 +50,8 @@ describe('Visualizations -> Chart -> Editor -> Colors Settings', () => {
columnMapping: { a: 'x', b: 'y' },
}, done);

findByTestID(el, 'Chart.Colors.Heatmap.ColorScheme').first().simulate('click');
findByTestID(el, 'Chart.Colors.Heatmap.ColorScheme.RdBu').first().simulate('click');
findByTestID(el, 'Chart.Colors.Heatmap.ColorScheme').last().simulate('click');
findByTestID(el, 'Chart.Colors.Heatmap.ColorScheme.RdBu').last().simulate('click');
});

test('Sets custom color scheme', async (done) => {
Expand All @@ -59,12 +61,16 @@ describe('Visualizations -> Chart -> Editor -> Colors Settings', () => {
colorScheme: 'Custom...',
}, after(2, done)); // we will perform 2 actions, so call `done` after all of them completed

findByTestID(el, 'Chart.Colors.Heatmap.MinColor').first().simulate('click');
findByTestID(el, 'ColorPicker').first().find('input')
findByTestID(el, 'Chart.Colors.Heatmap.MinColor')
.find('.color-picker-trigger').last()
.simulate('click');
findByTestID(el, 'ColorPicker').last().find('input')
.simulate('change', { target: { value: 'yellow' } });

findByTestID(el, 'Chart.Colors.Heatmap.MaxColor').first().simulate('click');
findByTestID(el, 'ColorPicker').first().find('input')
findByTestID(el, 'Chart.Colors.Heatmap.MaxColor')
.find('.color-picker-trigger').last()
.simulate('click');
findByTestID(el, 'ColorPicker').last().find('input')
.simulate('change', { target: { value: 'red' } });
});
});
Expand All @@ -76,8 +82,11 @@ describe('Visualizations -> Chart -> Editor -> Colors Settings', () => {
columnMapping: { a: 'x', b: 'y' },
}, done);

findByTestID(el, 'Chart.Series.b.Color').first().simulate('click');
findByTestID(el, 'ColorPicker').first().find('input')
findByTestID(el, 'Chart.Series.b.Color')
.find('.color-picker-trigger').last()
.simulate('click');

findByTestID(el, 'ColorPicker').last().find('input')
.simulate('change', { target: { value: 'red' } });
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Visualizations -> Chart -> Editor -> Data Labels Settings', () => {
showDataLabels: false,
}, done);

findByTestID(el, 'Chart.DataLabels.ShowDataLabels').first().find('input')
findByTestID(el, 'Chart.DataLabels.ShowDataLabels').last().find('input')
.simulate('change', { target: { checked: true } });
});

Expand All @@ -40,7 +40,7 @@ describe('Visualizations -> Chart -> Editor -> Data Labels Settings', () => {
numberFormat: '0[.]0000',
}, done);

findByTestID(el, 'Chart.DataLabels.NumberFormat').first()
findByTestID(el, 'Chart.DataLabels.NumberFormat').last()
.simulate('change', { target: { value: '0.00' } });
});

Expand All @@ -50,7 +50,7 @@ describe('Visualizations -> Chart -> Editor -> Data Labels Settings', () => {
percentFormat: '0[.]00%',
}, done);

findByTestID(el, 'Chart.DataLabels.PercentFormat').first()
findByTestID(el, 'Chart.DataLabels.PercentFormat').last()
.simulate('change', { target: { value: '0.0%' } });
});

Expand All @@ -60,7 +60,7 @@ describe('Visualizations -> Chart -> Editor -> Data Labels Settings', () => {
dateTimeFormat: 'YYYY-MM-DD HH:mm:ss',
}, done);

findByTestID(el, 'Chart.DataLabels.DateTimeFormat').first()
findByTestID(el, 'Chart.DataLabels.DateTimeFormat').last()
.simulate('change', { target: { value: 'YYYY MMM DD' } });
});

Expand All @@ -70,7 +70,7 @@ describe('Visualizations -> Chart -> Editor -> Data Labels Settings', () => {
textFormat: null,
}, done);

findByTestID(el, 'Chart.DataLabels.TextFormat').first()
findByTestID(el, 'Chart.DataLabels.TextFormat').last()
.simulate('change', { target: { value: '{{ @@x }} :: {{ @@y }} / {{ @@yPercent }}' } });
});
});
22 changes: 11 additions & 11 deletions client/app/visualizations/chart/Editor/GeneralSettings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describe('Visualizations -> Chart -> Editor -> General Settings', () => {
},
}, done);

findByTestID(el, 'Chart.GlobalSeriesType').first().simulate('click');
findByTestID(el, 'Chart.ChartType.pie').first().simulate('click');
findByTestID(el, 'Chart.GlobalSeriesType').last().simulate('click');
findByTestID(el, 'Chart.ChartType.pie').last().simulate('click');
});

test('Pie: changes direction', (done) => {
Expand All @@ -48,8 +48,8 @@ describe('Visualizations -> Chart -> Editor -> General Settings', () => {
direction: { type: 'counterclockwise' },
}, done);

findByTestID(el, 'Chart.PieDirection').first().simulate('click');
findByTestID(el, 'Chart.PieDirection.Clockwise').first().simulate('click');
findByTestID(el, 'Chart.PieDirection').last().simulate('click');
findByTestID(el, 'Chart.PieDirection.Clockwise').last().simulate('click');
});

test('Toggles legend', (done) => {
Expand All @@ -58,7 +58,7 @@ describe('Visualizations -> Chart -> Editor -> General Settings', () => {
legend: { enabled: true },
}, done);

findByTestID(el, 'Chart.ShowLegend').first().find('input')
findByTestID(el, 'Chart.ShowLegend').last().find('input')
.simulate('change', { target: { checked: false } });
});

Expand All @@ -68,7 +68,7 @@ describe('Visualizations -> Chart -> Editor -> General Settings', () => {
showpoints: false,
}, done);

findByTestID(el, 'Chart.ShowPoints').first().find('input')
findByTestID(el, 'Chart.ShowPoints').last().find('input')
.simulate('change', { target: { checked: true } });
});

Expand All @@ -78,8 +78,8 @@ describe('Visualizations -> Chart -> Editor -> General Settings', () => {
series: {},
}, done);

findByTestID(el, 'Chart.Stacking').first().simulate('click');
findByTestID(el, 'Chart.Stacking.Stack').first().simulate('click');
findByTestID(el, 'Chart.Stacking').last().simulate('click');
findByTestID(el, 'Chart.Stacking.Stack').last().simulate('click');
});

test('Toggles normalize values to percentage', (done) => {
Expand All @@ -88,7 +88,7 @@ describe('Visualizations -> Chart -> Editor -> General Settings', () => {
series: {},
}, done);

findByTestID(el, 'Chart.NormalizeValues').first().find('input')
findByTestID(el, 'Chart.NormalizeValues').last().find('input')
.simulate('change', { target: { checked: true } });
});

Expand All @@ -98,8 +98,8 @@ describe('Visualizations -> Chart -> Editor -> General Settings', () => {
missingValuesAsZero: true,
}, done);

findByTestID(el, 'Chart.MissingValues').first().simulate('click');
findByTestID(el, 'Chart.MissingValues.Keep').first().simulate('click');
findByTestID(el, 'Chart.MissingValues').last().simulate('click');
findByTestID(el, 'Chart.MissingValues.Keep').last().simulate('click');
});

describe('Column mappings should be available', () => {
Expand Down
8 changes: 4 additions & 4 deletions client/app/visualizations/chart/Editor/SeriesSettings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ describe('Visualizations -> Chart -> Editor -> Series Settings', () => {
},
}, done);

findByTestID(el, 'Chart.Series.a.Type').first().simulate('click');
findByTestID(el, 'Chart.ChartType.area').first().simulate('click');
findByTestID(el, 'Chart.Series.a.Type').last().simulate('click');
findByTestID(el, 'Chart.ChartType.area').last().simulate('click');
});

test('Changes series label', (done) => {
Expand All @@ -46,7 +46,7 @@ describe('Visualizations -> Chart -> Editor -> Series Settings', () => {
},
}, done);

findByTestID(el, 'Chart.Series.a.Label').first().simulate('change', { target: { value: 'test' } });
findByTestID(el, 'Chart.Series.a.Label').last().simulate('change', { target: { value: 'test' } });
});

test('Changes series axis', (done) => {
Expand All @@ -58,7 +58,7 @@ describe('Visualizations -> Chart -> Editor -> Series Settings', () => {
},
}, done);

findByTestID(el, 'Chart.Series.a.UseRightAxis').first().find('input')
findByTestID(el, 'Chart.Series.a.UseRightAxis').last().find('input')
.simulate('change', { target: { checked: true } });
});
});
12 changes: 6 additions & 6 deletions client/app/visualizations/chart/Editor/XAxisSettings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe('Visualizations -> Chart -> Editor -> X-Axis Settings', () => {
xAxis: { type: '-', labels: { enabled: true } },
}, done);

findByTestID(el, 'Chart.XAxis.Type').first().simulate('click');
findByTestID(el, 'Chart.XAxis.Type.Linear').first().simulate('click');
findByTestID(el, 'Chart.XAxis.Type').last().simulate('click');
findByTestID(el, 'Chart.XAxis.Type.Linear').last().simulate('click');
});

test('Changes axis name', (done) => {
Expand All @@ -40,7 +40,7 @@ describe('Visualizations -> Chart -> Editor -> X-Axis Settings', () => {
xAxis: { type: '-', labels: { enabled: true } },
}, done);

findByTestID(el, 'Chart.XAxis.Name').first().simulate('change', { target: { value: 'test' } });
findByTestID(el, 'Chart.XAxis.Name').last().simulate('change', { target: { value: 'test' } });
});

test('Sets Show Labels option', (done) => {
Expand All @@ -49,7 +49,7 @@ describe('Visualizations -> Chart -> Editor -> X-Axis Settings', () => {
xAxis: { type: '-', labels: { enabled: false } },
}, done);

findByTestID(el, 'Chart.XAxis.ShowLabels').first().simulate('click');
findByTestID(el, 'Chart.XAxis.ShowLabels').last().simulate('click');
});

test('Sets Sort X Values option', (done) => {
Expand All @@ -58,7 +58,7 @@ describe('Visualizations -> Chart -> Editor -> X-Axis Settings', () => {
sortX: false,
}, done);

findByTestID(el, 'Chart.XAxis.Sort').first().simulate('click');
findByTestID(el, 'Chart.XAxis.Sort').last().simulate('click');
});

test('Sets Reverse X Values option', (done) => {
Expand All @@ -67,6 +67,6 @@ describe('Visualizations -> Chart -> Editor -> X-Axis Settings', () => {
reverseX: false,
}, done);

findByTestID(el, 'Chart.XAxis.Reverse').first().simulate('click');
findByTestID(el, 'Chart.XAxis.Reverse').last().simulate('click');
});
});
14 changes: 7 additions & 7 deletions client/app/visualizations/chart/Editor/YAxisSettings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ describe('Visualizations -> Chart -> Editor -> Y-Axis Settings', () => {
yAxis: [{ type: 'linear' }, { type: 'linear', opposite: true }],
}, done);

findByTestID(el, 'Chart.LeftYAxis.Type').first().simulate('click');
findByTestID(el, 'Chart.LeftYAxis.Type.Category').first().simulate('click');
findByTestID(el, 'Chart.LeftYAxis.Type').last().simulate('click');
findByTestID(el, 'Chart.LeftYAxis.Type.Category').last().simulate('click');
});

test('Changes axis name', (done) => {
Expand All @@ -44,7 +44,7 @@ describe('Visualizations -> Chart -> Editor -> Y-Axis Settings', () => {
yAxis: [{ type: 'linear' }, { type: 'linear', opposite: true }],
}, done);

findByTestID(el, 'Chart.LeftYAxis.Name').first().simulate('change', { target: { value: 'test' } });
findByTestID(el, 'Chart.LeftYAxis.Name').last().simulate('change', { target: { value: 'test' } });
});

test('Changes axis min value', (done) => {
Expand All @@ -53,7 +53,7 @@ describe('Visualizations -> Chart -> Editor -> Y-Axis Settings', () => {
yAxis: [{ type: 'linear' }, { type: 'linear', opposite: true }],
}, done);

findByTestID(el, 'Chart.LeftYAxis.RangeMin').find('input').first().simulate('change', { target: { value: '50' } });
findByTestID(el, 'Chart.LeftYAxis.RangeMin').find('input').last().simulate('change', { target: { value: '50' } });
});

test('Changes axis max value', (done) => {
Expand All @@ -62,7 +62,7 @@ describe('Visualizations -> Chart -> Editor -> Y-Axis Settings', () => {
yAxis: [{ type: 'linear' }, { type: 'linear', opposite: true }],
}, done);

findByTestID(el, 'Chart.LeftYAxis.RangeMax').find('input').first().simulate('change', { target: { value: '200' } });
findByTestID(el, 'Chart.LeftYAxis.RangeMax').find('input').last().simulate('change', { target: { value: '200' } });
});

describe('for non-heatmap', () => {
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('Visualizations -> Chart -> Editor -> Y-Axis Settings', () => {
sortY: false,
}, done);

findByTestID(el, 'Chart.LeftYAxis.Sort').first().simulate('click');
findByTestID(el, 'Chart.LeftYAxis.Sort').last().simulate('click');
});

test('Sets Reverse Y Values option', (done) => {
Expand All @@ -101,7 +101,7 @@ describe('Visualizations -> Chart -> Editor -> Y-Axis Settings', () => {
reverseY: false,
}, done);

findByTestID(el, 'Chart.LeftYAxis.Reverse').first().simulate('click');
findByTestID(el, 'Chart.LeftYAxis.Reverse').last().simulate('click');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Object {

exports[`Visualizations -> Chart -> Editor -> Colors Settings for heatmap Sets custom color scheme 2`] = `
Object {
"heatMinColor": "#FF0000",
"heatMaxColor": "#FF0000",
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default function GeneralSettings({ options, onOptionsChange }) {
</Grid.Col>
<Grid.Col span={12}>
<TextAlignmentSelect
data-test="Choropleth.Editor.LegendTextAlignment"
label="Legend text alignment"
disabled={!options.legend.visible}
defaultValue={options.legend.alignText}
Expand Down
1 change: 1 addition & 0 deletions client/app/visualizations/table/Editor/ColumnEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function ColumnEditor({ column, onChange }) {
</Grid.Col>
<Grid.Col span={8}>
<TextAlignmentSelect
data-test={`Table.Column.${column.name}.TextAlignment`}
defaultValue={column.alignContent}
onChange={event => handleChange({ alignContent: event.target.value })}
/>
Expand Down
Loading

0 comments on commit 94e5ac1

Please sign in to comment.