Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: add error handler e2e coverage #408

Merged
merged 1 commit into from
Nov 23, 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
16 changes: 8 additions & 8 deletions packages/ui-tests/cypress/e2e/beans.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ describe('Test for Bean support', () => {
cy.openSourceCode();
cy.checkCodeSpanLine('- name: test2', 0);
cy.checkCodeSpanLine('value: value', 0);
// blocked ATM by - https://github.com/KaotoIO/kaoto-next/issues/245
// cy.openBeans();
// cy.get('[data-testid="metadata-delete-0-btn"]').click();
// cy.get('[data-testid="metadata-row-0"]').should('not.exist');
// // CHECK the second bean was deleted in the code editor
// cy.openSourceCode();
// cy.checkCodeSpanLine('- name: test', 0);
// cy.checkCodeSpanLine('type: org.acme', 0);

cy.openBeans();
cy.get('[data-testid="metadata-delete-0-btn"]').click();
cy.get('[data-testid="metadata-row-0"]').should('not.exist');
// CHECK the second bean was deleted in the code editor
cy.openSourceCode();
cy.checkCodeSpanLine('- name: test', 0);
cy.checkCodeSpanLine('type: org.acme', 0);
});
});
78 changes: 78 additions & 0 deletions packages/ui-tests/cypress/e2e/errorHandler.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
describe('Test for Error handler support', () => {
beforeEach(() => {
cy.openHomePage();
});

it('ErrorHandler - create a new errorHandler using errorHandler editor', () => {
cy.uploadFixture('flows/TimerKafkaKB.yaml');
cy.openPipeErrorHandler();
cy.get('.pf-v5-c-menu-toggle__toggle-icon').click();
cy.get('[data-testid="pipe-error-handler-select-option-log"]').click();
cy.get(`input[name="log.parameters.maximumRedeliveries"]`).clear().type('5');
cy.get(`input[name="log.parameters.redeliveryDelay"]`).clear().type('1000');

cy.openSourceCode();
cy.checkCodeSpanLine('errorHandler:');
cy.checkCodeSpanLine('log:');
cy.checkCodeSpanLine('parameters:');
cy.checkCodeSpanLine('maximumRedeliveries: 5');
cy.checkCodeSpanLine('redeliveryDelay: 1000');

cy.openPipeErrorHandler();
cy.get('.pf-v5-c-menu-toggle__toggle-icon').click();
cy.get('[data-testid="pipe-error-handler-select-option-sink"]').click();
cy.get(`input[name="sink.endpoint.ref.kind"]`).clear().type('test-kind');
cy.get(`input[name="sink.endpoint.ref.apiVersion"]`).clear().type('0.1-SNAPSHOT');
cy.get(`input[name="sink.endpoint.ref.name"]`).clear().type('test-name');
cy.get(`input[name="sink.endpoint.properties.message"]`).clear().type('test-message');
cy.get(`input[name="sink.endpoint.properties.additionalProperties"]`).clear().type('test-additionalProperties');
cy.get(`input[name="sink.parameters.maximumRedeliveries"]`).clear().type('3');
cy.get(`input[name="sink.parameters.redeliveryDelay"]`).clear().type('2000');

cy.openSourceCode();
cy.checkCodeSpanLine('errorHandler:');
cy.checkCodeSpanLine('sink:');
cy.checkCodeSpanLine('parameters:');
cy.checkCodeSpanLine('kind: test-kind');
cy.checkCodeSpanLine('apiVersion: 0.1-SNAPSHOT');
cy.checkCodeSpanLine('name: test-name');
cy.checkCodeSpanLine('message: test-message');
cy.checkCodeSpanLine('additionalProperties: test-additionalProperties');
cy.checkCodeSpanLine('maximumRedeliveries: 3');
cy.checkCodeSpanLine('redeliveryDelay: 2000');
});

it('ErrorHandler - edit in errorHandler editor', () => {
cy.openSourceCode();
cy.uploadFixture('flows/ErrorHandlerPipe.yaml');
cy.openPipeErrorHandler();
cy.get(`input[name="log.parameters.maximumRedeliveries"]`).clear().type('5');
cy.get(`input[name="log.parameters.redeliveryDelay"]`).clear().type('1000');
cy.openSourceCode();
// CHECK the errorHandler update was reflected in the code editor
cy.checkCodeSpanLine('maximumRedeliveries: 5');
cy.checkCodeSpanLine('redeliveryDelay: 1000');
});

it('ErrorHandler - delete errorHandler properties using the ErrorHandler editor', () => {
cy.uploadFixture('flows/ErrorHandlerPipe.yaml');
cy.openPipeErrorHandler();

cy.get(`input[name="log.parameters.maximumRedeliveries"]`).clear();
cy.get(`input[name="log.parameters.redeliveryDelay"]`).clear();

// CHECK the errorHandler was edited in the code editor
cy.openSourceCode();
cy.checkCodeSpanLine('parameters: {}');
});

it('ErrorHandler - select "no error handlers" - delete errorHandler', () => {
cy.uploadFixture('flows/ErrorHandlerPipe.yaml');
cy.openPipeErrorHandler();
cy.get('.pf-v5-c-menu-toggle__toggle-icon').click();
cy.get('[data-testid="pipe-error-handler-select-option-none"]').click();
// CHECK the first errorHandler was deleted in the code editor
cy.openSourceCode();
cy.checkCodeSpanLine('errorHandler:', 0);
});
});
25 changes: 25 additions & 0 deletions packages/ui-tests/cypress/fixtures/flows/ErrorHandlerPipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: webhook-binding
spec:
errorHandler:
log:
parameters:
maximumRedeliveries: 3
redeliveryDelay: 2000
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: webhook-source
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: delay-action
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: log-sink
3 changes: 0 additions & 3 deletions packages/ui-tests/cypress/fixtures/flows/MetadataPipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,3 @@ spec:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: log-sink



2 changes: 1 addition & 1 deletion packages/ui-tests/cypress/support/next-commands/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Cypress.Commands.add('openMetadata', () => {

Cypress.Commands.add('openPipeErrorHandler', () => {
cy.get('[data-testid="Pipe ErrorHandler"]').click();
cy.get('[data-testid="metadata-editor-form-ErrorHandler"]').should('be.visible');
cy.get('h1.pf-v5-c-title').should('contain.text', 'Pipe ErrorHandler Configuration');
Copy link
Member

Choose a reason for hiding this comment

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

@tplevko this will break in the next patternfly upgrade, as an alternative, is there a cypress command to look for a test instead? or maybe looking for an H1 element?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe the H1 could help?

image

});

Cypress.Commands.add('openCatalog', () => {
Expand Down
Loading