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

Commit

Permalink
Add wait for API response before code sync
Browse files Browse the repository at this point in the history
  • Loading branch information
tplevko committed Jun 1, 2023
1 parent ac1a3c3 commit 0edb218
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('Test for Step actions from the canvas', () => {
cy.intercept('/v1/deployments*').as('getDeployments');
cy.intercept('/v1/integrations/dsls').as('getDSLs');
cy.intercept('/v1/view-definitions').as('getViewDefinitions');
cy.intercept('/v2/integrations*').as('getIntegration');
cy.intercept('POST', '/v2/integrations*').as('getIntegration');

cy.openHomePage();
cy.uploadFixture('TimerLogCamelRoute.yaml');
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('Test for Step actions from the canvas', () => {
// CHECK that YAML not contains the 'timer:null'
cy.get('.code-editor').should('not.contain.text', 'timer:null');

cy.syncUpCodeChanges();
cy.waitAndsyncUpCodeChanges()

// CHECK that the step is deleted
cy.get('[data-testid="viz-step-timer"]').should('not.exist');
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Test for Step actions from the canvas', () => {
// CHECK that YAML not contains the 'timer:null'
cy.get('.code-editor').should('not.contain.text', 'timer:null');

cy.syncUpCodeChanges();
cy.waitAndsyncUpCodeChanges()

// CHECK that the step is deleted
cy.get('[data-testid="viz-step-timer"]').should('not.exist');
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Test for Step actions from the canvas', () => {
// CHECK that YAML not contains the 'timer:null'
cy.get('.code-editor').should('not.contain.text', 'timer:null');

cy.syncUpCodeChanges();
cy.waitAndsyncUpCodeChanges()

// CHECK that the step is deleted
cy.get('[data-testid="viz-step-timer"]').should('not.exist');
Expand All @@ -123,7 +123,13 @@ describe('Test for Step actions from the canvas', () => {

it('User appends a step(+ button to the right of the node)', () => {
cy.deleteStep('log');
//Wait for backend sync
cy.wait('@getIntegration');
cy.wait('@getViewDefinitions');
cy.appendStepMiniCatalog('timer', 'aggregate');
//Wait for backend sync
cy.wait('@getIntegration');
cy.wait('@getViewDefinitions');
cy.appendStepMiniCatalog('aggregate', 'log', 'end');

// CHECK that stepNodes are in the correct order
Expand All @@ -134,7 +140,7 @@ describe('Test for Step actions from the canvas', () => {
cy.get('.stepNode').should('have.length', 3);
// CHECK YAML contains the 'aggregate: {}'
cy.checkCodeSpanLine('aggregate: {}');
cy.syncUpCodeChanges();
cy.waitAndsyncUpCodeChanges()

// CHECK that stepNodes are in the correct order
cy.get('.stepNode').eq(0).should('have.attr', 'data-testid', 'viz-step-timer');
Expand Down Expand Up @@ -172,9 +178,15 @@ describe('Test for Step actions from the canvas', () => {

cy.get('[data-testid="kaoto-right-drawer"]').should('be.visible');
cy.deleteStep('log');
//Wait for backend sync
cy.wait('@getIntegration');
cy.wait('@getViewDefinitions');
cy.get('[data-testid="kaoto-right-drawer"]').should('not.be.visible');

cy.openStepConfigurationTab('timer');
//Wait for backend sync
cy.wait('@getIntegration');
cy.wait('@getViewDefinitions');
cy.get('[data-testid="kaoto-right-drawer"]').should('be.visible');
cy.deleteStep('choice');
cy.get('[data-testid="kaoto-right-drawer"]').should('be.visible');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('Test for Branching actions from the canvas', () => {
cy.intercept('/v1/deployments*').as('getDeployments');
cy.intercept('/v1/integrations/dsls').as('getDSLs');
cy.intercept('/v1/view-definitions').as('getViewDefinitions');
cy.intercept('/v2/integrations*').as('getIntegration');
cy.intercept('POST', '/v2/integrations*').as('getIntegration');

cy.openHomePage();
cy.uploadFixture('EipAction.yaml');
Expand All @@ -30,7 +30,7 @@ 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.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('[data-testid="viz-step-choice"]').should('have.length', 2);
Expand All @@ -46,7 +46,7 @@ describe('Test for Branching actions from the canvas', () => {
cy.get('.stepNode').eq(11).should('have.attr', 'data-testid', 'viz-step-kamelet:sink');
cy.get('.code-editor').should('not.contain.text', '{{?bar}}')

cy.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('[data-testid="viz-step-marshal"]').should('not.exist');
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('Test for Branching actions from the canvas', () => {
cy.get('.stepNode').eq(6).should('have.attr', 'data-testid', 'viz-step-activemq');
cy.get('[data-testid="viz-step-activemq"]').should('be.visible');

cy.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(4).should('have.attr', 'data-testid', 'viz-step-digitalocean');
Expand All @@ -108,7 +108,7 @@ describe('Test for Branching actions from the canvas', () => {
cy.get('.stepNode').eq(6).should('have.attr', 'data-testid', 'viz-step-set-header');
cy.get('[data-testid="viz-step-activemq"]').should('be.visible');

cy.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(4).should('have.attr', 'data-testid', 'viz-step-activemq');
Expand All @@ -129,7 +129,7 @@ describe('Test for Branching actions from the canvas', () => {
cy.get('.stepNode').eq(13).should('have.attr', 'data-testid', 'viz-step-filter');
cy.get('[data-testid="viz-step-activemq"]').should('be.visible');

cy.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(5).should('have.attr', 'data-testid', 'viz-step-set-header');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('User completes normal actions on steps in a branch', () => {
cy.checkCodeSpanLine('oAuthToken: token');
});

it(' User deletes a step in a branch', () => {
it('User deletes a step in a branch', () => {
cy.deleteStep('digitalocean');
cy.syncUpCodeChanges();
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 @@ -3,7 +3,7 @@ describe('Test for Nested Branching actions from the canvas', () => {
cy.intercept('/v1/deployments*').as('getDeployments');
cy.intercept('/v1/integrations/dsls').as('getDSLs');
cy.intercept('/v1/view-definitions').as('getViewDefinitions');
cy.intercept('/v2/integrations*').as('getIntegration');
cy.intercept('POST', '/v2/integrations*').as('getIntegration');

cy.openHomePage();
cy.uploadFixture('EipAction.yaml');
Expand Down Expand Up @@ -69,7 +69,7 @@ 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.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-slot');
Expand All @@ -94,15 +94,14 @@ describe('Test for Nested Branching actions from the canvas', () => {
// CHECK test setup
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-slot');

cy.appendStepMiniCatalog('amqp', 'activemq');

// CHECK that there are activemq->amqp in the nested branch and second branch step is slot
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');
cy.get('.stepNode').eq(11).should('have.attr', 'data-testid', 'viz-step-slot');

cy.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-amqp');
Expand All @@ -127,16 +126,15 @@ describe('Test for Nested Branching actions from the canvas', () => {

// CHECK test setup
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-slot');

cy.get('.stepNode').eq(10).should('have.attr', 'data-testid', 'viz-step-slot');
cy.prependStepMiniCatalog('amqp', 'activemq');

// CHECK that there are amqp->activemq in the nested branch and second branch step is slot
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');
cy.get('.stepNode').eq(11).should('have.attr', 'data-testid', 'viz-step-slot');

cy.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-activemq');
Expand All @@ -160,7 +158,8 @@ describe('Test for Nested Branching actions from the canvas', () => {
// CHECK test setup
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');

cy.wait('@getIntegration');
cy.wait('@getViewDefinitions');
cy.prependStepMiniCatalog('log', 'activemq');

// CHECK that the activemq step was prepended before filter and after all the branches ends
Expand All @@ -170,7 +169,7 @@ 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.syncUpCodeChanges()
cy.waitAndsyncUpCodeChanges()

// CHECK after Sync your code button click
cy.get('.stepNode').eq(9).should('have.attr', 'data-testid', 'viz-step-slot');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('User completes normal actions on steps in a branch', () => {
cy.intercept('/v1/steps/id/*').as('getStepDetails');
cy.intercept('/v1/integrations/dsls').as('getDSLs');
cy.intercept('/v1/view-definitions').as('getViewDefinitions');
cy.intercept('/v2/integrations*').as('getIntegration');
cy.intercept('POST', '/v2/integrations*').as('getIntegration');

cy.openHomePage();
cy.uploadFixture('EipAction.yaml');
Expand Down Expand Up @@ -42,7 +42,7 @@ 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.syncUpCodeChanges();
cy.waitAndsyncUpCodeChanges()

// CHECK that amqp step is deleted and empty step is added
cy.get('[data-testid="viz-step-amqp"]').should('not.exist');
Expand Down
6 changes: 6 additions & 0 deletions cypress/support/kaoto-ui-commands/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ Cypress.Commands.add('syncUpCodeChanges', () => {
cy.wait('@getViewDefinitions');
});

Cypress.Commands.add('waitAndsyncUpCodeChanges', () => {
cy.wait('@getIntegration');
cy.wait('@getViewDefinitions');
cy.syncUpCodeChanges();
});

Cypress.Commands.add('checkCodeSpanLine', (spanText, linesCount) => {
linesCount = linesCount ?? 1;
cy.get('.code-editor')
Expand Down
3 changes: 2 additions & 1 deletion cypress/support/kaoto-ui-commands/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ Cypress.Commands.add('deleteStep', (step, stepIndex) => {
/** Delete the given step */
cy.get(`[data-testid="viz-step-${step}"]`).eq(stepIndex).trigger('mouseover').children('[data-testid="configurationTab__deleteBtn"]').click({ force: true });

cy.waitVisualizationUpdate();
cy.wait('@getIntegration');
cy.wait('@getViewDefinitions');

/** Check whether the given step was removed */
cy.get(`[data-testid="viz-step-${step}"]`).should('have.length.lessThan', previousStepsCount);
Expand Down

0 comments on commit 0edb218

Please sign in to comment.