-
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-testing-app): add menu to display information about a …
…view
- Loading branch information
1 parent
02bc372
commit 1f8cedf
Showing
10 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
apps/workbench-testing-app/src/app/view-info-dialog/view-info-dialog.component.html
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,47 @@ | ||
<section> | ||
<sci-form-field label="View ID"> | ||
<span class="e2e-view-id">{{view.id}}</span> | ||
</sci-form-field> | ||
|
||
<sci-form-field label="Part ID"> | ||
<span class="e2e-part-id">{{view.part.id}}</span> | ||
</sci-form-field> | ||
|
||
<sci-form-field label="View Title"> | ||
<span class="e2e-title">{{view.title}}</span> | ||
</sci-form-field> | ||
|
||
<sci-form-field label="View Heading"> | ||
<span class="e2e-heading">{{view.heading}}</span> | ||
</sci-form-field> | ||
|
||
<sci-form-field label="URL Segments"> | ||
<span class="e2e-url-segments">{{view.urlSegments | appJoin:'/'}}</span> | ||
</sci-form-field> | ||
</section> | ||
|
||
@if (route?.snapshot?.params | appNullIfEmpty; as params) { | ||
<section> | ||
<header>Route Params</header> | ||
<sci-key-value [object]="params" class="e2e-route-params"></sci-key-value> | ||
</section> | ||
} | ||
|
||
@if (route?.snapshot?.data | appNullIfEmpty; as data) { | ||
<section> | ||
<header>Route Data</header> | ||
<sci-key-value [object]="data" class="e2e-route-data"></sci-key-value> | ||
</section> | ||
} | ||
|
||
@if (view.state | appNullIfEmpty; as state) { | ||
<section> | ||
<header>View State</header> | ||
<sci-key-value [object]="state" class="e2e-state"></sci-key-value> | ||
</section> | ||
} | ||
|
||
<!-- Close button --> | ||
<ng-template wbDialogAction> | ||
<button (click)="onClose()">Close</button> | ||
</ng-template> |
16 changes: 16 additions & 0 deletions
16
apps/workbench-testing-app/src/app/view-info-dialog/view-info-dialog.component.scss
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,16 @@ | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.5em; | ||
|
||
> section { | ||
display: flex; | ||
flex-direction: column; | ||
gap: .5em; | ||
|
||
> header { | ||
font-weight: bold; | ||
margin-bottom: .25em; | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
apps/workbench-testing-app/src/app/view-info-dialog/view-info-dialog.component.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,59 @@ | ||
/* | ||
* Copyright (c) 2018-2024 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, Input, OnInit} from '@angular/core'; | ||
import {WorkbenchDialog, WorkbenchDialogActionDirective, WorkbenchView} from '@scion/workbench'; | ||
import {ActivatedRoute, Router} from '@angular/router'; | ||
import {SciFormFieldComponent} from '@scion/components.internal/form-field'; | ||
import {JoinPipe} from '../common/join.pipe'; | ||
import {SciKeyValueComponent} from '@scion/components.internal/key-value'; | ||
import {NullIfEmptyPipe} from '../common/null-if-empty.pipe'; | ||
|
||
@Component({ | ||
selector: 'app-view-info-dialog', | ||
templateUrl: './view-info-dialog.component.html', | ||
styleUrls: ['./view-info-dialog.component.scss'], | ||
standalone: true, | ||
imports: [ | ||
SciFormFieldComponent, | ||
JoinPipe, | ||
WorkbenchDialogActionDirective, | ||
SciKeyValueComponent, | ||
NullIfEmptyPipe, | ||
], | ||
}) | ||
export class ViewInfoDialogComponent implements OnInit { | ||
|
||
/** | ||
* Activated route, or `undefined` if not navigated yet. | ||
*/ | ||
protected route: ActivatedRoute | undefined; | ||
|
||
@Input({required: true}) | ||
public view!: WorkbenchView; | ||
|
||
constructor(private _router: Router, private _dialog: WorkbenchDialog) { | ||
this._dialog.title = 'View Info'; | ||
this._dialog.size.minWidth = '32em'; | ||
} | ||
|
||
public ngOnInit(): void { | ||
const route = this._router.routerState.root.children.find(route => route.outlet === this.view.id); | ||
this.route = route && resolveActualRoute(route); | ||
} | ||
|
||
public onClose(): void { | ||
this._dialog.close(); | ||
} | ||
} | ||
|
||
function resolveActualRoute(route: ActivatedRoute): ActivatedRoute { | ||
return route.firstChild ? resolveActualRoute(route.firstChild) : route; | ||
} |
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
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
56 changes: 56 additions & 0 deletions
56
projects/scion/e2e-testing/src/workbench/page-object/view-info-dialog.po.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,56 @@ | ||
/* | ||
* Copyright (c) 2018-2024 Swiss Federal Railways | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms from 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 {Locator} from '@playwright/test'; | ||
import {SciKeyValuePO} from '../../@scion/components.internal/key-value.po'; | ||
import {DialogPO} from '../../dialog.po'; | ||
import {WorkbenchDialogPagePO} from './workbench-dialog-page.po'; | ||
import {ViewState} from '@scion/workbench'; | ||
import {Data, Params} from '@angular/router'; | ||
|
||
/** | ||
* Page object to interact with {@link ViewInfoDialogComponent}. | ||
*/ | ||
export class ViewInfoDialogPO implements WorkbenchDialogPagePO { | ||
|
||
public readonly locator: Locator; | ||
|
||
constructor(public dialog: DialogPO) { | ||
this.locator = this.dialog.locator.locator('app-view-info-dialog'); | ||
} | ||
|
||
public async getInfo(): Promise<ViewInfo> { | ||
const routeParams = this.locator.locator('sci-key-value.e2e-route-params'); | ||
const routeData = this.locator.locator('sci-key-value.e2e-route-data'); | ||
const state = this.locator.locator('sci-key-value.e2e-state'); | ||
|
||
return { | ||
viewId: await this.locator.locator('span.e2e-view-id').innerText(), | ||
partId: await this.locator.locator('span.e2e-part-id').innerText(), | ||
title: await this.locator.locator('span.e2e-title').innerText(), | ||
heading: await this.locator.locator('span.e2e-heading').innerText(), | ||
urlSegments: await this.locator.locator('span.e2e-url-segments').innerText(), | ||
routeParams: await routeParams.isVisible() ? await new SciKeyValuePO(routeParams).readEntries() : {}, | ||
routeData: await routeData.isVisible() ? await new SciKeyValuePO(routeData).readEntries() : {}, | ||
state: await state.isVisible() ? await new SciKeyValuePO(state).readEntries() : {}, | ||
}; | ||
} | ||
} | ||
|
||
export interface ViewInfo { | ||
viewId: string; | ||
partId: string; | ||
title: string; | ||
heading: string; | ||
urlSegments: string; | ||
routeParams: Params; | ||
routeData: Data; | ||
state: ViewState; | ||
} |
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