Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
bugfix: empty report and info/error style
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrouand committed Nov 29, 2023
1 parent 4844b10 commit f16e80a
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { StepExecutionReport } from '@core/model/scenario/step-execution-report.model';
import { ExecutionStatus } from './execution-status';

export class ScenarioExecutionReport {
constructor(
public executionId: string,
public status: ExecutionStatus,
public duration: number,
public startDate: Date,
public report: StepExecutionReport,
public environment: string,
public user: string,
public scenarioName?: string,
public error?: string,
public contextVariables?: Map<string, Object>
) { }
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div>
<div #reportHeader class="row report-header bg-body shadow sticky-top mb-2">
<div class="col-6 badge-container" *ngIf="scenarioExecutionReport?.report">
<div class="col-6 badge-container" *ngIf="scenarioExecutionReport">
<span>
<chutney-execution-badge [status]="scenarioExecutionReport.report.status"
<chutney-execution-badge [status]="scenarioExecutionReport.status"
[spin]="true"></chutney-execution-badge>
<small class="text-muted ms-2">
{{'global.time.in' | translate}} {{scenarioExecutionReport.report.duration | duration}}
{{'global.time.in' | translate}} {{scenarioExecutionReport.duration | duration}}
</small>
<small class="text-muted ms-2">
{{'global.time.at' | translate}} {{scenarioExecutionReport.report.startDate | date:'medium'}}
{{'global.time.at' | translate}} {{scenarioExecutionReport.startDate | date:'medium'}}
</small>
<small *ngIf="scenarioExecutionReport.user" class="text-muted ms-2">
{{'global.smallword.by' | translate}} : <b>{{scenarioExecutionReport.user}}</b>
Expand Down Expand Up @@ -54,7 +54,7 @@
</button>
</div>
</ng-container>
<div class="shadow btn-group btn-group-sm" role="group" aria-label="Report view actions">
<div class="shadow btn-group btn-group-sm" role="group" aria-label="Report view actions" *ngIf="scenarioExecutionReport?.report">
<button type="button" class="btn btn-sm btn-outline-primary"
title="{{'scenarios.execution.step.actions.collapse.all' | translate}}" (click)="setAllStepsCollapsed(true)">
<span class="fa fa-fw fa-chevron-right"></span>
Expand Down Expand Up @@ -117,7 +117,10 @@
</div>
</div>
</div>
<div class="report-raw d-flex flex-row" resize [left]="leftPanel" [right]="rightPanel" [grab]="grab">
<div class="report-raw d-flex flex-row error" *ngIf="!scenarioExecutionReport?.report">
{{ scenarioExecutionReport?.error }}
</div>
<div class="report-raw d-flex flex-row" resize [left]="leftPanel" [right]="rightPanel" [grab]="grab" *ngIf="scenarioExecutionReport?.report">
<div #leftPanel class="report-raw-left pe-1 w30 report-bg border-top border-end sticky-top align-self-start">
<ng-container *ngIf="scenarioExecutionReport?.report">
<ng-container *rxFor="let step of scenarioExecutionReport.report.steps">
Expand Down Expand Up @@ -222,19 +225,19 @@
</div>
</div>
</ng-cntainer>
<ng-container *ngIf="(step.information && step.information.length > 0) || (step.errors && step.errors.length > 0)">
<hr class="infos hr-text" [ngClass]="{'d-none': !infosToggle}">
<ng-container *ngIf="(step.information && step.information.length > 0) || (step.errors && step.errors.length > 0)" >
<hr class="infos hr-text" [ngClass]="{'d-none': !infosToggle}" attr.data-content="{{'scenarios.execution.step.inferr' | translate}}">
</ng-container>
<ng-container *ngIf="step.information && step.information.length > 0">
<div class="infos" [ngClass]="{'d-none': !infosToggle}">
<pre *rxFor="let info of step.information" class="step-info text-wrap text-break mb-0"
[innerHTML]="('>> ' + (info | prettyPrint: true | thumbnail) | safe: 'html')">
<pre *rxFor="let info of step.information" class="step-info mb-0"
[innerHTML]="((info | prettyPrint: true | thumbnail) | safe: 'html')">
</pre>
</div>
</ng-container>
<div *ngIf="step.errors && step.errors.length > 0" class="errors" [ngClass]="{'d-none': !errorsToggle}">
<pre *rxFor="let error of step.errors" class="step-error text-wrap text-break mb-0"
[innerHTML]="('>> ' + (error | prettyPrint: true | thumbnail) | safe: 'html')">
<pre *rxFor="let error of step.errors" class="step-error mb-0"
[innerHTML]="((error | prettyPrint: true | thumbnail) | safe: 'html')">
</pre>
</div>
<ng-container *ngIf="step.stepOutputs && Object.keys(step.stepOutputs).length > 0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
}
}

