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(757) - add tests for support for kamelet beans #856

Merged
merged 1 commit into from
Feb 21, 2024
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
117 changes: 64 additions & 53 deletions packages/ui-tests/cypress/e2e/designer/routeBeanConf.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,96 @@ describe('Test for node bean reference and configuration support', () => {
cy.openHomePage();
});

it('Beans - create a new bean in route using bean editor', () => {
cy.uploadFixture('flows/SqlBeansCR.yaml');
cy.openDesignPage();
const testData = [
{ file: 'SqlBeansKamelet.yaml', dataSource: '#bean:{{test}}' },
{ file: 'SqlBeansCR.yaml', dataSource: '#test' },
];
testData.forEach((data) => {
it('Beans - create a new bean in route using bean editor ' + data.file, () => {
cy.uploadFixture('flows/' + data.file);
cy.openDesignPage();

cy.openStepConfigurationTab('sql');
cy.configureNewBeanReference('parameters.dataSource');
cy.get(`input[name="name"]`).clear().type('test');
cy.get(`input[name="type"]`).clear().type('org.acme');
cy.openStepConfigurationTab('sql');
cy.configureNewBeanReference('parameters.dataSource');
cy.get(`input[name="name"]`).clear().type('test');
cy.get(`input[name="type"]`).clear().type('org.acme');

cy.expandWrappedSection('properties');
cy.get('[data-testid="properties-add-string-property--btn"]').not(':hidden').first().click({ force: true });
cy.get('[data-testid="properties--placeholder-name-input"]').should('not.be.disabled');
cy.get('[data-testid="properties--placeholder-name-input"]').click({ force: true });
cy.get('[data-testid="properties--placeholder-name-input"]').clear().type('test');
cy.expandWrappedSection('properties');
cy.get('[data-testid="properties-add-string-property--btn"]').not(':hidden').first().click({ force: true });
cy.get('[data-testid="properties--placeholder-name-input"]').should('not.be.disabled');
cy.get('[data-testid="properties--placeholder-name-input"]').click({ force: true });
cy.get('[data-testid="properties--placeholder-name-input"]').clear().type('test');

cy.get('[data-testid="properties--placeholder-value-input"]').should('not.be.disabled');
cy.get('[data-testid="properties--placeholder-value-input"]').click({ force: true });
cy.get('[data-testid="properties--placeholder-value-input"]').clear().type('value');
cy.get('[data-testid="properties--placeholder-value-input"]').should('not.be.disabled');
cy.get('[data-testid="properties--placeholder-value-input"]').click({ force: true });
cy.get('[data-testid="properties--placeholder-value-input"]').clear().type('value');

cy.get('[data-testid="properties--placeholder-property-edit-confirm--btn"]').click({ force: true });
cy.get('[data-testid="properties--placeholder-property-edit-confirm--btn"]').click({ force: true });

cy.get('[data-testid="create-bean-btn"').click();
cy.closeStepConfigurationTab();
cy.openSourceCode();
cy.get('[data-testid="create-bean-btn"').click();
cy.closeStepConfigurationTab();
cy.openSourceCode();

// CHECK the bean was created in the code editor
cy.openSourceCode();
cy.checkCodeSpanLine('- beans:');
cy.checkCodeSpanLine('- name: test');
cy.checkCodeSpanLine('type: org.acme');
cy.checkCodeSpanLine('properties:');
cy.checkCodeSpanLine('test: value');
// CHECK the bean is referenced in the code editor
cy.checkCodeSpanLine('dataSource: "#test"');
// CHECK the bean was created in the code editor
cy.openSourceCode();
cy.checkCodeSpanLine('- name: test');
cy.checkCodeSpanLine('type: org.acme');
cy.checkCodeSpanLine('properties:');
cy.checkCodeSpanLine('test: value');
// CHECK the bean is referenced in the code editor
cy.checkCodeSpanLine('dataSource: "' + data.dataSource + '"');
});
});

it('Beans - select existing bean in node form config', () => {
cy.openSourceCode();
cy.uploadFixture('flows/SqlBeansCR.yaml');
const newTestData = [
{ file: 'SqlBeansKamelet.yaml', dataSource: '#bean:{{postgreSqlSource}}' },
{ file: 'SqlBeansCR.yaml', dataSource: '#postgreSqlSource' },
];
newTestData.forEach((data) => {
it('Beans - select existing bean in node form config ' + data.file, () => {
cy.openSourceCode();
cy.uploadFixture('flows/' + data.file);

cy.openDesignPage();
cy.openStepConfigurationTab('sql');
cy.configureBeanReference('parameters.dataSource', 'mysqlPostgreSqlSource');
cy.openSourceCode();
cy.openDesignPage();
cy.openStepConfigurationTab('sql');
cy.configureBeanReference('parameters.dataSource', data.dataSource);
cy.openSourceCode();

// CHECK the bean update was reflected in the code editor
cy.checkCodeSpanLine('dataSource: "#mysqlPostgreSqlSource"');
});
// CHECK the bean update was reflected in the code editor
cy.checkCodeSpanLine('dataSource: "' + data.dataSource + '"');
});

it('Beans - unselect selected bean', () => {
cy.openSourceCode();
cy.uploadFixture('flows/SqlBeansCR.yaml');
it('Beans - unselect selected bean', () => {
cy.openSourceCode();
cy.uploadFixture('flows/' + data.file);

cy.openDesignPage();
cy.openStepConfigurationTab('sql');
cy.configureBeanReference('parameters.dataSource', 'mysqlPostgreSqlSource');
cy.openSourceCode();
cy.checkCodeSpanLine('dataSource: "#mysqlPostgreSqlSource"');
cy.openDesignPage();
cy.openStepConfigurationTab('sql');
cy.configureBeanReference('parameters.dataSource', data.dataSource);
cy.openSourceCode();
cy.checkCodeSpanLine('dataSource: "' + data.dataSource + '"');

cy.openDesignPage();
cy.openStepConfigurationTab('sql');
cy.deselectNodeBean('parameters.dataSource');
cy.openSourceCode();
cy.checkCodeSpanLine('dataSource: "#mysqlPostgreSqlSource"', 0);
cy.openDesignPage();
cy.openStepConfigurationTab('sql');
cy.deselectNodeBean('parameters.dataSource');
cy.openSourceCode();
cy.checkCodeSpanLine('dataSource: "' + data.dataSource + '"', 0);
});
});

// blocked by https://github.com/KaotoIO/kaoto-next/issues/558
it.skip('Beans - delete bean using the bean editor', () => {
cy.uploadFixture('flows/SqlBeansCR.yaml');
cy.openDesignPage();
cy.openStepConfigurationTab('sql');
cy.configureBeanReference('parameters.dataSource', 'mysqlPostgreSqlSource');
cy.configureBeanReference('parameters.dataSource', 'postgreSqlSource');

cy.openBeans();
// Remove the bean
cy.get('[data-testid="metadata-delete-1-btn"]').click();
cy.get('[data-testid="metadata-row-1"]').should('not.exist');
cy.openDesignPage();
cy.openStepConfigurationTab('sql');
cy.get(`div[data-fieldname="parameters.dataSource"] input[value="#mysqlPostgreSqlSource"]`).should('not.exist');
cy.get(`div[data-fieldname="parameters.dataSource"] input[value="#postgreSqlSource"]`).should('not.exist');
});
});
4 changes: 2 additions & 2 deletions packages/ui-tests/cypress/fixtures/flows/SqlBeansCR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
username: dbuser
password: dbpass
driver-class-name: com.mysql.jdbc.Driver
- name: mysqlPostgreSqlSource
type: io.kaoto.MysqlPostgreSqlSource
- name: postgreSqlSource
type: io.kaoto.PostgreSqlSource
properties:
port: "5432"
url: jdbc:postgresql://localhost/test
Expand Down
62 changes: 62 additions & 0 deletions packages/ui-tests/cypress/fixtures/flows/SqlBeansKamelet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
annotations:
camel.apache.org/catalog.version: main-SNAPSHOT
camel.apache.org/kamelet.group: Users
camel.apache.org/kamelet.icon: data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgNjAgNjAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDYwIDYwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxwYXRoIGQ9Ik00OC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software Foundation
labels:
camel.apache.org/kamelet.type: source
name: kamelet-3024
spec:
definition:
description: Produces periodic events about random users!
properties:
period:
default: 5000
description: The time interval between two events
title: Period
type: integer
title: kamelet-3024
type: object
dependencies:
- camel:timer
- camel:http
- camel:kamelet
template:
beans:
- name: mysqlDataSource
properties:
driver-class-name: com.mysql.jdbc.Driver
password: dbpass
port: "3306"
url: jdbc:mysql://localhost/test
username: dbuser
type: io.kaoto.MysqlDataSource
- name: postgreSqlSource
properties:
driver-class-name: org.postgresql.Driver
password: dbpass
port: "5432"
url: jdbc:postgresql://localhost/test
username: dbuser
type: io.kaoto.PostgreSqlSource
from:
steps:
- to:
id: to-2047
parameters:
dataSource: ""
uri: sql
- to: kamelet:sink
id: from-2814
parameters:
exceptionHandler: "#bean:{{test}}"
period: "{{period}}"
timerName: user
uri: timer
types:
out:
mediaType: application/json
2 changes: 1 addition & 1 deletion packages/ui-tests/cypress/support/next-commands/design.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Cypress.Commands.add('configureBeanReference', (inputName: string, value?: strin
cy.get(`[data-fieldname="${inputName}"]`).scrollIntoView();
cy.get(`[data-fieldname="${inputName}"] input`).click();
cy.get(`[id$="${value}"]`).click();
cy.get(`div[data-fieldname="${inputName}"] input[value="#${value}"]`).should('exist');
cy.get(`div[data-fieldname="${inputName}"] input[value="${value}"]`).should('exist');
});

Cypress.Commands.add('deselectNodeBean', (inputName: string) => {
Expand Down
Loading