-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workbench-client/popup): add 'referrer' to popup handle to provi…
…de information about the calling context The popup handle, which can be obtained in a popup microfrontend, can be used to retrieve information about the calling context. ```ts const referrer: WorkbenchPopupReferrer = Beans.get(WorkbenchPopup).referrer; console.log('view', referrer.viewId); // reference to the view from which the popup was opened console.log('view', referrer.viewCapabilityId); // reference to the view capability from which the popup was opened ```
- Loading branch information
1 parent
edf6f53
commit 920d831
Showing
19 changed files
with
502 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
projects/scion/e2e-testing/src/workbench-client/host-popup-referrer.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright (c) 2018-2022 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
import {expect} from '@playwright/test'; | ||
import {test} from '../fixtures'; | ||
import {PopupOpenerPagePO} from './page-object/popup-opener-page.po'; | ||
import {ViewPagePO} from './page-object/view-page.po'; | ||
import {RegisterWorkbenchIntentionPagePO} from './page-object/register-workbench-intention-page.po'; | ||
import {HostPopupPagePO} from './page-object/host-popup-page.po'; | ||
|
||
test.describe('Workbench Popup', () => { | ||
|
||
test.describe('Popup Referrer', () => { | ||
|
||
test('should have a view reference to the contextual view', async ({appPO, microfrontendNavigator}) => { | ||
await appPO.navigateTo({microfrontendSupport: true}); | ||
|
||
// TODO [#271]: Register popup capability in the host app via RegisterWorkbenchCapabilityPagePO when implemented the issue #271 | ||
// https://github.com/SchweizerischeBundesbahnen/scion-workbench/issues/271 | ||
|
||
// register intention | ||
const registerIntentionPagePO = await microfrontendNavigator.openInNewTab(RegisterWorkbenchIntentionPagePO, 'app1'); | ||
await registerIntentionPagePO.registerIntention({type: 'popup', qualifier: {component: 'host-popup'}}); | ||
|
||
const popupOpenerPagePO = await microfrontendNavigator.openInNewTab(PopupOpenerPagePO, 'app1'); | ||
await popupOpenerPagePO.enterQualifier({component: 'host-popup'}); | ||
await popupOpenerPagePO.clickOpen(); | ||
|
||
const popupPagePO = new HostPopupPagePO(appPO, 'host-popup'); | ||
await expect(await popupPagePO.getReferrer()).toEqual({ | ||
viewId: popupOpenerPagePO.viewId, | ||
viewCapabilityId: await popupOpenerPagePO.outlet.getCapabilityId(), | ||
}); | ||
}); | ||
|
||
test('should have a view reference to the specified contextual view', async ({appPO, microfrontendNavigator}) => { | ||
await appPO.navigateTo({microfrontendSupport: true}); | ||
|
||
// TODO [#271]: Register popup capability in the host app via RegisterWorkbenchCapabilityPagePO when implemented the issue #271 | ||
// https://github.com/SchweizerischeBundesbahnen/scion-workbench/issues/271 | ||
|
||
// register intention | ||
const registerIntentionPagePO = await microfrontendNavigator.openInNewTab(RegisterWorkbenchIntentionPagePO, 'app1'); | ||
await registerIntentionPagePO.registerIntention({type: 'popup', qualifier: {component: 'host-popup'}}); | ||
|
||
const startPagePO = await appPO.openNewViewTab(); | ||
const startPageViewId = startPagePO.viewId!; | ||
|
||
const popupOpenerPagePO = await microfrontendNavigator.openInNewTab(PopupOpenerPagePO, 'app1'); | ||
await popupOpenerPagePO.enterQualifier({component: 'host-popup'}); | ||
await popupOpenerPagePO.enterContextualViewId(startPageViewId); | ||
await popupOpenerPagePO.enterCloseStrategy({closeOnFocusLost: false}); | ||
await popupOpenerPagePO.clickOpen({waitForPopup: false}); | ||
|
||
await startPagePO.view!.viewTab.click(); | ||
|
||
const popupPagePO = new HostPopupPagePO(appPO, 'host-popup'); | ||
await expect(await popupPagePO.getReferrer()).toEqual({ | ||
viewId: startPageViewId, | ||
}); | ||
}); | ||
|
||
test('should have a view reference to the specified contextual view and capability', async ({appPO, microfrontendNavigator}) => { | ||
await appPO.navigateTo({microfrontendSupport: true}); | ||
|
||
// TODO [#271]: Register popup capability in the host app via RegisterWorkbenchCapabilityPagePO when implemented the issue #271 | ||
// https://github.com/SchweizerischeBundesbahnen/scion-workbench/issues/271 | ||
|
||
// register intention | ||
const registerIntentionPagePO = await microfrontendNavigator.openInNewTab(RegisterWorkbenchIntentionPagePO, 'app1'); | ||
await registerIntentionPagePO.registerIntention({type: 'popup', qualifier: {component: 'host-popup'}}); | ||
|
||
const microfrontendPO = await microfrontendNavigator.openInNewTab(ViewPagePO, 'app1'); | ||
const microfrontendViewId = microfrontendPO.viewId!; | ||
|
||
const popupOpenerPagePO = await microfrontendNavigator.openInNewTab(PopupOpenerPagePO, 'app1'); | ||
await popupOpenerPagePO.enterQualifier({component: 'host-popup'}); | ||
await popupOpenerPagePO.enterContextualViewId(microfrontendViewId); | ||
await popupOpenerPagePO.enterCloseStrategy({closeOnFocusLost: false}); | ||
await popupOpenerPagePO.clickOpen({waitForPopup: false}); | ||
|
||
await microfrontendPO.view!.viewTab.click(); | ||
|
||
const popupPagePO = new HostPopupPagePO(appPO, 'host-popup'); | ||
await expect(await popupPagePO.getReferrer()).toEqual({ | ||
viewId: microfrontendViewId, | ||
viewCapabilityId: await microfrontendPO.outlet.getCapabilityId(), | ||
}); | ||
}); | ||
|
||
test('should not have a view reference if opened outside of a contextual view', async ({appPO, microfrontendNavigator}) => { | ||
await appPO.navigateTo({microfrontendSupport: true}); | ||
|
||
// TODO [#271]: Register popup capability in the host app via RegisterWorkbenchCapabilityPagePO when implemented the issue #271 | ||
// https://github.com/SchweizerischeBundesbahnen/scion-workbench/issues/271 | ||
|
||
// register intention | ||
const registerIntentionPagePO = await microfrontendNavigator.openInNewTab(RegisterWorkbenchIntentionPagePO, 'app1'); | ||
await registerIntentionPagePO.registerIntention({type: 'popup', qualifier: {component: 'host-popup'}}); | ||
|
||
const popupOpenerPagePO = await microfrontendNavigator.openInNewTab(PopupOpenerPagePO, 'app1'); | ||
await popupOpenerPagePO.enterQualifier({component: 'host-popup'}); | ||
await popupOpenerPagePO.enterContextualViewId('<null>'); | ||
await popupOpenerPagePO.clickOpen(); | ||
|
||
const popupPagePO = new HostPopupPagePO(appPO, 'host-popup'); | ||
await expect(await popupPagePO.getReferrer()).toEqual({}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.