Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Add basic set of multiflow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tplevko committed Jun 6, 2023
1 parent a397b05 commit 1af67b9
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 49 deletions.
80 changes: 80 additions & 0 deletions cypress/e2e/11-multi_flow/canvas_multi_flow.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
describe('Test for Multi route actions from the canvas', () => {
beforeEach(() => {
cy.intercept('/v1/deployments*').as('getDeployments');
cy.intercept('/v1/steps/id/*').as('getStepDetails');
cy.intercept('/v1/integrations/dsls').as('getDSLs');
cy.intercept('/v1/view-definitions').as('getViewDefinitions');
cy.intercept('POST', '/v2/integrations*').as('getIntegration');

cy.openHomePage();
cy.zoomOutXTimes(3);
});

it('User changes route type in the canvas', () => {
cy.switchIntegrationType('Integration');
cy.get('.pf-c-chip__text').contains('Integration');
cy.switchIntegrationType('Camel Route');
cy.get('.pf-c-chip__text').contains('Camel Route');
cy.switchIntegrationType('Kamelet');
cy.get('.pf-c-chip__text').contains('Kamelet');
cy.switchIntegrationType('KameletBinding');
cy.get('.pf-c-chip__text').contains('KameletBinding');
});

it('User shows and hides a route', () => {
cy.switchIntegrationType('Integration');
cy.createNewRoute();
cy.createNewRoute();

cy.toggleRouteVisibility(0);
cy.toggleRouteVisibility(1);

cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 3);

cy.toggleRouteVisibility(0);
cy.toggleRouteVisibility(1);
cy.toggleRouteVisibility(2);

cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 0);
});

it('User deletes routes in the canvas', () => {
cy.switchIntegrationType('Integration');
cy.createNewRoute();
cy.createNewRoute();
cy.showAllRoutes();

cy.deleteRoute(0);
cy.deleteRoute(0);
cy.deleteRoute(0);
cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 0);
});

it('User creates multiple routes in canvas', () => {
cy.switchIntegrationType('Integration');
cy.createNewRoute();
cy.createNewRoute();

cy.hideAllRoutes();
cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 0);
cy.toggleRouteVisibility(0);

cy.replaceEmptyStepMiniCatalog('timer');
cy.appendStepMiniCatalog('timer', 'log');
cy.hideAllRoutes();

cy.toggleRouteVisibility(1);
cy.replaceEmptyStepMiniCatalog('timer');
cy.appendStepMiniCatalog('timer', 'log');
cy.hideAllRoutes();

cy.toggleRouteVisibility(2);
cy.replaceEmptyStepMiniCatalog('timer');
cy.appendStepMiniCatalog('timer', 'log');

cy.showAllRoutes();
cy.get('[data-testid="viz-step-timer"]').should('have.length', 3);
cy.get('[data-testid="viz-step-log"]').should('have.length', 3);
cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 3);
});
});
79 changes: 79 additions & 0 deletions cypress/e2e/11-multi_flow/code_editor_multi_flow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
describe('Test for Multi route actions from the code editor', () => {
beforeEach(() => {
cy.intercept('/v1/deployments*').as('getDeployments');
cy.intercept('/v1/steps/id/*').as('getStepDetails');
cy.intercept('/v1/integrations/dsls').as('getDSLs');
cy.intercept('/v1/view-definitions').as('getViewDefinitions');
cy.intercept('POST', '/v2/integrations*').as('getIntegration');

cy.openHomePage();
cy.uploadFixture('IntegrationMultiFlow.yaml');

cy.zoomOutXTimes(3);
});

it('User deletes first route from multi-route using code editor', () => {
cy.editorDeleteLine(0, 15);
cy.syncUpCodeChanges();

cy.showAllRoutes();
cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 1);
});

it('User deletes second route from multi-route using code editor', () => {
cy.editorDeleteLine(15, 12);
cy.syncUpCodeChanges();

cy.showAllRoutes();
cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 1);
});

it('User deletes step from first route using code editor', () => {
cy.editorDeleteLine(11, 2);
cy.syncUpCodeChanges();

cy.showAllRoutes();
cy.get('[data-testid="viz-step-set-body"]').should('not.exist');
cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 2);
});

it('User adds step to the first route using code editor', () => {
const stepToInsert = ` - set-header:
constant: test`;
const insertLine = 11;
cy.editorAddText(insertLine, stepToInsert);
cy.syncUpCodeChanges();

// CHECK the set-header step was added
cy.get('[data-testid="viz-step-set-header"]').should('be.visible');
});

// Blocked by - https://github.com/KaotoIO/kaoto-ui/issues/1910
it.skip('User adds step to the second route using code editor', () => {
cy.showAllRoutes();
const stepToInsert = ` - set-body:
constant: test`;
const insertLine = 25;
cy.editorAddText(insertLine, stepToInsert);
cy.syncUpCodeChanges();
// CHECK the insert-field-action step was added
cy.get('[data-testid="viz-step-set-body"]').should('be.visible');
});

it('User reverts route deletion using code editor', () => {
cy.editorDeleteLine(15, 12);
cy.syncUpCodeChanges();

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();
cy.syncUpCodeChanges();

cy.showAllRoutes();
cy.get('[data-testid^="rf__node-node_0"]').should('have.length', 2);
});
});
27 changes: 27 additions & 0 deletions cypress/fixtures/IntegrationMultiFlow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
name: ''
spec:
flows:
- from:
uri: cron:cron
parameters:
schedule: '1000'
steps:
- set-body:
simple: body
- to:
uri: log:log1
---
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
name: ''
spec:
flows:
- from:
uri: timer:test
steps:
- to:
uri: log:log2
Loading

0 comments on commit 1af67b9

Please sign in to comment.