Skip to content

Commit

Permalink
✅ Fix functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Jun 4, 2021
1 parent d7c6946 commit 9417ccc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,19 @@ export const DatatableComponent = (props: DatatableRenderProps) => {
return ({ columnId }: { columnId: string }) => {
const currentAlignment = alignments && alignments[columnId];
const alignmentClassName = `lnsTableCell--${currentAlignment}`;
const columnName =
columns.find(({ id }) => id === columnId)?.displayAsText?.replace(/ /g, '-') || columnId;
return summaryLookup[columnId] != null ? (
<div
className={`lnsTableCell ${alignmentClassName}`}
data-test-subj={`lnsDataTable-footer-${columnId}`}
data-test-subj={`lnsDataTable-footer-${columnName}`}
>
{summaryLookup[columnId]}
</div>
) : null;
};
}
}, [columnConfig.columns, alignments, firstTable]);
}, [columnConfig.columns, alignments, firstTable, columns]);

if (isEmpty) {
return <EmptyPlaceholder icon={LensIconChartDatatable} />;
Expand Down
12 changes: 11 additions & 1 deletion x-pack/plugins/lens/public/datatable_visualization/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,53 @@ export function getDefaultSummaryLabel(type: SummaryRowType) {
return getSummaryRowOptions().find(({ value }) => type === value)!.inputDisplay!;
}

export function getSummaryRowOptions(): Array<{ value: SummaryRowType; inputDisplay: string }> {
export function getSummaryRowOptions(): Array<{
value: SummaryRowType;
inputDisplay: string;
'data-test-subj': string;
}> {
return [
{
value: 'none',
inputDisplay: i18n.translate('xpack.lens.table.summaryRow.none', {
defaultMessage: 'None',
}),
'data-test-subj': 'lns-datatable-summary-none',
},
{
value: 'count',
inputDisplay: i18n.translate('xpack.lens.table.summaryRow.count', {
defaultMessage: 'Value count',
}),
'data-test-subj': 'lns-datatable-summary-count',
},
{
value: 'sum',
inputDisplay: i18n.translate('xpack.lens.table.summaryRow.sum', {
defaultMessage: 'Sum',
}),
'data-test-subj': 'lns-datatable-summary-sum',
},
{
value: 'avg',
inputDisplay: i18n.translate('xpack.lens.table.summaryRow.average', {
defaultMessage: 'Average',
}),
'data-test-subj': 'lns-datatable-summary-avg',
},
{
value: 'min',
inputDisplay: i18n.translate('xpack.lens.table.summaryRow.minimum', {
defaultMessage: 'Minimum',
}),
'data-test-subj': 'lns-datatable-summary-min',
},
{
value: 'max',
inputDisplay: i18n.translate('xpack.lens.table.summaryRow.maximum', {
defaultMessage: 'Maximum',
}),
'data-test-subj': 'lns-datatable-summary-max',
},
];
}
Expand Down
6 changes: 3 additions & 3 deletions x-pack/test/functional/apps/lens/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(styleObj['background-color']).to.be('rgb(168, 191, 218)');
// should also set text color when in cell mode
expect(styleObj.color).to.be('rgb(0, 0, 0)');
await PageObjects.lens.closeTablePalettePanel();
});

it('should allow to show a summary table for metric columns', async () => {
await PageObjects.lens.openDimensionEditor('lnsDatatable_metrics > lns-dimensionTrigger');
await PageObjects.lens.setTableSummaryRowFunction('sum');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.lens.assertExactText(
'[data-test-subj="lnsDataTable-footer-c"]',
'Sum: 100'
'[data-test-subj="lnsDataTable-footer-169.228.188.120-›-Average-of-bytes"]',
'Sum: 18,994'
);
});
});
Expand Down
9 changes: 6 additions & 3 deletions x-pack/test/functional/page_objects/lens_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,8 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
async setTableSummaryRowFunction(
summaryFunction: 'none' | 'sum' | 'avg' | 'count' | 'min' | 'max'
) {
const target = await testSubjects.find('lnsDatatable_summaryrow_function');
await comboBox.openOptionsList(target);
await comboBox.setElement(target, summaryFunction);
await testSubjects.click('lnsDatatable_summaryrow_function');
await testSubjects.click('lns-datatable-summary-' + summaryFunction);
},

async setTableSummaryRowLabel(newLabel: string) {
Expand All @@ -767,6 +766,10 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont
await testSubjects.click('lnsDatatable_dynamicColoring_trigger');
},

async closeTablePalettePanel() {
await testSubjects.click('lns-indexPattern-PalettePanelContainerBack');
},

// different picker from the next one
async changePaletteTo(paletteName: string) {
await testSubjects.click('lnsDatatable_dynamicColoring_palette_picker');
Expand Down

0 comments on commit 9417ccc

Please sign in to comment.