Merge branch 'refactor-menu-resolvers-7.6' into refactor-menu-resolvers-9.0

This commit is contained in:
Yana De Pauw
2025-02-13 16:12:05 +01:00
3 changed files with 16 additions and 10 deletions

View File

@@ -148,7 +148,7 @@ export abstract class AbstractMenuProvider implements MenuProvider {
abstract getSections(route?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Observable<PartialMenuSection[]>;
protected getAutomatedSectionId(indexOfSectionInProvider: number): string {
return `${this.menuProviderId}_${indexOfSectionInProvider};`;
return `${this.menuProviderId}_${indexOfSectionInProvider}`;
}
}

View File

@@ -70,7 +70,7 @@ describe('MenuProviderService', () => {
const persistentProvider1 = new TestMenuProvider(MenuID.PUBLIC, true, 'provider1', 0, undefined, undefined, false, [section]);
const persistentProvider2 = new TestMenuProvider(MenuID.PUBLIC, true, 'provider2', 1, undefined, 'provider1', false, [section]);
const persistentProvider2 = new TestMenuProvider(MenuID.PUBLIC, true, 'provider2', 1, undefined, 'provider1', false, [section, section]);
const nonPersistentProvider3 = new TestMenuProvider(MenuID.PUBLIC, false, 'provider3', 2, undefined, undefined, false, [section]);
const nonPersistentProvider4 = new TestMenuProvider(MenuID.PUBLIC, false, 'provider4', 3, undefined, 'provider3', false, [section]);
const nonPersistentProvider5WithRoutes = new TestMenuProvider(MenuID.PUBLIC, false, 'provider4', 3, [MenuRoute.SIMPLE_COMMUNITY_PAGE, MenuRoute.SIMPLE_COLLECTION_PAGE], undefined, false, [section]);
@@ -78,17 +78,19 @@ describe('MenuProviderService', () => {
const listOfProvider = [persistentProvider1, persistentProvider2, nonPersistentProvider3, nonPersistentProvider4, nonPersistentProvider5WithRoutes];
const expectedSection1 = generateAddedSection(persistentProvider1, section);
const expectedSection2 = generateAddedSection(persistentProvider2, section);
const expectedSection21 = generateAddedSection(persistentProvider2, section);
const expectedSection22 = generateAddedSection(persistentProvider2, section, 1);
const expectedSection3 = generateAddedSection(nonPersistentProvider3, section);
const expectedSection4 = generateAddedSection(nonPersistentProvider4, section);
const expectedSection5 = generateAddedSection(nonPersistentProvider5WithRoutes, section);
function generateAddedSection(provider, sectionToAdd) {
function generateAddedSection(provider, sectionToAdd, index = 0) {
return {
...sectionToAdd,
id: sectionToAdd.id ?? `${provider.menuProviderId}`,
id: sectionToAdd.id ?? `${provider.menuProviderId}_${index}`,
parentID: sectionToAdd.parentID ?? provider.parentID,
index: sectionToAdd.index ?? provider.index,
active: false,
shouldPersistOnRouteChange: sectionToAdd.shouldPersistOnRouteChange ?? provider.shouldPersistOnRouteChange,
alwaysRenderExpandable: sectionToAdd.alwaysRenderExpandable ?? provider.alwaysRenderExpandable,
};
@@ -115,7 +117,8 @@ describe('MenuProviderService', () => {
menuProviderService.initPersistentMenus();
expect(menuService.addSection).toHaveBeenCalledWith(persistentProvider1.menuID, expectedSection1);
expect(menuService.addSection).toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection2);
expect(menuService.addSection).toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection21);
expect(menuService.addSection).toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection22);
expect(menuService.addSection).not.toHaveBeenCalledWith(nonPersistentProvider3.menuID, expectedSection3);
expect(menuService.addSection).not.toHaveBeenCalledWith(nonPersistentProvider4.menuID, expectedSection4);
expect(menuService.addSection).not.toHaveBeenCalledWith(nonPersistentProvider5WithRoutes.menuID, expectedSection5);
@@ -133,7 +136,8 @@ describe('MenuProviderService', () => {
expect(menuService.removeSection).toHaveBeenCalledWith(MenuID.DSO_EDIT, sectionToBeRemoved.id);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider1.menuID, expectedSection1);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection2);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection21);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection22);
expect(menuService.addSection).toHaveBeenCalledWith(nonPersistentProvider3.menuID, expectedSection3);
expect(menuService.addSection).toHaveBeenCalledWith(nonPersistentProvider4.menuID, expectedSection4);
expect(menuService.addSection).not.toHaveBeenCalledWith(nonPersistentProvider5WithRoutes.menuID, expectedSection5);
@@ -151,7 +155,8 @@ describe('MenuProviderService', () => {
expect(menuService.removeSection).toHaveBeenCalledWith(MenuID.DSO_EDIT, sectionToBeRemoved.id);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider1.menuID, expectedSection1);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection2);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection21);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection22);
expect(menuService.addSection).toHaveBeenCalledWith(nonPersistentProvider3.menuID, expectedSection3);
expect(menuService.addSection).toHaveBeenCalledWith(nonPersistentProvider4.menuID, expectedSection4);
expect(menuService.addSection).toHaveBeenCalledWith(nonPersistentProvider5WithRoutes.menuID, expectedSection5);
@@ -167,7 +172,8 @@ describe('MenuProviderService', () => {
expect(menuService.removeSection).toHaveBeenCalledWith(MenuID.DSO_EDIT, sectionToBeRemoved.id);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider1.menuID, expectedSection1);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection2);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection21);
expect(menuService.addSection).not.toHaveBeenCalledWith(persistentProvider2.menuID, expectedSection22);
expect(menuService.addSection).toHaveBeenCalledWith(nonPersistentProvider3.menuID, expectedSection3);
expect(menuService.addSection).toHaveBeenCalledWith(nonPersistentProvider4.menuID, expectedSection4);
expect(menuService.addSection).not.toHaveBeenCalledWith(nonPersistentProvider5WithRoutes.menuID, expectedSection5);

View File

@@ -70,7 +70,7 @@ export abstract class AbstractExpandableMenuProvider extends AbstractMenuProvide
return this.getAutomatedSectionId(0);
}
protected getAutomatedSectionIdForSubsection(indexOfSubSectionInProvider: number): string {
return `${this.menuProviderId}_0_${indexOfSubSectionInProvider};`;
return `${this.menuProviderId}_0_${indexOfSubSectionInProvider}`;
}
}