Skip to content

Commit 43d0169

Browse files
committed
fix unit test failures
Signed-off-by: abbyhu2000 <[email protected]>
1 parent 0e18a6e commit 43d0169

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

src/core/public/chrome/recently_accessed/recently_accessed_service.ts

+17-9
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,23 @@ export class RecentlyAccessedService {
6464
id: string,
6565
extraProps?: { type?: string; updatedAt?: number }
6666
) => {
67-
const type = extraProps!.type;
68-
const updatedAt = extraProps!.updatedAt;
69-
history.add({
70-
link,
71-
label,
72-
id,
73-
type,
74-
updatedAt,
75-
});
67+
if (extraProps) {
68+
const type = extraProps!.type;
69+
const updatedAt = extraProps!.updatedAt;
70+
history.add({
71+
link,
72+
label,
73+
id,
74+
type,
75+
updatedAt,
76+
});
77+
} else {
78+
history.add({
79+
link,
80+
label,
81+
id,
82+
});
83+
}
7684
},
7785

7886
/** Gets the current array of history items. */

src/plugins/dashboard/public/application/utils/use/use_saved_dashboard_instance.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('useSavedDashboardInstance', () => {
3838
getFilters: () => dashboardAppStateStub.filters,
3939
optionsJSON: JSON.stringify(dashboardAppStateStub.options),
4040
getFullPath: () => `/${dashboardIdFromUrl}`,
41+
getOpenSearchType: () => 'dashboard',
4142
},
4243
} as unknown) as SavedObjectDashboard;
4344
dashboard = new Dashboard(convertToSerializedDashboard(savedDashboardInstance));

src/plugins/home/public/mocks.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@
66
import { applicationServiceMock, chromeServiceMock, coreMock } from '../../../core/public/mocks';
77
import { HomeOpenSearchDashboardsServices } from './application/opensearch_dashboards_services';
88
import { injectedMetadataServiceMock } from '../../../core/public/mocks';
9+
import { featureCatalogueRegistryMock } from './services/feature_catalogue/feature_catalogue_registry.mock';
10+
import { environmentServiceMock } from './services/environment/environment.mock';
11+
import { configSchema } from '../config';
12+
import { tutorialServiceMock } from './services/tutorials/tutorial_service.mock';
13+
import { sectionTypeServiceMock } from './services/section_type/section_type.mock';
914

10-
export const createHomeServicesMock = () => {
15+
const createSetupContract = () => ({
16+
featureCatalogue: featureCatalogueRegistryMock.createSetup(),
17+
environment: environmentServiceMock.createSetup(),
18+
tutorials: tutorialServiceMock.createSetup(),
19+
sectionTypes: sectionTypeServiceMock.createSetup(),
20+
});
21+
22+
export const createStartContract = () => {
1123
const coreStartMock = coreMock.createStart();
1224
const chromeMock = chromeServiceMock.createStartContract();
1325
const applicationMock = applicationServiceMock.createStartContract();
@@ -36,3 +48,8 @@ export const createHomeServicesMock = () => {
3648
},
3749
} as unknown) as jest.Mocked<HomeOpenSearchDashboardsServices>;
3850
};
51+
52+
export const homePluginMock = {
53+
createSetupContract,
54+
createStartContract,
55+
};

src/plugins/visualize/public/application/utils/use/use_saved_vis_instance.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ const mockSavedVisInstance = {
5252
id: savedVisId,
5353
title: 'Test Vis',
5454
destroy: mockSavedVisDestroy,
55+
getOpenSearchType: () => 'visualization',
56+
getFullPath: () => '/',
5557
},
5658
vis: {
5759
type: {},

0 commit comments

Comments
 (0)