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

Add wait for API response before code sync #1879

Merged
merged 2 commits into from
Jun 1, 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
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 @@ -134,7 +134,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
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 @@ -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 All @@ -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 Down Expand Up @@ -170,7 +168,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
2 changes: 1 addition & 1 deletion cypress/support/kaoto-ui-commands/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Cypress.Commands.add('selectStepMiniCatalog', (step, stage) => {
cy.get('[data-testid="miniCatalog"]').should('be.visible');
cy.get('.pf-c-text-input-group__text-input').type(step);
cy.get(`[data-testid="miniCatalog__stepItem--${step}"]`).first().click();
cy.waitVisualizationUpdate();
cy.waitMiniCatalogItIsClosed();
});

Expand All @@ -66,7 +67,6 @@ Cypress.Commands.add('deleteStep', (step, stepIndex) => {
cy.get(`[data-testid="viz-step-${step}"]`).eq(stepIndex).trigger('mouseover').children('[data-testid="configurationTab__deleteBtn"]').click({ force: true });

cy.waitVisualizationUpdate();

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