Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: open first checkpoint instead of root node when opening report in debug tab #733

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 13 additions & 2 deletions src/app/debug/debug-tree/debug-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,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
Loading