Use real appBasePath in legacy AppService shim (#51353)

This commit is contained in:
Josh Dover 2019-11-25 16:31:42 -06:00 committed by GitHub
parent aeb082e7c2
commit 1da0dc8aec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -18,13 +18,15 @@
*/
import { setRootControllerMock } from './new_platform.test.mocks';
import { legacyAppRegister, __reset__ } from './new_platform';
import { legacyAppRegister, __reset__, __setup__ } from './new_platform';
import { coreMock } from '../../../../core/public/mocks';
describe('ui/new_platform', () => {
describe('legacyAppRegister', () => {
beforeEach(() => {
setRootControllerMock.mockReset();
__reset__();
__setup__(coreMock.createSetup({ basePath: '/test/base/path' }) as any, {} as any);
});
const registerApp = () => {
@ -59,7 +61,7 @@ describe('ui/new_platform', () => {
controller(scopeMock, elementMock);
expect(mountMock).toHaveBeenCalledWith(expect.any(Object), {
element: elementMock[0],
appBasePath: '',
appBasePath: '/test/base/path/app/test',
});
});

View file

@ -111,7 +111,10 @@ export const legacyAppRegister = (app: App) => {
// Root controller cannot return a Promise so use an internal async function and call it immediately
(async () => {
const unmount = await app.mount({ core: npStart.core }, { element, appBasePath: '' });
const unmount = await app.mount(
{ core: npStart.core },
{ element, appBasePath: npSetup.core.http.basePath.prepend(`/app/${app.id}`) }
);
$scope.$on('$destroy', () => {
unmount();
});