Skip to content

Commit

Permalink
Merge branch 'master' into fix/illogical-toast-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsSmets authored Oct 23, 2024
2 parents af62a1d + e47b807 commit 2d1c444
Show file tree
Hide file tree
Showing 30 changed files with 144 additions and 214 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/debug/custom-editor.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Tests for custom editor in debug tab', () => {

it('should set xml as available view if editor content is xml file', () => {
cy.clickRowInTable(0);
cy.clickFirstFileInFileTree();
cy.clickRootNodeInFileTree();
cy.get('[data-cy-editor="viewDropDown"]').as('viewDropDown').find('option:selected').should('contain.text', 'Raw');
// eslint-disable-next-line sonarjs/no-duplicate-string
cy.get('@viewDropDown').find('option').should('have.length', 2);
Expand All @@ -21,7 +21,7 @@ describe('Tests for custom editor in debug tab', () => {

it('should apply effect based on selected view', () => {
cy.clickRowInTable(0);
cy.clickFirstFileInFileTree();
cy.clickRootNodeInFileTree();
cy.get('[data-cy-editor="viewDropDown"]').as('viewDropDown');
let numberOfLines = 0;
cy.get('div.line-numbers').then((elements) => {
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/debug/transformation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ describe('Tests for report transformation', () => {
cy.get('[data-cy-debug="refresh"]').click();
cy.assertDebugTableLength(1).click();
cy.checkFileTreeLength(1);
// We test that the top node was not selected before.
// cy.get('[data-cy-debug-tree="root"] .jqx-tree-dropdown-root > li > div').click();
cy.clickRootNodeInFileTree();
cy.get('[data-cy-open-metadata-table]').click();
cy.get('[data-cy-element-name="editor"]').contains('Name="IGNORED"');
// The transformation should not affect the report table, only the XML in the Monaco editor
Expand Down
35 changes: 0 additions & 35 deletions cypress/e2e/transformation.cy.ts

This file was deleted.

37 changes: 31 additions & 6 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,55 @@ declare global {
namespace Cypress {
interface Chainable {
initializeApp(): Chainable;

resetApp(): Chainable;

clearTestReports(): Chainable;

navigateToTestTabAndWait(): Chainable;

navigateToDebugTabAndWait(): Chainable;

createReport(): Chainable;

createOtherReport(): Chainable;

createRunningReport(): Chainable;

createReportWithLabelNull(): Chainable;

createReportWithLabelEmpty(): Chainable;

createReportWithInfopoint(): Chainable;

createReportWithMultipleStartpoints(): Chainable;

clearDebugStore(): Chainable;

clearReportsInProgress(): Chainable;

selectIfNotSelected(): Chainable;

enableShowMultipleInDebugTree(): Chainable;

checkTestTableNumRows(length: number): Chainable;

checkTestTableReportsAre(reportNames: string[]): Chainable;

debugTreeGuardedCopyReport(reportName: string, numExpandedNodes: number, aliasSuffix: string): Chainable;
clickFirstFileInFileTree(): Chainable;

clickRootNodeInFileTree(): Chainable;

clickRowInTable(index: number): Chainable;

checkFileTreeLength(length: number): Chainable;

refreshApp(): Chainable;

getDebugTableRows(): Chainable;

getTestTableRows(): Chainable

assertDebugTableLength(length: number): Chainable;
}
}
Expand All @@ -61,7 +86,7 @@ Cypress.Commands.add('resetApp' as keyof Chainable, (): void => {
});

Cypress.Commands.add('clearTestReports' as keyof Chainable, (): void => {
cy.request({ method: 'DELETE', url: '/api/report/all/Test' }).then((resp: Cypress.Response<ApiResponse>) => {
cy.request({method: 'DELETE', url: '/api/report/all/Test'}).then((resp: Cypress.Response<ApiResponse>) => {
expect(resp.status).equal(200);
});
});
Expand Down Expand Up @@ -140,7 +165,7 @@ Cypress.Commands.add('clearReportsInProgress' as keyof Chainable, (): void => {
});
});

Cypress.Commands.add('selectIfNotSelected' as keyof Chainable, { prevSubject: 'element' }, (node: JQueryWithSelector<HTMLElement>): void => {
Cypress.Commands.add('selectIfNotSelected' as keyof Chainable, {prevSubject: 'element'}, (node: JQueryWithSelector<HTMLElement>): void => {
if (!node[0].classList.contains("selected")) {
cy.wrap(node).click()
}
Expand Down Expand Up @@ -185,9 +210,9 @@ Cypress.Commands.add('debugTreeGuardedCopyReport' as keyof Chainable, (reportNam
});
});

Cypress.Commands.add('clickFirstFileInFileTree' as keyof Chainable, (): void => {
cy.get('[data-cy-debug-tree="root"] > app-tree-item').eq(0).find('app-tree-item').eq(0).click();
});
Cypress.Commands.add('clickRootNodeInFileTree' as keyof Chainable, (): void => {
cy.get('[data-cy-debug-tree="root"] > app-tree-item').eq(0).find('.sft-item').eq(0).click()
})

Cypress.Commands.add('clickRowInTable' as keyof Chainable, (index: number): void => {
cy.getDebugTableRows().eq(index).click();
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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];
}
}
6 changes: 5 additions & 1 deletion src/app/debug/active-filters/active-filters.component.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.filter-container {
background-color: rgba(26, 179,148);
background-color: rgba(26, 179, 148);
}

div:hover {
cursor: pointer;
}
17 changes: 13 additions & 4 deletions src/app/debug/debug-tree/debug-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
NgbDropdownMenu,
NgbDropdownToggle,
} from '@ng-bootstrap/ng-bootstrap';
import { ButtonComponent } from '../../shared/components/button/button.component';
import { ReportHierarchyTransformer } from '../../shared/classes/report-hierarchy-transformer';
import { SimpleFileTreeUtil } from '../../shared/util/simple-file-tree-util';
import { View } from '../../shared/interfaces/view';
Expand All @@ -31,7 +30,6 @@ import { RefreshCondition } from '../../shared/interfaces/refresh-condition';
styleUrls: ['./debug-tree.component.css'],
standalone: true,
imports: [
ButtonComponent,
NgbDropdown,
NgbDropdownToggle,
NgbDropdownMenu,
Expand Down Expand Up @@ -152,13 +150,24 @@ export class DebugTreeComponent implements OnDestroy {
this.tree.clearItems();
}
const newReport: CreateTreeItem = new ReportHierarchyTransformer().transform(report);
const path: string = this.tree.addItem(newReport);
this.tree.selectItem(path);
const rootNodePath: string = this.tree.addItem(newReport);
this.selectFirstCheckpoint(rootNodePath);
if (this._currentView) {
this.hideOrShowCheckpointsBasedOnView(this._currentView);
}
}

private selectFirstCheckpoint(rootNodePath: string) {
const last = this.tree.items.length - 1;
const lastAdded = this.tree.items[last];
if (lastAdded.children) {
const firstCheckpoint = lastAdded.children[0];
this.tree.selectItem(firstCheckpoint.path);
} else {
this.tree.selectItem(rootNodePath);
}
}

closeEntireTree(): void {
this.closeEntireTreeEvent.emit();
this.tree.clearItems();
Expand Down
14 changes: 1 addition & 13 deletions src/app/debug/filter-side-drawer/filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ export class FilterService {
this.filterErrors.clear();
for (let [key, value] of context) {
const metadataType: string | undefined = this.metadataTypes.get(key);
if (
(this.isTimestamp(metadataType) && !this.isValidTimestamp(value)) ||
(this.isNumber(metadataType) && !this.isValidNumber(value))
) {
if (this.isNumber(metadataType) && !this.isValidNumber(value)) {
this.filterErrors.set(<string>this.metadataTypes.get(key), value);
errorFound = true;
}
Expand Down Expand Up @@ -104,19 +101,10 @@ export class FilterService {
this.filterErrorSubject.next([true, this.filterErrors]);
}

isTimestamp(metadataType: string | undefined): boolean {
return metadataType === 'timestamp';
}

isNumber(metadataType: string | undefined): boolean {
return metadataType === 'int' || metadataType === 'long';
}

isValidTimestamp(userInput: string): boolean {
const regex: RegExp = /^(\*|[\d :\-]*\*?)+$/;
return regex.test(userInput) && length < 20;
}

isValidNumber(userInput: string): boolean {
const regex: RegExp = /^\*?-?\d*(\.\d*)?\*?$/;
return regex.test(userInput);
Expand Down
18 changes: 11 additions & 7 deletions src/app/debug/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HelperService } from '../../shared/services/helper.service';
import { HttpService } from '../../shared/services/http.service';
import { TableSettingsModalComponent } from './table-settings-modal/table-settings-modal.component';
import { TableSettings } from '../../shared/interfaces/table-settings';
import { catchError, Subject, Subscription, tap } from 'rxjs';
import { catchError, Subject, Subscription } from 'rxjs';
import { Report } from '../../shared/interfaces/report';
import { SettingsService } from '../../shared/services/settings.service';
import { ToastService } from '../../shared/services/toast.service';
Expand All @@ -23,7 +23,6 @@ import {
NgbDropdownMenu,
NgbDropdownToggle,
} from '@ng-bootstrap/ng-bootstrap';
import { ButtonComponent } from '../../shared/components/button/button.component';
import { FilterSideDrawerComponent } from '../filter-side-drawer/filter-side-drawer.component';
import { KeyValuePipe, NgClass } from '@angular/common';
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
Expand All @@ -43,7 +42,6 @@ import { RefreshCondition } from '../../shared/interfaces/refresh-condition';
standalone: true,
imports: [
FilterSideDrawerComponent,
ButtonComponent,
NgbDropdown,
NgbDropdownToggle,
NgbDropdownMenu,
Expand Down Expand Up @@ -190,6 +188,10 @@ export class TableComponent implements OnInit, OnDestroy {
this.refresh(condition),
);
this.subscriptions.add(refreshTable);
const amountOfRecordsInTableSubscription = this.settingsService.amountOfRecordsInTableObservable.subscribe(
(value) => (this.tableSettings.displayAmount = value),
);
this.subscriptions.add(amountOfRecordsInTableSubscription);
}

setTableSpacing(value: number): void {
Expand Down Expand Up @@ -465,19 +467,21 @@ export class TableComponent implements OnInit, OnDestroy {
}

changeTableLimit(event: any): void {
this.tableSettings.displayAmount = event.target.value === '' ? 0 : event.target.value;
this.retrieveRecords();
const value = event.target.value === '' ? 0 : event.target.value;
if (this.tableSettings.displayAmount !== value) {
this.settingsService.setAmountOfRecordsInTable(value);
this.retrieveRecords();
}
}

refresh(refreshCondition?: RefreshCondition): void {
this.tableSettings.displayAmount = 10;
if (refreshCondition) {
this.loadData(refreshCondition.displayToast);
} else {
this.loadData();
}
}

Check failure on line 484 in src/app/debug/table/table.component.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Delete `··`
openReport(storageId: number): void {
this.httpService
.getReport(storageId, this.currentView.storageName)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CustomEditorComponent } from './custom-editor.component';
import { EditorComponent } from './editor.component';

describe('CustomEditorComponent', () => {
let component: CustomEditorComponent;
let fixture: ComponentFixture<CustomEditorComponent>;
let component: EditorComponent;
let fixture: ComponentFixture<EditorComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CustomEditorComponent],
imports: [EditorComponent],
}).compileComponents();

fixture = TestBed.createComponent(CustomEditorComponent);
fixture = TestBed.createComponent(EditorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
Loading

0 comments on commit 2d1c444

Please sign in to comment.