Trying to add a test to show that a late registered extension works - but test says otherwise compared to using it in entrypoint
This commit is contained in:
committed by
Niels Lyngsø
parent
c6e10515e8
commit
4107117efb
@@ -483,7 +483,7 @@ describe('Append Conditions', () => {
|
||||
type: 'section',
|
||||
name: 'test-section-2',
|
||||
alias: 'Umb.Test.Section.2',
|
||||
weight: 200
|
||||
weight: 200,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -661,4 +661,48 @@ describe('Prepend Conditions', () => {
|
||||
expect(extUpdated.conditions?.[1]?.alias).to.equal('Umb.Test.Condition.Invalid');
|
||||
expect(extUpdated.conditions?.[2]?.alias).to.equal('Umb.Test.Condition.Valid');
|
||||
});
|
||||
|
||||
it('allows conditions to be prepended when an extension is loaded later on', async () => {
|
||||
const conditions: Array<UmbConditionConfigBase> = [
|
||||
{
|
||||
alias: 'Umb.Test.Condition.Invalid',
|
||||
},
|
||||
{
|
||||
alias: 'Umb.Condition.WorkspaceAlias',
|
||||
match: 'Umb.Workspace.Document',
|
||||
} as WorkspaceAliasConditionConfig,
|
||||
];
|
||||
|
||||
console.log('About to go KABOOM..');
|
||||
|
||||
// Prepend the conditions
|
||||
// [WB] HELP: Why is this fine when using in in an entrypoint
|
||||
// /src/packages/property-editors/entry-point.ts
|
||||
// But this TEST implodes if it can't find the extension that is not yet registered
|
||||
await extensionRegistry.prependConditions('Late.Extension.To.Be.Loaded', conditions);
|
||||
|
||||
// Make sure the extension is not registered YET
|
||||
expect(extensionRegistry.isRegistered('Late.Extension.To.Be.Loaded')).to.be.false;
|
||||
|
||||
// Register the extension LATE/after the conditions have been added
|
||||
extensionRegistry.register({
|
||||
type: 'section',
|
||||
name: 'Late Section Extension with one condition',
|
||||
alias: 'Late.Extension.To.Be.Loaded',
|
||||
weight: 200,
|
||||
conditions: [
|
||||
{
|
||||
alias: 'Umb.Test.Condition.Valid',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(extensionRegistry.isRegistered('Late.Extension.To.Be.Loaded')).to.be.true;
|
||||
|
||||
const extUpdated = extensionRegistry.getByAlias('Late.Extension.To.Be.Loaded') as ManifestWithDynamicConditions;
|
||||
expect(extUpdated.conditions?.length).to.equal(3);
|
||||
expect(extUpdated.conditions?.[0]?.alias).to.equal('Umb.Condition.WorkspaceAlias');
|
||||
expect(extUpdated.conditions?.[1]?.alias).to.equal('Umb.Test.Condition.Invalid');
|
||||
expect(extUpdated.conditions?.[2]?.alias).to.equal('Umb.Test.Condition.Valid');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { ManifestWithDynamicConditions, UmbConditionConfigBase, UmbEntryPointOnInit } from '@umbraco-cms/backoffice/extension-api';
|
||||
import type {
|
||||
ManifestWithDynamicConditions,
|
||||
UmbConditionConfigBase,
|
||||
UmbEntryPointOnInit,
|
||||
} from '@umbraco-cms/backoffice/extension-api';
|
||||
import type { WorkspaceAliasConditionConfig } from '@umbraco-cms/backoffice/workspace';
|
||||
|
||||
import './checkbox-list/components/index.js';
|
||||
@@ -13,9 +17,16 @@ export const onInit: UmbEntryPointOnInit = (_host, _extensionRegistry) => {
|
||||
match: 'Umb.Workspace.WARRENYO',
|
||||
} as WorkspaceAliasConditionConfig;
|
||||
|
||||
console.log(
|
||||
'Should not be false and not registered',
|
||||
_extensionRegistry.isRegistered('Umb.Dashboard.UmbracoNewsLATE'),
|
||||
);
|
||||
|
||||
_extensionRegistry.appendCondition('Umb.Dashboard.UmbracoNewsLATE', condition);
|
||||
|
||||
const ext:ManifestWithDynamicConditions = {
|
||||
console.log('I HAZ APPENED CONDITIONS');
|
||||
|
||||
const ext: ManifestWithDynamicConditions = {
|
||||
alias: 'Umb.Dashboard.UmbracoNewsLATE',
|
||||
type: 'dashboard',
|
||||
name: 'WARREN Package',
|
||||
@@ -30,4 +41,9 @@ export const onInit: UmbEntryPointOnInit = (_host, _extensionRegistry) => {
|
||||
|
||||
_extensionRegistry.register(ext);
|
||||
|
||||
const amIRegistered = _extensionRegistry.isRegistered('Umb.Dashboard.UmbracoNewsLATE');
|
||||
console.log('Should be true and registered', amIRegistered);
|
||||
|
||||
const getTheThing = _extensionRegistry.getByAlias('Umb.Dashboard.UmbracoNewsLATE');
|
||||
console.log('Should be the extension', getTheThing);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user