Skip to content

Commit

Permalink
[Vis Augmenter] Fix bug of undefined tooltip when all plugin layers a…
Browse files Browse the repository at this point in the history
…re empty (#4577) (#4578)

(cherry picked from commit 1249d3d)

Signed-off-by: Tyler Ohlsen <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent bf99855 commit 2084c9f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
71 changes: 71 additions & 0 deletions src/plugins/vis_augmenter/public/test_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,55 @@ const TEST_VALUES_MULTIPLE_VIS_LAYERS = [
},
];

const TEST_VALUES_MULTIPLE_VIS_LAYERS_ONE_EMPTY = [
{
[TEST_X_AXIS_ID]: 0,
[TEST_VALUE_AXIS_ID]: 5,
[TEST_PLUGIN_EVENT_TYPE]: 0,
[TEST_PLUGIN_EVENT_TYPE_2]: 0,
},
{
[TEST_X_AXIS_ID]: 5,
[TEST_VALUE_AXIS_ID]: 10,
[TEST_PLUGIN_EVENT_TYPE]: 2,
[TEST_PLUGIN_EVENT_TYPE_2]: 0,
},
{
[TEST_X_AXIS_ID]: 10,
[TEST_VALUE_AXIS_ID]: 6,
[TEST_PLUGIN_EVENT_TYPE]: 0,
[TEST_PLUGIN_EVENT_TYPE_2]: 0,
},
{
[TEST_X_AXIS_ID]: 15,
[TEST_VALUE_AXIS_ID]: 4,
[TEST_PLUGIN_EVENT_TYPE]: 0,
[TEST_PLUGIN_EVENT_TYPE_2]: 0,
},
{
[TEST_X_AXIS_ID]: 20,
[TEST_VALUE_AXIS_ID]: 5,
[TEST_PLUGIN_EVENT_TYPE]: 0,
[TEST_PLUGIN_EVENT_TYPE_2]: 0,
},
{ [TEST_X_AXIS_ID]: 25, [TEST_PLUGIN_EVENT_TYPE]: 0, [TEST_PLUGIN_EVENT_TYPE_2]: 0 },
{ [TEST_X_AXIS_ID]: 30, [TEST_PLUGIN_EVENT_TYPE]: 0, [TEST_PLUGIN_EVENT_TYPE_2]: 0 },
{ [TEST_X_AXIS_ID]: 35, [TEST_PLUGIN_EVENT_TYPE]: 1, [TEST_PLUGIN_EVENT_TYPE_2]: 0 },
{ [TEST_X_AXIS_ID]: 40, [TEST_PLUGIN_EVENT_TYPE]: 0, [TEST_PLUGIN_EVENT_TYPE_2]: 0 },
{
[TEST_X_AXIS_ID]: 45,
[TEST_VALUE_AXIS_ID]: 3,
[TEST_PLUGIN_EVENT_TYPE]: 0,
[TEST_PLUGIN_EVENT_TYPE_2]: 0,
},
{
[TEST_X_AXIS_ID]: 50,
[TEST_VALUE_AXIS_ID]: 5,
[TEST_PLUGIN_EVENT_TYPE]: 0,
[TEST_PLUGIN_EVENT_TYPE_2]: 0,
},
];

export const TEST_COLUMNS_NO_VIS_LAYERS = [
{
id: TEST_X_AXIS_ID,
Expand Down Expand Up @@ -269,6 +318,12 @@ export const TEST_DATATABLE_MULTIPLE_VIS_LAYERS = {
rows: TEST_VALUES_MULTIPLE_VIS_LAYERS,
} as OpenSearchDashboardsDatatable;

export const TEST_DATATABLE_MULTIPLE_VIS_LAYERS_ONE_EMPTY = {
type: 'opensearch_dashboards_datatable',
columns: TEST_COLUMNS_MULTIPLE_VIS_LAYERS,
rows: TEST_VALUES_MULTIPLE_VIS_LAYERS_ONE_EMPTY,
} as OpenSearchDashboardsDatatable;

const TEST_BASE_CONFIG = {
view: { stroke: null },
concat: { spacing: 0 },
Expand Down Expand Up @@ -510,6 +565,22 @@ export const TEST_VIS_LAYERS_MULTIPLE = [
},
];

export const TEST_VIS_LAYERS_MULTIPLE_ONE_EMPTY = [
...TEST_VIS_LAYERS_SINGLE,
{
originPlugin: TEST_PLUGIN,
type: VisLayerTypes.PointInTimeEvents,
pluginResource: {
type: TEST_PLUGIN_RESOURCE_TYPE,
id: TEST_PLUGIN_RESOURCE_ID_2,
name: TEST_PLUGIN_RESOURCE_NAME_2,
urlPath: TEST_PLUGIN_RESOURCE_PATH_2,
},
pluginEventType: TEST_PLUGIN_EVENT_TYPE_2,
events: [],
},
];

const TEST_RULE_LAYER_SINGLE_VIS_LAYER = {
mark: { type: 'rule', color: EVENT_COLOR, opacity: 1 },
transform: [{ filter: `datum['${TEST_PLUGIN_EVENT_TYPE}'] > 0` }],
Expand Down
12 changes: 12 additions & 0 deletions src/plugins/vis_augmenter/public/vega/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from '../';
import {
TEST_DATATABLE_MULTIPLE_VIS_LAYERS,
TEST_DATATABLE_MULTIPLE_VIS_LAYERS_ONE_EMPTY,
TEST_DATATABLE_NO_VIS_LAYERS,
TEST_DATATABLE_ONLY_VIS_LAYERS,
TEST_DATATABLE_SINGLE_ROW_NO_VIS_LAYERS,
Expand All @@ -48,6 +49,7 @@ import {
TEST_SPEC_NO_VIS_LAYERS,
TEST_SPEC_SINGLE_VIS_LAYER,
TEST_VIS_LAYERS_MULTIPLE,
TEST_VIS_LAYERS_MULTIPLE_ONE_EMPTY,
TEST_VIS_LAYERS_SINGLE,
TEST_VIS_LAYERS_SINGLE_INVALID_BOUNDS,
TEST_VIS_LAYERS_SINGLE_ON_BOUNDS,
Expand Down Expand Up @@ -410,6 +412,16 @@ describe('helpers', function () {
)
).toStrictEqual(TEST_DATATABLE_ONLY_VIS_LAYERS);
});
it('vis layers with one having events and the other empty are added correctly', function () {
expect(
addPointInTimeEventsLayersToTable(
TEST_DATATABLE_NO_VIS_LAYERS,

TEST_DIMENSIONS,
TEST_VIS_LAYERS_MULTIPLE_ONE_EMPTY
)
).toStrictEqual(TEST_DATATABLE_MULTIPLE_VIS_LAYERS_ONE_EMPTY);
});
it('vis layer with out-of-bounds timestamps are not added', function () {
expect(
addPointInTimeEventsLayersToTable(
Expand Down
1 change: 0 additions & 1 deletion src/plugins/vis_augmenter/public/vega/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ export const addPointInTimeEventsLayersToTable = (
});

visLayers.forEach((visLayer: PointInTimeEventsVisLayer) => {
if (isEmpty(visLayer.events)) return;
const visLayerColumnId = `${visLayer.pluginEventType}`;

// Add placeholder values of 0 for every event value. This is so the tooltip
Expand Down

0 comments on commit 2084c9f

Please sign in to comment.