Skip to content

Commit

Permalink
update tests and await
Browse files Browse the repository at this point in the history
Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
  • Loading branch information
kavilla committed Nov 22, 2024
1 parent d8d59b9 commit cf8341a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/plugins/vis_augmenter/public/utils/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('utils', () => {
aggs: VALID_AGGS,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(vis)).toEqual(false);
expect(await isEligibleForVisLayers(vis)).toEqual(false);
});
it('vis is ineligible with no date_histogram', async () => {
const invalidConfigStates = [
Expand All @@ -89,7 +89,7 @@ describe('utils', () => {
invalidAggs,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(vis)).toEqual(false);
expect(await isEligibleForVisLayers(vis)).toEqual(false);
});
it('vis is ineligible with invalid aggs counts', async () => {
const invalidConfigStates = [
Expand All @@ -113,7 +113,7 @@ describe('utils', () => {
invalidAggs,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(vis)).toEqual(false);
expect(await isEligibleForVisLayers(vis)).toEqual(false);
});
it('vis is ineligible with no metric aggs', async () => {
const invalidConfigStates = [
Expand All @@ -135,7 +135,7 @@ describe('utils', () => {
invalidAggs,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(vis)).toEqual(false);
expect(await isEligibleForVisLayers(vis)).toEqual(false);
});
it('vis is ineligible with series param is not line type', async () => {
const vis = ({
Expand All @@ -156,7 +156,7 @@ describe('utils', () => {
aggs: VALID_AGGS,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(vis)).toEqual(false);
expect(await isEligibleForVisLayers(vis)).toEqual(false);
});
it('vis is ineligible with series param not all being line type', async () => {
const vis = ({
Expand All @@ -180,7 +180,7 @@ describe('utils', () => {
aggs: VALID_AGGS,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(vis)).toEqual(false);
expect(await isEligibleForVisLayers(vis)).toEqual(false);
});
it('vis is ineligible with invalid x-axis due to no segment aggregation', async () => {
const badConfigStates = [
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('utils', () => {
badAggs,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(invalidVis)).toEqual(false);
expect(await isEligibleForVisLayers(invalidVis)).toEqual(false);
});
it('vis is ineligible with xaxis not on bottom', async () => {
const invalidVis = ({
Expand All @@ -239,7 +239,7 @@ describe('utils', () => {
aggs: VALID_AGGS,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(invalidVis)).toEqual(false);
expect(await isEligibleForVisLayers(invalidVis)).toEqual(false);
});
it('vis is ineligible with no seriesParams', async () => {
const invalidVis = ({
Expand All @@ -255,16 +255,16 @@ describe('utils', () => {
aggs: VALID_AGGS,
},
} as unknown) as Vis;
expect(isEligibleForVisLayers(invalidVis)).toEqual(false);
expect(await isEligibleForVisLayers(invalidVis)).toEqual(false);
});
it('vis is ineligible with valid type and disabled setting', async () => {
uiSettingsMock.get.mockImplementation((key: string) => {
return key !== PLUGIN_AUGMENTATION_ENABLE_SETTING;
});
expect(isEligibleForVisLayers(VALID_VIS)).toEqual(false);
expect(await isEligibleForVisLayers(VALID_VIS)).toEqual(false);
});
it('vis is eligible with valid type', async () => {
expect(isEligibleForVisLayers(VALID_VIS)).toEqual(true);
expect(await isEligibleForVisLayers(VALID_VIS)).toEqual(true);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ViewEventsOptionAction implements Action<EmbeddableContext> {
const vis = (embeddable as VisualizeEmbeddable).vis;
return (
vis !== undefined &&
isEligibleForVisLayers(vis) &&
(await isEligibleForVisLayers(vis)) &&
!isEmpty((embeddable as VisualizeEmbeddable).visLayers)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_vislib/public/line_to_expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const toExpressionAst = async (vis: Vis, params: any) => {
if (
params.visLayers == null ||
Object.keys(params.visLayers).length === 0 ||
!isEligibleForVisLayers(vis)
!(await isEligibleForVisLayers(vis))
) {
// Render using vislib instead of vega-lite
const visConfig = { ...vis.params, dimensions };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ export class VisualizeEmbeddable
this.visAugmenterConfig?.visLayerResourceIds
);

if (!isEmpty(augmentVisSavedObjs) && !aborted && isEligibleForVisLayers(this.vis)) {
if (!isEmpty(augmentVisSavedObjs) && !aborted && (await isEligibleForVisLayers(this.vis))) {
const visLayersPipeline = buildPipelineFromAugmentVisSavedObjs(augmentVisSavedObjs);
// The initial input for the pipeline will just be an empty arr of VisLayers. As plugin
// expression functions are ran, they will incrementally append their generated VisLayers to it.
Expand Down

0 comments on commit cf8341a

Please sign in to comment.