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.17] [Lens] Fixes error on table when there is no data (#161953) #162018

Merged
merged 1 commit into from
Jul 17, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DatatableArgs } from './datatable';

import { transposeTable } from './transpose_helpers';

describe('transpose_helpes', () => {
describe('transpose_helpers', () => {
function buildTable(): Datatable {
// 3 buckets, 2 metrics
// first bucket goes A/B/C
Expand Down Expand Up @@ -290,4 +290,26 @@ describe('transpose_helpes', () => {
1 + 18 - 2
);
});

it('should not fail for no data', () => {
const table = buildTable();
const updatedTable = {
...table,
rows: [],
};
const args = buildArgs();
const updatedArgs = {
...args,
columns: [
{
type: 'lens_datatable_column',
columnId: 'bucket1',
isTransposed: true,
transposable: false,
},
],
} as DatatableArgs;
transposeTable(updatedArgs, updatedTable, buildFormatters());
expect(args.columns.length).toEqual(5);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function updateColumnArgs(
) {
args.columns = [...bucketsColumnArgs];
// add first column from each group, then add second column for each group, ...
transposedColumnGroups[0].forEach((_, index) => {
transposedColumnGroups[0]?.forEach((_, index) => {
transposedColumnGroups.forEach((transposedColumnGroup) => {
args.columns.push(transposedColumnGroup[index]);
});
Expand Down