diff --git a/packages/ui-tests/cypress/e2e/codeEditor/multiFlowEditor.cy.ts b/packages/ui-tests/cypress/e2e/codeEditor/multiFlowEditor.cy.ts index 6d57f8960..9179bc5b5 100644 --- a/packages/ui-tests/cypress/e2e/codeEditor/multiFlowEditor.cy.ts +++ b/packages/ui-tests/cypress/e2e/codeEditor/multiFlowEditor.cy.ts @@ -85,20 +85,4 @@ describe('Test for Multi route actions from the code editor', () => { // CHECK the insert-field-action step was added cy.get('[data-type="node"][data-id^="setBody"]').should('have.length', 1); }); - - // Blocked ATM by https://github.com/patternfly/patternfly-react/issues/9838 - // it('User reverts route deletion using code editor', () => { - // cy.uploadFixture('CamelRouteMultiFlow.yaml'); - // cy.editorDeleteLine(8, 12); - // - // cy.showAllRoutes(); - // cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 1); - // // First click undo button => reverted automatic adjustments - // cy.editorClickUndoXTimes(); - // // Second click undo button => changes reverted & alert is displayed - // cy.editorClickUndoXTimes(12); - // - // cy.showAllRoutes(); - // cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 2); - // }); }); diff --git a/packages/ui-tests/cypress/e2e/codeEditor/sourceCodeActions.cy.ts b/packages/ui-tests/cypress/e2e/codeEditor/sourceCodeActions.cy.ts index 7939b0ac1..7c4f2399a 100644 --- a/packages/ui-tests/cypress/e2e/codeEditor/sourceCodeActions.cy.ts +++ b/packages/ui-tests/cypress/e2e/codeEditor/sourceCodeActions.cy.ts @@ -79,29 +79,26 @@ describe('Test source code editor', () => { cy.get('[data-type="node"][data-id^="atlasmap"]').should('have.length', 1); }); - // Blocked by https://github.com/patternfly/patternfly-react/issues/9838 - // it('User undoes a change they saved, syncs with canvas', () => { - // cy.uploadFixture('flows/CamelRoute.yaml'); - - // cy.editorDeleteLine(31, 7); - - // // CHECK branch with digitalocean and set header step was deleted - // cy.get('[data-testid="viz-step-digitalocean"]').should('not.exist'); - // cy.get('[data-testid="viz-step-set-header"]').should('not.exist'); - - // // First click undo button => reverted automatic adjustments - // cy.editorClickUndoXTimes(1); - // // Second click undo button => changes reverted & alert is displayed - // cy.editorClickUndoXTimes(7); - // // CHECK alert is displayed - // cy.get('.pf-c-alert__title').contains( - // "Any invalid code will be replaced after sync. If you don't want to lose your changes please make a backup.", - // ); - - // // CHECK branch with digitalocean and set header step was deleted - // cy.get('[data-testid="viz-step-digitalocean"]').should('be.visible'); - // cy.get('[data-testid="viz-step-set-header"]').should('be.visible'); - // }); + it('User undoes a change and redoes a change', () => { + cy.uploadFixture('flows/CamelRoute.yaml'); + + cy.editorDeleteLine(5, 7); + // click undo button => reverted automatic adjustments + cy.editorClickUndoXTimes(4); + + // CHECK changes are reflected in the code editor + cy.checkCodeSpanLine('- setHeader:', 0); + cy.checkCodeSpanLine('constant: test', 0); + cy.checkCodeSpanLine('name: test', 0); + cy.checkCodeSpanLine('- marshal:', 1); + cy.checkCodeSpanLine('id: marshal-3801', 1); + + // click redo button => redo adjustments + cy.editorClickRedoXTimes(2); + // CHECK changes are reflected in the code editor + cy.checkCodeSpanLine('- marshal:', 0); + cy.checkCodeSpanLine('id: marshal-3801', 0); + }); it('User uploads YAML file, syncs with canvas', () => { cy.uploadFixture('flows/TimerKafkaKB.yaml'); diff --git a/packages/ui-tests/cypress/support/cypress.d.ts b/packages/ui-tests/cypress/support/cypress.d.ts index 6423e0c34..1079c8a7c 100644 --- a/packages/ui-tests/cypress/support/cypress.d.ts +++ b/packages/ui-tests/cypress/support/cypress.d.ts @@ -71,6 +71,7 @@ declare global { checkCodeSpanLine(spanText: string, linesCount?: number): Chainable>; checkMultiLineContent(text: string[]): Chainable>; editorClickUndoXTimes(repeatCount: number): Chainable>; + editorClickRedoXTimes(repeatCount: number): Chainable>; compareFileWithMonacoEditor(filePath: string): Chainable>; } } diff --git a/packages/ui-tests/cypress/support/next-commands/sourceCode.ts b/packages/ui-tests/cypress/support/next-commands/sourceCode.ts index 3741e6b8a..57d0b7e3f 100644 --- a/packages/ui-tests/cypress/support/next-commands/sourceCode.ts +++ b/packages/ui-tests/cypress/support/next-commands/sourceCode.ts @@ -64,6 +64,13 @@ Cypress.Commands.add('editorClickUndoXTimes', (repeatCount: number) => { }); }); +Cypress.Commands.add('editorClickRedoXTimes', (repeatCount: number) => { + repeatCount = repeatCount ?? 1; + Array.from({ length: repeatCount }).forEach(() => { + return cy.get('[data-testid="sourceCode--redoButton"]').click(); + }); +}); + Cypress.Commands.add('compareFileWithMonacoEditor', (filePath: string) => { cy.fixture(filePath).then((fileContent) => { const fileLines = fileContent.split('\n').filter((line: string) => line.trim() !== '');