Skip to content

Commit

Permalink
fix(workbench-client/router): set title/heading as passed to navigation
Browse files Browse the repository at this point in the history
A navigator can set the view title/heading by passing the `wb.title`/`wb.heading` parameter (exposed as constants `WB_VIEW_TITLE_PARAM`/`WB_VIEW_HEADING_PARAM`). Note that this API is deprecated and will be removed in version 16 of SCION Workbench.
  • Loading branch information
danielwiehl authored and Marcarrian committed Oct 13, 2022
1 parent 6f05791 commit f182859
Showing 2 changed files with 64 additions and 5 deletions.
64 changes: 61 additions & 3 deletions projects/scion/e2e-testing/src/workbench-client/router.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1074,10 +1074,68 @@ test.describe('Workbench Router', () => {
const activeViewPO = await appPO.activePart.activeView;

await routerPagePO.enterQualifier({component: 'view', app: 'app1'});
await routerPagePO.enterCssClass('e2e-test-view');
await routerPagePO.enterCssClass('testee');
await routerPagePO.clickNavigate({evalNavigateResponse: false});

await expect(await activeViewPO.getCssClasses()).toEqual(expect.arrayContaining(['e2e-test-view']));
await expect(await activeViewPO.viewTab.getCssClasses()).toEqual(expect.arrayContaining(['e2e-test-view']));
await expect(await activeViewPO.getCssClasses()).toEqual(expect.arrayContaining(['testee']));
await expect(await activeViewPO.viewTab.getCssClasses()).toEqual(expect.arrayContaining(['testee']));
});

test('should allow setting view title via "wb.title" param (DEPRECATED: API will be removed in v16)', async ({appPO, microfrontendNavigator}) => {
await appPO.navigateTo({microfrontendSupport: true});

// register testee microfrontend
const registerCapabilityPagePO = await microfrontendNavigator.openInNewTab(RegisterWorkbenchCapabilityPagePO, 'app1');
await registerCapabilityPagePO.registerCapability({
type: 'view',
qualifier: {component: 'testee'},
params: [
{name: 'wb.title', required: false},
],
properties: {
path: 'microfrontend',
title: 'Capability Title',
cssClass: 'testee',
},
});

const routerPagePO = await microfrontendNavigator.openInNewTab(RouterPagePO, 'app1');
await routerPagePO.enterQualifier({component: 'testee'});
await routerPagePO.enterParams({'wb.title': 'Param Title'}); // deprecated API
await routerPagePO.enterCssClass('testee');
await routerPagePO.selectTarget('blank');
await routerPagePO.clickNavigate();

const testeeViewTab = appPO.view({cssClass: 'testee'}).viewTab;
await expect(await testeeViewTab.getTitle()).toEqual('Param Title');
});

test('should allow setting view heading via "wb.heading" param (DEPRECATED: API will be removed in v16)', async ({appPO, microfrontendNavigator}) => {
await appPO.navigateTo({microfrontendSupport: true});

// register testee microfrontend
const registerCapabilityPagePO = await microfrontendNavigator.openInNewTab(RegisterWorkbenchCapabilityPagePO, 'app1');
await registerCapabilityPagePO.registerCapability({
type: 'view',
qualifier: {component: 'testee'},
params: [
{name: 'wb.heading', required: false},
],
properties: {
path: 'microfrontend',
heading: 'Capability Heading',
cssClass: 'testee',
},
});

const routerPagePO = await microfrontendNavigator.openInNewTab(RouterPagePO, 'app1');
await routerPagePO.enterQualifier({component: 'testee'});
await routerPagePO.enterParams({'wb.heading': 'Param Heading'}); // deprecated API
await routerPagePO.enterCssClass('testee');
await routerPagePO.selectTarget('blank');
await routerPagePO.clickNavigate();

const testeeViewTab = appPO.view({cssClass: 'testee'}).viewTab;
await expect(await testeeViewTab.getHeading()).toEqual('Param Heading');
});
});
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ import {WorkbenchRouteData} from '../../routing/workbench-route-data';
import {WorkbenchNavigationalStates} from '../../routing/workbench-navigational-states';
import {MicrofrontendNavigationalStates} from '../routing/microfrontend-navigational-states';
import {Beans} from '@scion/toolkit/bean-manager';
import {WB_VIEW_HEADING_PARAM, WB_VIEW_TITLE_PARAM} from '../../routing/routing.constants';

/**
* Embeds the microfrontend of a view capability.
@@ -203,8 +204,8 @@ export class MicrofrontendViewComponent implements OnInit, OnDestroy, WbBeforeDe
* Updates the properties of this view, such as the view title, as defined by the capability.
*/
private setViewProperties(viewCapability: WorkbenchViewCapability, activatedRoute: ActivatedRouteSnapshot): void {
this._view.title = viewCapability.properties.title ?? null;
this._view.heading = viewCapability.properties.heading ?? null;
this._view.title = activatedRoute.params[WB_VIEW_TITLE_PARAM] ?? viewCapability.properties.title ?? null;
this._view.heading = activatedRoute.params[WB_VIEW_HEADING_PARAM] ?? viewCapability.properties.heading ?? null;
this._view.cssClass = new Array<string>()
.concat(Arrays.coerce(viewCapability.properties.cssClass))
.concat(Arrays.coerce(activatedRoute.data[WorkbenchRouteData.state]?.[WorkbenchNavigationalStates.cssClass]));

0 comments on commit f182859

Please sign in to comment.