Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Jul 14, 2023
1 parent e31b7a9 commit 830690f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
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

0 comments on commit 830690f

Please sign in to comment.