Skip to content

Commit

Permalink
fix: allow interaction with the platform once navigated away from an …
Browse files Browse the repository at this point in the history
…application's root page

fixes #141
  • Loading branch information
ue06919 authored and danielwiehl committed May 8, 2019
1 parent 6bffc7d commit 80ddeab
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ACTIVITY_ACTION_PROVIDER, INTENT_HANDLER, MessageBoxIntentHandler, Noti
import { ListNotificationComponent } from './list-notification/list-notification.component';
import { CustomNotifyActivityActionComponent } from './custom-notify-activity-action/custom-notify-activity-action.component';
import { CustomNotifyActivityActionProvider } from './custom-notify-activity-action/custom-notify-activity-action-provider.service';
import { CustomIntentHandlerService } from './custom-intent/custom-intent-handler.service';
import { PingIntentHandler } from './ping-intent/ping-intent-handler.service';

@NgModule({
declarations: [
Expand Down Expand Up @@ -49,7 +49,7 @@ import { CustomIntentHandlerService } from './custom-intent/custom-intent-handle
},
{
provide: INTENT_HANDLER,
useClass: CustomIntentHandlerService,
useClass: PingIntentHandler,
multi: true
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { IntentHandler, MessageBus } from '@scion/workbench-application-platform
import { NilQualifier, IntentMessage, MessageEnvelope } from '@scion/workbench-application-platform.api';

@Injectable()
export class CustomIntentHandlerService implements IntentHandler {
export class PingIntentHandler implements IntentHandler {

public readonly type = 'custom';
public readonly type = 'ping';
public readonly qualifier = NilQualifier;

public readonly description = 'Handles intents of type custom';
public readonly description = 'Replies to ping requests.';

constructor(private _messageBus: MessageBus) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ViewC985a55bComponent } from './testing/view-c985a55b/view-c985a55b.component';

const routes: Routes = [
{path: '', component: ViewC985a55bComponent},
{path: 'testing', loadChildren: './testing/testing.module#TestingModule'},
];

@NgModule({
imports: [RouterModule.forRoot(routes, {useHash: true})],
exports: [RouterModule]
exports: [RouterModule],
})
export class AppRoutingModule {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import { AppComponent } from './app.component';
import { WorkbenchApplicationModule } from '@scion/workbench-application.angular';
import { SciViewportModule } from '@scion/viewport';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { SciParamsEnterModule } from '@scion/app/common';
import { AppRoutingModule } from './app-routing.module';


@NgModule({
declarations: [
AppComponent,
Expand All @@ -27,6 +29,7 @@ import { AppRoutingModule } from './app-routing.module';
SciViewportModule,
AppRoutingModule,
BrowserAnimationsModule,
SciParamsEnterModule
],
providers: [],
bootstrap: [
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<input class="e2e-ping-message" #input placeholder="Enter ping message."/>

<button (click)="onPing(input.value)" class="e2e-ping">Ping</button>

<section *ngIf="result$ | async as result">
Result: <output class="e2e-result">{{result}}</output>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018 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 { Component } from '@angular/core';
import { NilQualifier } from '@scion/workbench-application-platform.api';
import { first } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { IntentService } from '@scion/workbench-application.core';

@Component({
selector: 'app-ping-intent-panel',
templateUrl: './ping-intent-panel.component.html',
styleUrls: ['./ping-intent-panel.component.scss'],
})
export class PingIntentPanelComponent {

public result$: Observable<string>;

constructor(private _intentService: IntentService) {
}

public onPing(message: string): void {
this.result$ = this._intentService.issueIntent$<string>('ping', NilQualifier, message)
.pipe(first());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ <h2>URL Query Parameters</h2>
</ng-template>

<!-- Custom Intents -->
<ng-template sciAccordionItem [panel]="custom_intent_panel" [cssClass]="'e2e-custom-intent-panel'">
<header>Custom Intents</header>
<ng-template sciAccordionItem [panel]="ping_intent_panel" [cssClass]="'e2e-ping-intent-panel'">
<header>Issue ping intent</header>
</ng-template>

<ng-template #custom_intent_panel>
<app-custom-intent-panel></app-custom-intent-panel>
<ng-template #ping_intent_panel>
<app-ping-intent-panel></app-ping-intent-panel>
</ng-template>

<!-- Notification -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ import { Activity5782ab19Component } from './activity-5782ab19/activity-5782ab19
import { ViewOpenActivityActionPanelComponent } from './view-open-activity-action-panel/view-open-activity-action-panel.component';
import { PopupOpenActivityActionPanelComponent } from './popup-open-activity-action-panel/popup-open-activity-action-panel.component';
import { ViewC91805e8Component } from './view-c91805e8/view-c91805e8.component';
import { CustomIntentPanelComponent } from './custom-intent/custom-intent-panel.component';
import { PingIntentPanelComponent } from './ping-intent/ping-intent-panel.component';
import { ViewCba33eafComponent } from './view-cba33eaf/view-cba33eaf.component';
import { ViewC985a55bComponent } from './view-c985a55b/view-c985a55b.component';

@NgModule({
declarations: [
TestingViewComponent,
ViewNavigationPanelComponent,
ViewInterationPanelComponent,
MessageBoxPanelComponent,
CustomIntentPanelComponent,
PingIntentPanelComponent,
NotificationPanelComponent,
PopupPanelComponent,
TestingPopupComponent,
Expand Down Expand Up @@ -96,6 +97,7 @@ import { ViewCba33eafComponent } from './view-cba33eaf/view-cba33eaf.component';
ViewBe587bd6Component,
ViewC91805e8Component,
ViewCba33eafComponent,
ViewC985a55bComponent,
Popup1a90c8d2Component,
Popup7330f506Component,
Popup9c5319f7Component,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<app-view-navigation-panel></app-view-navigation-panel>
<app-ping-intent-panel></app-ping-intent-panel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2018 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 {Component} from '@angular/core';
import {provideWorkbenchView} from '@scion/workbench-application.angular';

@Component({
selector: 'app-view-c8e40918',
templateUrl: './view-c985a55b.component.html',
styles: [':host { padding: 1em }'],
providers: [
provideWorkbenchView(ViewC985a55bComponent)
]
})
export class ViewC985a55bComponent {
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@
"cssClass": "e2e-view-0c4fe9e3"
}
},
{
"type": "view",
"qualifier": {
"entity": "testing",
"testcase": "c985a55b-view"
},
"description": "Provides a view for testcase 'c985a55b'",
"properties": {
"path": "",
"title": "e2e-view-c985a55b",
"heading": "c985a55b",
"cssClass": "e2e-view-c985a55b",
"activityItem": {
"title": "c985a55b-activity",
"itemCssClass": [
"fab",
"fa-android"
],
"cssClass": "e2e-activity-c985a55b",
"position": 10000000042
}

}
},
{
"type": "view",
"qualifier": {
Expand Down Expand Up @@ -666,7 +690,7 @@
],
"intents": [
{
"type": "custom"
"type": "ping"
},
{
"type": "messagebox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ describe('CustomIntent', () => {

it('should return result when custom intent is dispatched', async () => {
await testingViewPO.navigateTo();
const panelPO = await testingViewPO.openCustomIntentPanel();
const panelPO = await testingViewPO.openPingIntentPanel();

await panelPO.issueIntent();
await expect(panelPO.getResult()).toEqual('custom-intent-payload');
await panelPO.enterPingMessage('Nobody calls me chicken!');
await panelPO.clickPingButton();
await expect(panelPO.getResult()).toEqual('Nobody calls me chicken!');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import { $ } from 'protractor';
import { switchToIFrameContext } from '../util/testing.util';

export class CustomIntentPanelPO {
export class PingIntentPanelPO {

private _panel = $('app-custom-intent-panel');
private _panel = $('app-ping-intent-panel');

constructor(public iframeContext: string[]) {
}
Expand All @@ -23,8 +23,14 @@ export class CustomIntentPanelPO {
return this._panel.$('output.e2e-result').getText();
}

public async issueIntent(): Promise<void> {
public async clickPingButton(): Promise<void> {
await switchToIFrameContext(this.iframeContext);
await this._panel.$('button.e2e-issue-intent').click();
await this._panel.$('button.e2e-ping').click();
}

public async enterPingMessage(message: string): Promise<void> {
await switchToIFrameContext(this.iframeContext);
await this._panel.$('input.e2e-ping-message').click();
await this._panel.$('input.e2e-ping-message').sendKeys(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2018 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 { ViewNavigationPanelPO } from './view-navigation-panel.po';
import { HostAppPO } from './host-app.po';
import { PingIntentPanelPO } from './ping-intent-panel-po';

const E2E_TESTING_VIEW_CONTEXT: string[] = ['e2e-testing-app', 'e2e-view', 'e2e-view-c985a55b'];

export class TestcaseC985a55bViewPO {

public async navigateTo(): Promise<void> {
await new HostAppPO().clickActivityItem('e2e-activity-c985a55b');
}

public getViewNavigationPanelPO(): ViewNavigationPanelPO {
return new ViewNavigationPanelPO(E2E_TESTING_VIEW_CONTEXT);
}

public getPingPanelPO(): PingIntentPanelPO {
return new PingIntentPanelPO(E2E_TESTING_VIEW_CONTEXT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { SciAccordionPO } from './sci-accordion-p.o';
import { switchToIFrameContext } from '../util/testing.util';
import { MessageBoxPanelPO } from './message-box-panel.po';
import { NotificationPanelPO } from './notification-panel.po';
import { CustomIntentPanelPO } from './custom-intent-panel.po';
import { PingIntentPanelPO } from './ping-intent-panel-po';

const E2E_TESTING_VIEW_CONTEXT: string[] = ['e2e-testing-app', 'e2e-view', 'e2e-testing-view'];

Expand Down Expand Up @@ -58,10 +58,10 @@ export class TestingViewPO {
return new MessageBoxPanelPO(E2E_TESTING_VIEW_CONTEXT);
}

public async openCustomIntentPanel(): Promise<CustomIntentPanelPO> {
public async openPingIntentPanel(): Promise<PingIntentPanelPO> {
await switchToIFrameContext(E2E_TESTING_VIEW_CONTEXT);
await new SciAccordionPO().toggle(this._component.$('sci-accordion'), 'e2e-custom-intent-panel', true);
return new CustomIntentPanelPO(E2E_TESTING_VIEW_CONTEXT);
await new SciAccordionPO().toggle(this._component.$('sci-accordion'), 'e2e-ping-intent-panel', true);
return new PingIntentPanelPO(E2E_TESTING_VIEW_CONTEXT);
}

public async openNotificationPanel(): Promise<NotificationPanelPO> {
Expand Down
Loading

0 comments on commit 80ddeab

Please sign in to comment.