Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] fixes scaling logic to check agg type instead schema (#42574) #42950

Merged
merged 1 commit into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/legacy/ui/public/agg_types/buckets/date_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ export const dateHistogramBucketAgg = new BucketAggType({

const scaleMetrics = interval.scaled && interval.scale < 1;
if (scaleMetrics && aggs) {
const all = _.every(aggs.bySchemaGroup.metrics, function (agg) {
return agg.type && agg.type.isScalable();
const metrics = aggs.filter(agg => agg.type && agg.type.type === 'metrics');
const all = _.every(metrics, function (agg) {
return agg.type.isScalable();
});
if (all) {
output.metricScale = interval.scale;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/legacy/ui/public/agg_types/controls/top_aggregate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ function TopAggregateParamEditor({
isInvalid={showValidation ? !isValid : false}
disabled={disabled}
onBlur={setTouched}
data-test-subj="visDefaultEditorAggregateWith"
/>
</EuiFormRow>
);
Expand Down
92 changes: 85 additions & 7 deletions test/functional/apps/visualize/_area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,93 @@ export default function ({ getService, getPageObjects }) {
await inspector.open();
await inspector.setTablePageSize(50);
await inspector.expectTableData(expectedTableData);
await inspector.close();
});

it('should hide side editor if embed is set to true in url', async () => {
const url = await browser.getCurrentUrl();
const embedUrl = url.split('/visualize/').pop().replace('?_g=', '?embed=true&_g=');
await PageObjects.common.navigateToUrl('visualize', embedUrl);
await PageObjects.header.waitUntilLoadingHasFinished();
const sideEditorExists = await PageObjects.visualize.getSideEditorExists();
expect(sideEditorExists).to.be(false);
describe('axis scaling', () => {
it('scales count agg', async () => {
const expectedTableData = [
[ '2015-09-20 00:00', '0.002' ],
[ '2015-09-20 01:00', '0.003' ],
[ '2015-09-20 02:00', '0.006' ],
[ '2015-09-20 03:00', '0.009' ],
[ '2015-09-20 04:00', '0.014' ],
[ '2015-09-20 05:00', '0.033' ],
[ '2015-09-20 06:00', '0.05' ],
[ '2015-09-20 07:00', '0.061' ],
[ '2015-09-20 08:00', '0.095' ],
[ '2015-09-20 09:00', '0.122' ],
[ '2015-09-20 10:00', '0.133' ],
[ '2015-09-20 11:00', '0.144' ],
[ '2015-09-20 12:00', '0.145' ],
[ '2015-09-20 13:00', '0.124' ],
[ '2015-09-20 14:00', '0.112' ],
[ '2015-09-20 15:00', '0.089' ],
[ '2015-09-20 16:00', '0.072' ],
[ '2015-09-20 17:00', '0.048' ],
[ '2015-09-20 18:00', '0.026' ],
[ '2015-09-20 19:00', '0.015' ],
];

await PageObjects.visualize.toggleOpenEditor(2);
await PageObjects.visualize.setInterval('Second');
await PageObjects.visualize.toggleOpenEditor(2, 'false');
await PageObjects.visualize.clickGo();
await inspector.open();
await inspector.expectTableData(expectedTableData);
await inspector.close();
});

it('does not scale top hit agg', async () => {
const expectedTableData = [
[ '2015-09-20 00:00', '6', '9.035KB' ],
[ '2015-09-20 01:00', '9', '5.854KB' ],
[ '2015-09-20 02:00', '22', '4.588KB' ],
[ '2015-09-20 03:00', '31', '8.349KB' ],
[ '2015-09-20 04:00', '52', '2.637KB' ],
[ '2015-09-20 05:00', '119', '1.712KB' ],
[ '2015-09-20 06:00', '181', '9.157KB' ],
[ '2015-09-20 07:00', '218', '8.192KB' ],
[ '2015-09-20 08:00', '341', '12.384KB' ],
[ '2015-09-20 09:00', '440', '4.482KB' ],
[ '2015-09-20 10:00', '480', '9.449KB' ],
[ '2015-09-20 11:00', '517', '213B' ],
[ '2015-09-20 12:00', '522', '638B' ],
[ '2015-09-20 13:00', '446', '7.421KB' ],
[ '2015-09-20 14:00', '403', '4.854KB' ],
[ '2015-09-20 15:00', '321', '4.132KB' ],
[ '2015-09-20 16:00', '258', '601B' ],
[ '2015-09-20 17:00', '172', '4.239KB' ],
[ '2015-09-20 18:00', '95', '6.272KB' ],
[ '2015-09-20 19:00', '55', '2.053KB' ]
];

await PageObjects.visualize.clickBucket('Y-axis', 'metrics');
await PageObjects.visualize.selectAggregation('Top Hit', 'metrics');
await PageObjects.visualize.selectField('bytes', 'metrics');
await PageObjects.visualize.selectAggregateWith('average');
await PageObjects.visualize.clickGo();
await inspector.open();
await inspector.expectTableData(expectedTableData);
await inspector.close();
});
});

describe('embedded mode', () => {
it('should hide side editor if embed is set to true in url', async () => {
const url = await browser.getCurrentUrl();
const embedUrl = url.split('/visualize/').pop().replace('?_g=', '?embed=true&_g=');
await PageObjects.common.navigateToUrl('visualize', embedUrl);
await PageObjects.header.waitUntilLoadingHasFinished();
const sideEditorExists = await PageObjects.visualize.getSideEditorExists();
expect(sideEditorExists).to.be(false);
});

after(async () => {
const url = await browser.getCurrentUrl();
const embedUrl = url.split('/visualize/').pop().replace('?embed=true&', '?');
await PageObjects.common.navigateToUrl('visualize', embedUrl);
});
});

describe.skip('switch between Y axis scale types', () => {
Expand Down
6 changes: 6 additions & 0 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
await comboBox.setElement(fieldEl, fieldValue);
}

async selectAggregateWith(fieldValue) {
const sortSelect = await testSubjects.find(`visDefaultEditorAggregateWith`);
const sortMetric = await sortSelect.findByCssSelector(`option[value="${fieldValue}"]`);
await sortMetric.click();
}

async selectFieldById(fieldValue, id) {
await find.clickByCssSelector(`#${id} > option[label="${fieldValue}"]`);
}
Expand Down