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

Add basic set of multiflow tests #1921

Merged
merged 1 commit into from
Jun 8, 2023
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
2 changes: 1 addition & 1 deletion cypress/e2e/03-step_integration/step_integration.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('3 step integration', () => {
cy.dragAndDropFromCatalog('timer', 'slot', 'start');

// CHECK the code editor contains the new timer step
cy.get('[data-testid="toolbar-show-code-btn"]').click();
cy.openCodeEditor();
cy.get('.code-editor').should('contain.text', 'timer');

// add an action from the mini catalog
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/04-source_code/source_code.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('source code and drag and drop', () => {
cy.dragAndDropFromCatalog('timer-source', 'kafka-source', 'start');

// CHECK that the code editor contains the new timer source step
cy.get('[data-testid="toolbar-show-code-btn"]').click();
cy.openCodeEditor();
cy.get('.pf-c-code-editor__code').contains('timer-source').should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ describe('Test for Branching actions from the canvas', () => {
cy.get('[data-testid="viz-step-slot"]').should('have.length', 1);
cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-slot');

cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('[data-testid="viz-step-choice"]').should('have.length', 2);
cy.get('[data-testid="viz-step-slot"]').should('have.length', 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('User completes normal actions on steps in a branch', () => {

it('User deletes a step in a branch', () => {
cy.deleteStep('digitalocean');
cy.waitAndsyncUpCodeChanges();

// CHECK that digitalocean step is deleted
cy.get('[data-testid="viz-step-digitalocean"]').should('not.exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ describe('Test for Nested Branching actions from the canvas', () => {
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-slot');
cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-log');

cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-slot');
cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-log');
Expand Down Expand Up @@ -101,8 +99,6 @@ describe('Test for Nested Branching actions from the canvas', () => {
cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-activemq');
cy.get('.stepNode').eq(11).should('have.attr', 'data-testid', 'viz-step-slot');

cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-amqp');
cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-activemq');
Expand Down Expand Up @@ -134,8 +130,6 @@ describe('Test for Nested Branching actions from the canvas', () => {
cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-amqp');
cy.get('.stepNode').eq(11).should('have.attr', 'data-testid', 'viz-step-slot');

cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-activemq');
cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-amqp');
Expand Down Expand Up @@ -168,8 +162,6 @@ describe('Test for Nested Branching actions from the canvas', () => {
cy.get('.stepNode').eq(12).should('have.attr', 'data-testid', 'viz-step-log');
cy.get('[data-testid="viz-step-activemq"]').should('be.visible');

cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-slot');
cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-slot');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ describe('User completes normal actions on steps in a branch', () => {
cy.get('[data-testid="viz-step-amqp"]').should('not.exist');
cy.get('[data-testid="viz-step-slot"]').should('have.length', 2).and('be.visible');

cy.waitAndsyncUpCodeChanges()

// CHECK that amqp step is deleted and empty step is added
cy.get('[data-testid="viz-step-amqp"]').should('not.exist');
cy.get('[data-testid="viz-step-slot"]').should('have.length', 2).and('be.visible');
Expand Down
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This integration type will be slightly different from what it is now. Later on, multiple routes from the Integration type will be handled inside of the flows array but this is in the works at the backend.

Can I suggest you another fixture in the meantime? This is a multiple Camel route fixture.

- from:
    uri: cron:cron
    parameters:
      schedule: '1000'
    steps:
    - set-body:
        simple: body
    - to:
        uri: log:log1

- from:
    uri: timer:test
    steps:
    - to:
        uri: log:log2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, thanks for letting me know - will convert this to the flows once it's in the backend. Also the second fixture - I'll extend the tests and add there also camelRoute type tests, so the covered area represents all the possible route options.

Loading