You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2021/06/23 09:29:21 UTC
[incubator-streampipes] 01/02: [STREAMPIPES-380] Add cypress test
to install system
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch STREAMPIPES-380
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit e25ac3d0000baf615388222bcb5734323eceb306
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Wed Jun 23 11:00:07 2021 +0200
[STREAMPIPES-380] Add cypress test to install system
---
ui/cypress/README.md | 2 +-
.../installation/installation.ts} | 41 ++++++++++++----------
ui/cypress/support/general/dataCy.ts | 10 ++++--
ui/cypress/support/general/login.ts | 6 ++--
ui/cypress/support/utils/AdapterUtils.ts | 6 ++--
ui/cypress/support/utils/DataLakeUtils.ts | 4 +--
ui/cypress/support/utils/PipelineUtils.ts | 8 ++---
.../{general/dataCy.ts => utils/UserUtils.ts} | 16 ++-------
.../login/components/setup/setup.component.html | 5 +--
9 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/ui/cypress/README.md b/ui/cypress/README.md
index 0d3ab5e..99bf847 100644
--- a/ui/cypress/README.md
+++ b/ui/cypress/README.md
@@ -28,7 +28,7 @@ npm run test-e2e
**User**: test@streampipes.apache.org **Password**: test1234
->**Note:** This can be changed in **support/general/login.ts**
+>**Note:** This can be changed in **support/utils/UserUtils.ts**
>**Note:** The base URL can be configured in **cypress.json**
diff --git a/ui/cypress/support/general/login.ts b/ui/cypress/integration/installation/installation.ts
similarity index 52%
copy from ui/cypress/support/general/login.ts
copy to ui/cypress/integration/installation/installation.ts
index a6e709e..e5781d6 100644
--- a/ui/cypress/support/general/login.ts
+++ b/ui/cypress/integration/installation/installation.ts
@@ -16,25 +16,28 @@
*
*/
-declare global {
- namespace Cypress {
- interface Chainable {
- /**
- * Login into streampipes with standard test user
- * @example cy.login();
- */
- login: typeof login;
- }
- }
-}
+import { UserUtils } from '../../support/utils/UserUtils';
-export const login = () => {
- Cypress.Cookies.defaults({
- preserve: 'JSESSIONID'
- });
+describe('Install StreamPipes', () => {
+ it('Open Streampipes', () => {
+ cy.visit('#/login');
+ });
+
+ let isSetupPage: boolean;
+
+ it('Install StreamPipes', () => {
+ cy.url({ timeout: 60000 }).then(($route) => {
+ isSetupPage = ($route.endsWith('setup')) ? true : false;
+ if (isSetupPage) {
+ cy.get('input[name="email"]').type(UserUtils.testUserName);
+ cy.get('input[name="password"]').type(UserUtils.testUserPassword);
- cy.request('POST', '/streampipes-backend/api/v2/admin/login', {
- username: 'test@streampipes.apache.org',
- password: 'test1234'
+ cy.get('button').contains('Install').parent().click();
+
+ cy.dataCy('sp-button-finish-installation', { timeout: 240000 }).should('be.visible');
+ cy.dataCy('sp-button-finish-installation').click();
+ }
});
-};
+ });
+
+});
diff --git a/ui/cypress/support/general/dataCy.ts b/ui/cypress/support/general/dataCy.ts
index 0162ce3..7a2e98a 100644
--- a/ui/cypress/support/general/dataCy.ts
+++ b/ui/cypress/support/general/dataCy.ts
@@ -22,11 +22,15 @@ declare global {
/**
* Select cypress id's ([data-cy=...])
*/
- dataCy(value: string): Chainable<Element>;
+ dataCy(value: string, config?: any): Chainable<Element>;
}
}
}
-export const dataCy = (value) => {
- return cy.get(`[data-cy=${value}]`);
+export const dataCy = (value, config?) => {
+ if (config) {
+ return cy.get(`[data-cy=${value}]`, config);
+ } else {
+ return cy.get(`[data-cy=${value}]`);
+ }
};
diff --git a/ui/cypress/support/general/login.ts b/ui/cypress/support/general/login.ts
index a6e709e..d165242 100644
--- a/ui/cypress/support/general/login.ts
+++ b/ui/cypress/support/general/login.ts
@@ -16,6 +16,8 @@
*
*/
+import { UserUtils } from '../utils/UserUtils';
+
declare global {
namespace Cypress {
interface Chainable {
@@ -34,7 +36,7 @@ export const login = () => {
});
cy.request('POST', '/streampipes-backend/api/v2/admin/login', {
- username: 'test@streampipes.apache.org',
- password: 'test1234'
+ username: UserUtils.testUserName,
+ password: UserUtils.testUserPassword
});
};
diff --git a/ui/cypress/support/utils/AdapterUtils.ts b/ui/cypress/support/utils/AdapterUtils.ts
index c244ab4..b2e2cbf 100644
--- a/ui/cypress/support/utils/AdapterUtils.ts
+++ b/ui/cypress/support/utils/AdapterUtils.ts
@@ -156,7 +156,7 @@ export class AdapterUtils {
private static finishEventSchemaConfiguration() {
it('Click next', () => {
- cy.get('[data-cy=sp-connect-schema-editor]', { timeout: 10000 }).should('be.visible');
+ cy.dataCy('sp-connect-schema-editor', { timeout: 10000 }).should('be.visible');
cy.get('#event-schema-next-button').click();
});
}
@@ -171,12 +171,12 @@ export class AdapterUtils {
private static startAdapter(name , successElement) {
it('Set adapter name', () => {
- cy.get('[data-cy=sp-adapter-name]').type(name);
+ cy.dataCy('sp-adapter-name').type(name);
});
it('Start adapter', () => {
cy.get('#button-startAdapter').click();
- cy.get('[data-cy=' + successElement + ']', { timeout: 10000 }).should('be.visible');
+ cy.dataCy(successElement , { timeout: 10000 }).should('be.visible');
});
it('Close adapter preview', () => {
diff --git a/ui/cypress/support/utils/DataLakeUtils.ts b/ui/cypress/support/utils/DataLakeUtils.ts
index 480120e..a969cc7 100644
--- a/ui/cypress/support/utils/DataLakeUtils.ts
+++ b/ui/cypress/support/utils/DataLakeUtils.ts
@@ -18,14 +18,14 @@
// tslint:disable-next-line:no-implicit-dependencies
import * as CSV from 'csv-string';
+import { UserUtils } from './UserUtils';
export class DataLakeUtils {
public static checkResults(dataLakeIndex: string, fileRoute: string) {
it('Validate result in datalake', () => {
- const streamPipesUser = 'riemer@fzi.de';
- cy.request('GET', '/streampipes-backend/api/v3/users/' + streamPipesUser + '/datalake/data/' + dataLakeIndex + '/download?format=csv',
+ cy.request('GET', '/streampipes-backend/api/v3/users/' + UserUtils.testUserName + '/datalake/data/' + dataLakeIndex + '/download?format=csv',
{'content-type': 'application/octet-stream'}).should((response) => {
const expectedResultString = response.body;
cy.readFile(fileRoute).then((actualResultString) => {
diff --git a/ui/cypress/support/utils/PipelineUtils.ts b/ui/cypress/support/utils/PipelineUtils.ts
index 2f2178a..5c52f07 100644
--- a/ui/cypress/support/utils/PipelineUtils.ts
+++ b/ui/cypress/support/utils/PipelineUtils.ts
@@ -59,7 +59,7 @@ export class PipelineUtils {
private static configurePipeline(pipelineInput: PipelineInput) {
it('Select processor', () => {
- cy.get('[data-cy=sp-possible-elements-' + pipelineInput.dataSource + ']', { timeout: 10000 }).click();
+ cy.dataCy('sp-possible-elements-' + pipelineInput.dataSource, { timeout: 10000 }).click();
cy.dataCy('sp-compatible-elements-' + pipelineInput.processingElement.name).click();
});
@@ -88,8 +88,8 @@ export class PipelineUtils {
cy.dataCy('sp-editor-pipeline-name').type(pipelineInput.pipelineName);
cy.dataCy('sp-editor-checkbox-start-immediately').children().click();
cy.dataCy('sp-editor-save').click();
- cy.get('[data-cy=sp-pipeline-started-dialog]', { timeout: 10000 }).should('be.visible');
- cy.get('[data-cy=sp-pipeline-dialog-close]', { timeout: 10000 }).click();
+ cy.dataCy('sp-pipeline-started-dialog', { timeout: 10000 }).should('be.visible');
+ cy.dataCy('sp-pipeline-dialog-close', { timeout: 10000 }).click();
});
}
@@ -99,7 +99,7 @@ export class PipelineUtils {
cy.dataCy('delete').should('have.length', 1);
cy.dataCy('delete').click();
cy.dataCy('sp-pipeline-stop-and-delete').click();
- cy.get('[data-cy=delete]', { timeout: 10000 }).should('have.length', 0);
+ cy.dataCy('delete', { timeout: 10000 }).should('have.length', 0);
});
}
}
diff --git a/ui/cypress/support/general/dataCy.ts b/ui/cypress/support/utils/UserUtils.ts
similarity index 72%
copy from ui/cypress/support/general/dataCy.ts
copy to ui/cypress/support/utils/UserUtils.ts
index 0162ce3..d22a751 100644
--- a/ui/cypress/support/general/dataCy.ts
+++ b/ui/cypress/support/utils/UserUtils.ts
@@ -16,17 +16,7 @@
*
*/
-declare global {
- namespace Cypress {
- interface Chainable {
- /**
- * Select cypress id's ([data-cy=...])
- */
- dataCy(value: string): Chainable<Element>;
- }
- }
+export class UserUtils {
+ public static testUserName = 'test@streampipes.apache.org';
+ public static testUserPassword = 'test1234';
}
-
-export const dataCy = (value) => {
- return cy.get(`[data-cy=${value}]`);
-};
diff --git a/ui/src/app/login/components/setup/setup.component.html b/ui/src/app/login/components/setup/setup.component.html
index efef941..9c6dcb7 100644
--- a/ui/src/app/login/components/setup/setup.component.html
+++ b/ui/src/app/login/components/setup/setup.component.html
@@ -74,13 +74,14 @@
<mat-divider></mat-divider>
<div fxLayout="row" fxLayoutAlign="center center">
<div fxLayout="row" style="margin-top: 10px; margin-bottom: 10px;">
- <button mat-button mat-raised-button color="primary"
+ <button mat-button mat-raised-button color="primary"
[disabled]="!(setupForm.valid) || loading || installationFinished"
(click)="configure(0)" *ngIf="!installationFinished">
<span>{{!installationRunning ? 'Install' : 'Installing...'}}</span>
</button>
<button mat-button mat-raised-button color="primary"
- (click)="openLoginPage()" *ngIf="installationFinished">
+ (click)="openLoginPage()" *ngIf="installationFinished"
+ data-cy="sp-button-finish-installation">
<mat-icon>arrow_forward</mat-icon>
<span>Go to login page</span>
</button>