fix(plugin-multi-portal): handle empty type (#10212)

This commit is contained in:
Zeke Zhang
2026-07-30 11:31:24 +08:00
committed by GitHub
parent 9ad37dd065
commit a1ba3f439f
2 changed files with 19 additions and 5 deletions
@@ -89,12 +89,26 @@ describe('Multi Portal runtime registration failures', () => {
expect(layoutManager.registerLayout).not.toHaveBeenCalled();
});
it('registers only no-code portals and skips every other portal type', () => {
it('treats empty portal types as no-code portals', () => {
const layoutManager = createLayoutManager();
const emptyTypePortals = [
{ ...portal, uid: 'missing-type-portal', portalName: 'missingType', portalType: undefined },
{ ...portal, uid: 'null-type-portal', portalName: 'nullType', portalType: null },
{ ...portal, uid: 'empty-type-portal', portalName: 'emptyType', portalType: '' },
];
expect(registerMultiPortalRecords(layoutManager, emptyTypePortals)).toEqual([
'missing-type-portal',
'null-type-portal',
'empty-type-portal',
]);
expect(layoutManager.registerLayout).toHaveBeenCalledTimes(3);
});
it('skips ai and unknown non-empty portal types', () => {
const layoutManager = createLayoutManager();
const skippedPortals = [
{ ...portal, uid: 'ai-portal', portalName: 'ai', portalType: 'ai' },
{ ...portal, uid: 'missing-type-portal', portalName: 'missingType', portalType: undefined },
{ ...portal, uid: 'empty-type-portal', portalName: 'emptyType', portalType: '' },
{ ...portal, uid: 'unknown-type-portal', portalName: 'unknownType', portalType: 'custom' },
];
@@ -16,7 +16,7 @@ export { getMultiPortalRouteScopeCacheKey };
export type MultiPortalRuntimeRecord = {
uid: string;
title?: string;
portalType?: string;
portalType?: string | null;
portalName: string;
routePath: string;
authCheck: boolean;
@@ -74,7 +74,7 @@ const layoutModeMobileRegisterOptions = {
} satisfies Pick<LayoutRegisterOptions, 'layoutModelClass' | 'rootPageModelClass' | 'childPageModelClass'>;
function isRuntimePortal(record: MultiPortalRuntimeRecord) {
return record.portalType === 'no-code';
return (record.portalType || 'no-code') === 'no-code';
}
export function toMultiPortalLayoutRegisterOptions(record: MultiPortalRuntimeRecord): LayoutRegisterOptions | null {