.error {
color: var(--bs-red);
}

.report-raw {

.collapse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ export class ScenarioExecutionComponent implements OnInit, OnDestroy, AfterViewI
}

ngAfterViewInit(): void {
this.resizeLeftPanelSubscription = merge(
fromEvent(window, 'resize'),
fromEvent(findScrollContainer(this.leftPanel.nativeElement),'scroll')
).pipe(
throttleTime(150),
debounceTime(150)
).subscribe(() => {
this.setLeftPanelStyle();
});
if(this.leftPanel) {
this.resizeLeftPanelSubscription = merge(
fromEvent(window, 'resize'),
fromEvent(findScrollContainer(this.leftPanel.nativeElement),'scroll')
).pipe(
throttleTime(150),
debounceTime(150)
).subscribe(() => {
this.setLeftPanelStyle();
});
}

this.setReportHeaderTop();

Expand Down Expand Up @@ -142,7 +144,9 @@ export class ScenarioExecutionComponent implements OnInit, OnDestroy, AfterViewI
this.observeScenarioExecution(executionId);
} else {
this.scenarioExecutionReport = scenarioExecutionReport;
this.afterReportUpdate();
if(scenarioExecutionReport?.report) {
this.afterReportUpdate();
}
}
},
error: error => {
Expand Down Expand Up @@ -325,8 +329,10 @@ export class ScenarioExecutionComponent implements OnInit, OnDestroy, AfterViewI
////////////////////////////////////////////////////// REPORT new view

private setLeftPanelStyle() {
this.setLefPanelHeight();
this.setLefPanelTop();
if(this.leftPanel) {
this.setLefPanelHeight();
this.setLefPanelTop();
}
}

private leftPanelHeight = 0;
Expand Down Expand Up @@ -512,9 +518,7 @@ export class ScenarioExecutionComponent implements OnInit, OnDestroy, AfterViewI
if (scrollIntoView && step) {
document.getElementById(step['rowId']).scrollIntoView({behavior: 'smooth', block: 'start'});
}
timer(1000).subscribe(() =>
this.elementRef.nativeElement.scrollIntoView({behavior: 'smooth', block: 'start'})
);
this.elementRef.nativeElement.scrollIntoView({behavior: 'instant', block: 'start'})
}

private computeAllStepRowId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,32 @@ export class ScenarioExecutionService {
}

private buildExecutionReport(jsonResponse: any): ScenarioExecutionReport {
let report;
let contextVariables;
if(jsonResponse.report) {
report = JSON.parse(jsonResponse.report).report
contextVariables = JSON.parse(jsonResponse.report).contextVariables
}
return new ScenarioExecutionReport(
jsonResponse.executionId,
JSON.parse(jsonResponse.report).report,
jsonResponse.status,
jsonResponse.duration,
new Date(jsonResponse.time),
report,
jsonResponse.environment,
jsonResponse.user,
jsonResponse.testCaseTitle,
JSON.parse(jsonResponse.report).contextVariables
jsonResponse.error,
contextVariables
);
}

private buildExecutionReportFromEvent(jsonResponse: any): ScenarioExecutionReport {
return new ScenarioExecutionReport(
jsonResponse.executionId,
jsonResponse.status,
jsonResponse.duration,
new Date(jsonResponse.time),
jsonResponse.report,
jsonResponse.environment,
jsonResponse.user,
Expand Down
1 change: 1 addition & 0 deletions ui/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"step": {
"inputs": "Inputs",
"outputs": "Outputs",
"inferr": "Logs",
"actions": {
"copy": "Copy value",
"edit": "Edit value",
Expand Down
1 change: 1 addition & 0 deletions ui/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"step": {
"inputs": "Entrées",
"outputs": "Sorties",
"inferr": "Logs",
"actions": {
"copy": "Copier la valeur",
"edit": "Editer la valeur",
Expand Down

0 comments on commit f16e80a

Please sign in to comment.