Skip to content

Commit

Permalink
🐛 Fix merge conflict bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Dec 19, 2024
1 parent 8d2973b commit aece621
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
getLensApiMock,
getLensAttributesMock,
getLensInternalApiMock,
getVisualizationContextHelperMock,
makeEmbeddableServices,
} from './mocks';
import { BehaviorSubject, filter, firstValueFrom } from 'rxjs';
Expand All @@ -23,7 +22,6 @@ import {
LensEmbeddableStartServices,
LensInternalApi,
LensPublicCallbacks,
VisualizationContextHelper,
} from './types';
import {
HasParentApi,
Expand Down Expand Up @@ -73,7 +71,6 @@ type ChangeFnType = ({
parentApi,
internalApi,
services,
visualizationContextHelper,
}: {
api: LensApi;
internalApi: LensInternalApi;
Expand All @@ -83,7 +80,6 @@ type ChangeFnType = ({
searchSessionId$: BehaviorSubject<string>;
};
services: LensEmbeddableStartServices;
visualizationContextHelper: VisualizationContextHelper;
}) => Promise<void | boolean>;

async function callDataLoader(
Expand Down Expand Up @@ -124,15 +120,13 @@ async function callDataLoader(
dataOverrides: { id: 'form_based' },
});
services.documentToExpression = jest.fn().mockResolvedValue({ ast: 'expression_string' });
const visualizationContextHelper = getVisualizationContextHelperMock();
const { cleanup } = loadEmbeddableData(
faker.string.uuid(),
getState,
api,
parentApi,
internalApi,
services,
visualizationContextHelper
);
// there's a debounce, so skip to the next tick
jest.advanceTimersByTime(100);
Expand All @@ -144,7 +138,6 @@ async function callDataLoader(
parentApi,
internalApi,
services,
visualizationContextHelper,
});
// fallback to true if undefined is returned
const expectRerender = result ?? true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function getDefaultProps({
// provide a valid expression to render
internalApi.updateExpressionParams(getValidExpressionParams());
return {
internalApi: getLensInternalApiMock(internalApiOverrides),
internalApi,
api: getLensApiMock(apiOverrides),
onUnmount: jest.fn(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
getLensApiMock,
getLensAttributesMock,
getLensInternalApiMock,
getVisualizationContextHelperMock,
makeEmbeddableServices,
} from '../mocks';
import { faker } from '@faker-js/faker';
Expand Down Expand Up @@ -50,10 +49,9 @@ function buildUserMessagesApi(metaInfo?: SharingSavedObjectProps) {
visOverrides: { id: 'lnsXY' },
dataOverrides: { id: 'form_based' },
});
const visualizationContextHelper = getVisualizationContextHelperMock();
// fill the context with some data
visualizationContextHelper.updateVisualizationContext({
doc: getLensAttributesMock({
internalApi.updateVisualizationContext({
activeAttributes: getLensAttributesMock({
state: {
datasourceStates: { form_based: { something: {} } },
visualization: { activeId: 'lnsXY', state: {} },
Expand All @@ -68,12 +66,11 @@ function buildUserMessagesApi(metaInfo?: SharingSavedObjectProps) {
const userMessagesApi = buildUserMessagesHelpers(
api,
internalApi,
visualizationContextHelper.getVisualizationContext,
services,
onBeforeBadgesRender,
metaInfo
);
return { api, internalApi, userMessagesApi, visualizationContextHelper, onBeforeBadgesRender };
return { api, internalApi, userMessagesApi, onBeforeBadgesRender };
}

describe('User Messages API', () => {
Expand Down Expand Up @@ -193,11 +190,11 @@ describe('User Messages API', () => {
});

it('should return basic validation for missing parts of the config', () => {
const { userMessagesApi, visualizationContextHelper } = buildUserMessagesApi();
const { userMessagesApi, internalApi } = buildUserMessagesApi();
// no doc scenario
visualizationContextHelper.updateVisualizationContext({
...visualizationContextHelper.getVisualizationContext(),
doc: undefined,
internalApi.updateVisualizationContext({
...internalApi.getVisualizationContext(),
activeAttributes: undefined,
});
for (const locationId of ALL_LOCATIONS) {
expect(userMessagesApi.getUserMessages(locationId).map(({ uniqueId }) => uniqueId)).toEqual(
Expand Down

0 comments on commit aece621

Please sign in to comment.