Skip to content

Commit

Permalink
Add e2e coverage for Rest Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tplevko authored and lordrip committed Jun 11, 2024
1 parent 719dfed commit e0d76a4
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('Test for root containers', () => {
describe('Test for root on exception container', () => {
beforeEach(() => {
cy.openHomePage();
});
Expand Down Expand Up @@ -33,6 +33,8 @@ describe('Test for root containers', () => {
.find('.pf-topology__node__label')
.find('.pf-topology__node__label__background')
.click();
cy.selectInTypeaheadField('redeliveryPolicy.retriesExhaustedLogLevel', 'INFO');
cy.selectInTypeaheadField('redeliveryPolicy.retryAttemptedLogLevel', 'INFO');

cy.get(`textarea[name="description"]`).clear().type('testDescription');
cy.get(`input[name="onExceptionOccurredRef"]`).clear().type('testOnExceptionOccurredRef');
Expand All @@ -59,6 +61,22 @@ describe('Test for root containers', () => {
cy.get(`input[name="redeliveryPolicy.redeliveryDelay"]`).clear().type('2000');
cy.get(`input[name="redeliveryPolicy.retryAttemptedLogInterval"]`).clear().type('2');
cy.get(`input[name="redeliveryPolicyRef"]`).clear().type('testRedeliveryPolicyRef');
cy.openExpressionModal('retryWhile');
cy.selectExpression('Constant');
cy.interactWithExpressinInputObject('expression', `retryWhile.constant`);
cy.interactWithExpressinInputObject('id', 'retryWhile.constantExpressionId');
cy.confirmExpressionModal();
cy.openExpressionModal('handled');
cy.selectExpression('Constant');
cy.interactWithExpressinInputObject('expression', `handled.constant`);
cy.interactWithExpressinInputObject('id', 'handled.constantExpressionId');
cy.confirmExpressionModal();
cy.openExpressionModal('continued');
cy.selectExpression('Constant');
cy.interactWithExpressinInputObject('expression', `continued.constant`);
cy.interactWithExpressinInputObject('id', 'continued.constantExpressionId');
cy.confirmExpressionModal();

cy.openSourceCode();

cy.checkCodeSpanLine('description: testDescription');
Expand All @@ -85,5 +103,18 @@ describe('Test for root containers', () => {
cy.checkCodeSpanLine('redeliveryDelay: "2000"');
cy.checkCodeSpanLine('retryAttemptedLogInterval: "2"');
cy.checkCodeSpanLine('redeliveryPolicyRef: testRedeliveryPolicyRef');

cy.checkCodeSpanLine('retryWhile:');
cy.checkCodeSpanLine('id: retryWhile.constantExpressionId');
cy.checkCodeSpanLine('expression: retryWhile.constant');
cy.checkCodeSpanLine('handled:');
cy.checkCodeSpanLine('id: handled.constantExpressionId');
cy.checkCodeSpanLine('expression: handled.constant');
cy.checkCodeSpanLine('continued:');
cy.checkCodeSpanLine('id: continued.constantExpressionId');
cy.checkCodeSpanLine('expression: continued.constant');

cy.checkCodeSpanLine('retriesExhaustedLogLevel: INFO');
cy.checkCodeSpanLine('retryAttemptedLogLevel: INFO');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
describe('Test for root on rest configuration container', () => {
beforeEach(() => {
cy.openHomePage();
});

it('Root onException config', () => {
cy.selectCamelRouteType('Rest', 'restConfiguration');

cy.get('[data-id^="restConfiguration"]')
.find('.pf-topology__node__label')
.find('.pf-topology__node__label__background')
.click();

cy.selectInTypeaheadField('component', 'coap');
cy.selectInTypeaheadField('apiComponent', 'openapi');
cy.selectInTypeaheadField('producerComponent', 'http');
cy.get(`input[name="scheme"]`).clear().type('testScheme');
cy.get(`input[name="host"]`).clear().type('testHost');
cy.get(`input[name="port"]`).clear().type('8080');
cy.get(`input[name="apiHost"]`).clear().type('testApiHost');
cy.get(`input[name="useXForwardHeaders"]`).check();
cy.get(`input[name="producerApiDoc"]`).clear().type('testProducerApiDoc');
cy.get(`input[name="contextPath"]`).clear().type('testContextPath');
cy.get(`input[name="apiContextPath"]`).clear().type('testApiContextPath');
cy.get(`input[name="apiContextRouteId"]`).clear().type('testApiContextRouteId');
cy.get(`input[name="apiVendorExtension"]`).check();
cy.selectInTypeaheadField('hostNameResolver', 'localIp');
cy.selectInTypeaheadField('bindingMode', 'auto');
cy.get(`input[name="skipBindingOnErrorCode"]`).check();
cy.get(`input[name="clientRequestValidation"]`).check();
cy.get(`input[name="enableCORS"]`).check();
cy.get(`input[name="enableNoContentResponse"]`).check();
cy.get(`input[name="inlineRoutes"]`).check();
cy.get(`input[name="jsonDataFormat"]`).clear().type('testJsonDataFormat');
cy.get(`input[name="xmlDataFormat"]`).clear().type('testXmlDataFormat');

cy.addSingleProperty('Component Property', 'componentTestKey', 'componentTestValue');
cy.addSingleProperty('Endpoint Property', 'endpointTestKey', 'endpointTestValue');
cy.addSingleProperty('Consumer Property', 'consumerTestKey', 'consumerTestValue');
cy.addSingleProperty('Data Format Property', 'dataFormatTestKey', 'dataFormatTestValue');
cy.addSingleProperty('Api Property', 'apiTestKey', 'apiTestValue');
cy.addSingleProperty('Cors Headers', 'corsHeadersTestKey', 'corsHeadersTestValue');

cy.openSourceCode();

cy.checkCodeSpanLine('- restConfiguration:');
cy.checkCodeSpanLine('apiComponent: openapi');
cy.checkCodeSpanLine('apiContextPath: testApiContextPath');
cy.checkCodeSpanLine('apiContextRouteId: testApiContextRouteId');
cy.checkCodeSpanLine('apiHost: testApiHost');
cy.checkCodeSpanLine('useXForwardHeaders: true');
cy.checkCodeSpanLine('apiVendorExtension: true');
cy.checkCodeSpanLine('bindingMode: auto');
cy.checkCodeSpanLine('clientRequestValidation: true');
cy.checkCodeSpanLine('component: coap');
cy.checkCodeSpanLine('contextPath: testContextPath');
cy.checkCodeSpanLine('enableCORS: true');
cy.checkCodeSpanLine('enableNoContentResponse: true');
cy.checkCodeSpanLine('host: testHost');
cy.checkCodeSpanLine('hostNameResolver: localIp');
cy.checkCodeSpanLine('jsonDataFormat: testJsonDataFormat');
cy.checkCodeSpanLine('port: "8080"');
cy.checkCodeSpanLine('producerApiDoc: testProducerApiDoc');
cy.checkCodeSpanLine('producerComponent: http');
cy.checkCodeSpanLine('scheme: testScheme');
cy.checkCodeSpanLine('skipBindingOnErrorCode: true');
cy.checkCodeSpanLine('xmlDataFormat: testXmlDataFormat');
cy.checkCodeSpanLine('componentProperty:');
cy.checkCodeSpanLine('- key: componentTestKey');
cy.checkCodeSpanLine('value: componentTestValue');
cy.checkCodeSpanLine('apiProperty:');
cy.checkCodeSpanLine('- key: apiTestKey');
cy.checkCodeSpanLine('value: apiTestValue');
cy.checkCodeSpanLine('consumerProperty:');
cy.checkCodeSpanLine('- key: consumerTestKey');
cy.checkCodeSpanLine('value: consumerTestValue');
cy.checkCodeSpanLine('corsHeaders:');
cy.checkCodeSpanLine('- key: corsHeadersTestKey');
cy.checkCodeSpanLine('value: corsHeadersTestValue');
cy.checkCodeSpanLine('dataFormatProperty:');
cy.checkCodeSpanLine('- key: dataFormatTestKey');
cy.checkCodeSpanLine('value: dataFormatTestValue');
cy.checkCodeSpanLine('endpointProperty:');
cy.checkCodeSpanLine('- key: endpointTestKey');
cy.checkCodeSpanLine('value: endpointTestValue');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Tests for sidebar expression configuration', () => {
cy.openDesignPage();
// Configure setHeader expression
cy.openStepConfigurationTab('setHeader');
cy.openExpressionModal();
cy.openExpressionModalBtn();
cy.selectExpression('Simple');
cy.interactWithExpressinInputObject('expression', `{{}{{}header.baz}}`);
cy.interactWithExpressinInputObject('id', 'simpleExpressionId');
Expand All @@ -28,7 +28,7 @@ describe('Tests for sidebar expression configuration', () => {
cy.openDesignPage();

cy.openStepConfigurationTab('setHeader');
cy.openExpressionModal();
cy.openExpressionModalBtn();
cy.selectExpression('JQ');
cy.interactWithConfigInputObject('expression', '.id');
cy.interactWithConfigInputObject('resultType', 'java.lang.String');
Expand All @@ -41,7 +41,7 @@ describe('Tests for sidebar expression configuration', () => {
cy.checkNodeExist('setHeader', 2);

cy.openStepConfigurationTab('setHeader', 1);
cy.openExpressionModal();
cy.openExpressionModalBtn();
cy.selectExpression('JQ');
cy.interactWithConfigInputObject('expression', '.name');
cy.interactWithConfigInputObject('resultType', 'java.lang.String');
Expand All @@ -51,15 +51,15 @@ describe('Tests for sidebar expression configuration', () => {
cy.openStepConfigurationTab('setHeader', 0);

// Check the configured fields didn't disappear from the first node
cy.openExpressionModal();
cy.openExpressionModalBtn();
cy.checkConfigCheckboxObject('trim', true);
cy.checkConfigInputObject('resultType', 'java.lang.String');
cy.checkConfigInputObject('expression', '.id');
cy.cancelExpressionModal();

// Check the configured fields didn't disappear from the second node
cy.openStepConfigurationTab('setHeader', 0);
cy.openExpressionModal();
cy.openExpressionModalBtn();
cy.checkConfigCheckboxObject('trim', true);
cy.checkConfigInputObject('resultType', 'java.lang.String');
cy.checkConfigInputObject('expression', '.name');
Expand All @@ -77,7 +77,7 @@ describe('Tests for sidebar expression configuration', () => {
cy.openDesignPage();
// Configure setHeader expression
cy.openStepConfigurationTab('setHeader');
cy.openExpressionModal();
cy.openExpressionModalBtn();
cy.selectExpression('Simple');
cy.interactWithExpressinInputObject('expression', `{{}{{}header.baz}}`);
cy.interactWithExpressinInputObject('id', 'simpleExpressionId');
Expand All @@ -97,7 +97,7 @@ describe('Tests for sidebar expression configuration', () => {
cy.openDesignPage();
// Configure setBody expression
cy.openStepConfigurationTab('setBody');
cy.openExpressionModal();
cy.openExpressionModalBtn();
cy.selectExpression('Simple');
cy.interactWithExpressinInputObject('expression', `{{}{{}body.baz}}`);
cy.interactWithExpressinInputObject('id', 'simpleExpressionId');
Expand Down
6 changes: 5 additions & 1 deletion packages/ui-tests/cypress/support/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@ declare global {
checkEdgeExists(sourceName: string, targetName: string): Chainable<JQuery<Element>>;
deleteBranch(branchIndex: number): Chainable<JQuery<Element>>;
selectDataformat(dataformat: string): Chainable<JQuery<Element>>;
openExpressionModal(): Chainable<JQuery<Element>>;
openExpressionModal(expression: string): Chainable<JQuery<Element>>;
openExpressionModalBtn(): Chainable<JQuery<Element>>;
confirmExpressionModal(): Chainable<JQuery<Element>>;
cancelExpressionModal(): Chainable<JQuery<Element>>;
selectExpression(expression: string): Chainable<JQuery<Element>>;
selectCamelRouteType(type: string, subType?: string): Chainable<JQuery<Element>>;
addSingleProperty(propertyName: string, key: string, value: string): Chainable<JQuery<Element>>;
configureNewBeanReference(inputName: string): Chainable<JQuery<Element>>;
configureBeanReference(inputName: string, value: string): Chainable<JQuery<Element>>;
deselectNodeBean(inputName: string): Chainable<JQuery<Element>>;
configureDropdownValue(inputName: string, value: string): Chainable<JQuery<Element>>;
chooseFromCatalog(nodeType: string, name: string): Chainable<JQuery<Element>>;
selectCustomMetadataEditor(type: string, expression: string): Chainable<JQuery<Element>>;
selectInTypeaheadField(inputGroup: string, value: string): Chainable<JQuery<Element>>;
// metadata
expandWrappedSection(sectionName: string): Chainable<JQuery<Element>>;
closeWrappedSection(sectionName: string): Chainable<JQuery<Element>>;
Expand Down
54 changes: 52 additions & 2 deletions packages/ui-tests/cypress/support/next-commands/design.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,44 @@ Cypress.Commands.add('deleteBranch', (branchIndex) => {
cy.get('[data-testid="confirmDeleteBranchDialog__btn"]').click();
});

Cypress.Commands.add('openExpressionModal', () => {
cy.get('[data-testid="launch-expression-modal-btn"]').should('be.visible').click();
Cypress.Commands.add('openExpressionModalBtn', () => {
cy.get('[data-testid="launch-expression-modal-btn"]').scrollIntoView().should('be.visible').click();
});

Cypress.Commands.add('openExpressionModal', (expression: string) => {
cy.get(`[data-fieldname="${expression}"]`)
.scrollIntoView()
.within(() => {
cy.openExpressionModalBtn();
});
});

Cypress.Commands.add('selectCamelRouteType', (type: string, subType?: string) => {
cy.get('[data-testid="new-entity-list-dropdown"]').click({ force: true });
if (subType) {
cy.get('ul.pf-v5-c-menu__list')
.should('exist')
.find(`[data-testid="new-entity-${type}"]`)
.should('exist')
.trigger('mouseover');
}
subType = subType ?? type;
cy.get(`[data-testid="new-entity-${subType}"] button.pf-v5-c-menu__item`).click({ force: true });
});

Cypress.Commands.add('addSingleProperty', (propertyName: string, key: string, value: string) => {
cy.get('label')
.contains(propertyName)
.parent()
.parent()
.parent()
.within(() => {
cy.get('[data-testid="list-add-field"]').click();
cy.get('input[label="Key"]').click();
cy.get('input[label="Key"]').type(key);
cy.get('input[label="Value"]').click();
cy.get('input[label="Value"]').type(value);
});
});

Cypress.Commands.add('confirmExpressionModal', () => {
Expand Down Expand Up @@ -166,3 +202,17 @@ Cypress.Commands.add('configureDropdownValue', (inputName: string, value?: strin
Cypress.Commands.add('deselectNodeBean', (inputName: string) => {
cy.get(`div[data-fieldname="${inputName}"] button[aria-label="Clear input value"]`).click();
});

Cypress.Commands.add('selectInTypeaheadField', (inputGroup: string, value: string) => {
cy.get(`[data-fieldname="${inputGroup}"]`).within(() => {
cy.get('button.pf-v5-c-menu-toggle__button').click();
});
cy.get(`#select-typeahead-${value}`).click();
});

Cypress.Commands.add('selectInTypeaheadField', (inputGroup: string, value: string) => {
cy.get(`[data-fieldname="${inputGroup}"]`).within(() => {
cy.get('button.pf-v5-c-menu-toggle__button').click();
});
cy.get(`#select-typeahead-${value}`).click();
});

0 comments on commit e0d76a4

Please sign in to comment.