Skip to content

Commit 914c5b4

Browse files
committed
add legacy-compat unit test
1 parent 66d813c commit 914c5b4

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/core/server/saved_objects/saved_objects_service.test.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,58 @@ describe('SavedObjectsService', () => {
164164
},
165165
]);
166166
});
167+
168+
it('merges legacy mappings and mappings registered using the service', async () => {
169+
const coreContext = mockCoreContext.create();
170+
const soService = new SavedObjectsService(coreContext);
171+
const setupDeps = createSetupDeps();
172+
173+
setupDeps.legacyPlugins.uiExports.savedObjectMappings = [
174+
{
175+
pluginId: 'legacyPlugin',
176+
properties: {
177+
legacyType: {
178+
properties: {
179+
field: { type: 'text' },
180+
},
181+
},
182+
},
183+
},
184+
];
185+
186+
const setup = await soService.setup(setupDeps);
187+
188+
setup.registerMappings('pluginA', {
189+
typeA: {
190+
properties: {
191+
field: { type: 'text' },
192+
},
193+
},
194+
});
195+
196+
await soService.start({});
197+
198+
expect(KibanaMigratorMock.mock.calls[0][0].savedObjectMappings).toEqual([
199+
{
200+
pluginId: 'legacyPlugin',
201+
type: 'legacyType',
202+
definition: {
203+
properties: {
204+
field: { type: 'text' },
205+
},
206+
},
207+
},
208+
{
209+
pluginId: 'pluginA',
210+
type: 'typeA',
211+
definition: {
212+
properties: {
213+
field: { type: 'text' },
214+
},
215+
},
216+
},
217+
]);
218+
});
167219
});
168220
});
169221

0 commit comments

Comments
 (0)