Skip to content

Commit

Permalink
fix: have rerun available on all checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsSmets committed Oct 22, 2024
1 parent 90cdabe commit 6fb0ddd
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 33 deletions.
10 changes: 4 additions & 6 deletions src/app/compare/compare-tree/compare-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ export class CompareTreeComponent {
if (item.children) {
for (const child of item.children) {
const checkpoint = child.originalValue as Checkpoint;
if (this.getCheckpointId(checkpoint.uid) === this.getCheckpointId(checkpointToMatch.uid)) {
if (
ReportUtil.getCheckpointIdFromUid(checkpoint.uid) === ReportUtil.getCheckpointIdFromUid(checkpointToMatch.uid)
) {
tree.selectItem(child.path);
return;
} else {
Expand All @@ -142,7 +144,7 @@ export class CompareTreeComponent {
for (let checkpoint of checkpoints) {
if (
ReportUtil.isCheckPoint(itemToMatch) &&
this.getCheckpointId(checkpoint.uid) === this.getCheckpointId(itemToMatch.uid)
ReportUtil.getCheckpointIdFromUid(checkpoint.uid) === ReportUtil.getCheckpointIdFromUid(itemToMatch.uid)
) {
return checkpoint;
}
Expand All @@ -153,8 +155,4 @@ export class CompareTreeComponent {
}
return null;
}

getCheckpointId(uid: string): string {
return uid.split('#')[1];
}
}
18 changes: 8 additions & 10 deletions src/app/report/edit-display/edit-display.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@
></app-toggle-button>

<span class="button-divider">&#124;</span>
@if (ReportUtil.isReport(selectedNode)) {
<button
data-cy-report="rerun"
class="btn btn-info"
[title]=" editingEnabled ? 'Please save your changes to rerun the report' : 'Rerun this report'"
[disabled]="editingEnabled"
(click)="openDifferenceModal('saveRerun')"
>Rerun
</button>
}
<button
data-cy-report="rerun"
class="btn btn-info"
[title]=" editingEnabled ? 'Please save your changes to rerun the report' : 'Rerun this report'"
[disabled]="editingEnabled"
(click)="openDifferenceModal('saveRerun')"
>Rerun
</button>
@if (editingEnabled) {
<button
data-cy-report="discard"
Expand Down
37 changes: 21 additions & 16 deletions src/app/report/edit-display/edit-display.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,26 @@ export class EditDisplayComponent implements OnChanges {

rerunReport(): void {
const node: Report | Checkpoint = this.selectedNode!;
if (!ReportUtil.isReport(node)) {
let reportId: number | undefined;
if (ReportUtil.isReport(node)) {
reportId = node.storageId;
} else if (ReportUtil.isCheckPoint(node)) {
reportId = ReportUtil.getStorageIdFromUid(node.uid);
}
if (reportId) {
this.httpService
.runReport(this.currentView.storageName, reportId)
.pipe(catchError(this.errorHandler.handleError()))
.subscribe({
next: (response: TestResult): void => {
this.toastService.showSuccess('Report rerun successful');
this.rerunResult = response;
this.debugTab.refreshTable();
},
});
} else {
this.toastService.showDanger('Could not find report to rerun');
return;
}
const reportId: number = node.storageId;
this.httpService
.runReport(this.currentView.storageName, reportId)
.pipe(catchError(this.errorHandler.handleError()))
.subscribe({
next: (response: TestResult): void => {
this.toastService.showSuccess('Report rerun successful');
this.rerunResult = response;
this.debugTab.refreshTable();
},
});
}

closeReport(): void {
Expand Down Expand Up @@ -182,12 +187,12 @@ export class EditDisplayComponent implements OnChanges {
let reportDifferences: ReportDifference[] = [];
if (ReportUtil.isReport(node) && this.editFormComponent) {
reportDifferences = this.editFormComponent.getDifferences();
} else if (ReportUtil.isCheckPoint(node)) {
} else if (ReportUtil.isCheckPoint(node) && this.editor?.getValue() !== node.message) {
const diff = new DiffMatchPatch().diff_main(node.message ?? '', this.editor?.getValue());
reportDifferences.push({
name: 'message',
originalValue: node.message,
// @ts-ignore
difference: new DiffMatchPatch().diff_main(node.message ?? '', this.editor?.getValue()),
difference: diff,
});
}
if (reportDifferences.length > 0) {
Expand Down
4 changes: 3 additions & 1 deletion src/app/shared/interfaces/report-difference.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import DiffMatchPatch from 'diff-match-patch';

export interface ReportDifference {
name: string;
originalValue: string;
difference: (number | string)[][] | string;
difference: DiffMatchPatch.Diff[] | string;
}
6 changes: 6 additions & 0 deletions src/app/shared/util/report-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ export const ReportUtil = {
hasValidUid(uid: string) {
return !uid.includes('null');
},
getCheckpointIdFromUid(uid: string): number {
return +uid.split('#')[1];
},
getStorageIdFromUid(uid: string): number {
return +uid.split('#')[0];
},
};

0 comments on commit 6fb0ddd

Please sign in to comment.