Skip to content

Commit

Permalink
e2e - add undo and redo coverage, was fixed in upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
tplevko authored and lordrip committed Mar 8, 2024
1 parent 54694c7 commit 271a29c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 39 deletions.
16 changes: 0 additions & 16 deletions packages/ui-tests/cypress/e2e/codeEditor/multiFlowEditor.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
// });
});
43 changes: 20 additions & 23 deletions packages/ui-tests/cypress/e2e/codeEditor/sourceCodeActions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions packages/ui-tests/cypress/support/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ declare global {
checkCodeSpanLine(spanText: string, linesCount?: number): Chainable<JQuery<Element>>;
checkMultiLineContent(text: string[]): Chainable<JQuery<Element>>;
editorClickUndoXTimes(repeatCount: number): Chainable<JQuery<Element>>;
editorClickRedoXTimes(repeatCount: number): Chainable<JQuery<Element>>;
compareFileWithMonacoEditor(filePath: string): Chainable<JQuery<Element>>;
}
}
Expand Down
7 changes: 7 additions & 0 deletions packages/ui-tests/cypress/support/next-commands/sourceCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() !== '');
Expand Down

0 comments on commit 271a29c

Please sign in to comment.