Skip to content

Commit

Permalink
Stabilise and Activate Protractor tests (hyperledger-archives#1625)
Browse files Browse the repository at this point in the history
* stabilise protractor

* modify return code conditioning

* removed git cached download item
  • Loading branch information
nklincoln authored and Simon Stone committed Jul 20, 2017
1 parent b3e9951 commit 6da2143
Show file tree
Hide file tree
Showing 19 changed files with 856 additions and 696 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ packages/composer-runtime-hlfv1/vendor/gopkg.in/sourcemap.v1/
packages/composer-website/installers/fabric-dev-servers.zip
packages/composer-website/installers/hlfv*/fabric-dev-servers/

packages/composer-playground/e2e/downloads/*
packages/composer-playground/e2e/downloads/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ matrix:
- env: SYSTEST=embedded,proxy,web FC_TASK=systest
- env: SYSTEST=hlf FC_TASK=systest
- env: SYSTEST=hlfv1_tls FC_TASK=systest
# - env: SYSTEST=e2e FC_TASK=systest
- env: SYSTEST=e2e FC_TASK=systest
dist: trusty
addons:
apt:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,63 +1,61 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';

import { dragDropFile } from '../utils/fileUtils.ts';
import { OperationsHelper } from '../utils/operations-helper';
import { dragDropFile } from '../utils/fileUtils';

export class AddFileModalHelper {
export class AddFile {

// Wait for modal to appear
static waitForAddFileModalToAppear() {
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000);
static waitToAppear() {
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 5000);
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 5000);
}

// Wait for modal to disappear
static waitToDisappear() {
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.import'))), 5000);
}

// Cancel Add
static cancelAdd() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
.then(() => {
return element(by.id('add-file_cancel')).click();
});
static clickCancelAdd() {
browser.wait(ExpectedConditions.visibilityOf(element(by.id('add-file_cancel'))), 5000);
return OperationsHelper.click(element(by.id('add-file_cancel')));
}

// Exit Add
static exitAdd() {
static clickExitAdd() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
.then(() => {
return element(by.id('add-file_exit')).click();
return OperationsHelper.click(element(by.id('add-file_exit')));
});
}

// Confirm Add
static confirmAdd() {
static clickConfirmAdd() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
.then(() => {
let addElement = element(by.id('add-file_confirm'));
browser.wait(ExpectedConditions.elementToBeClickable(addElement), 10000);
return addElement.click();
return OperationsHelper.click(element(by.id('add-file_confirm')));
});
}

// Select Script file via Radio Button
static selectScriptRadioOption() {
static selectAddScriptViaRadioOption() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
.then(() => {
let selectElement = element(by.css('[for="file-type-js"]'));
browser.wait(ExpectedConditions.elementToBeClickable(selectElement), 10000);
return selectElement.click();
return OperationsHelper.click(element(by.css('[for="file-type-js"]')));
});
}

// Select Model file via Radio Button
static selectModelRadioOption() {
static selectAddModelViaRadioOption() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
.then(() => {
let selectElement = element(by.css('[for="file-type-cto"]'));
browser.wait(ExpectedConditions.elementToBeClickable(selectElement), 10000);
return selectElement.click();
return OperationsHelper.click(element(by.css('[for="file-type-cto"]')));
});
}

Expand All @@ -67,10 +65,8 @@ export class AddFileModalHelper {
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
.then(() => {
let inputFileElement = element(by.id('file-importer_input'));
let importElement = element(by.id('add-file_confirm'));
dragDropFile(inputFileElement, filePath);
browser.wait(ExpectedConditions.elementToBeClickable(importElement), 10000);
return importElement.click();
return true;
});
}

Expand Down
14 changes: 14 additions & 0 deletions packages/composer-playground/e2e/component/editor-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { browser, element, by } from 'protractor';
import { OperationsHelper } from '../utils/operations-helper';

export class EditorFile {

static retrieveEditorCodeMirrorText() {
return OperationsHelper.retriveTextFromElement(element(by.id('editor-file_CodeMirror')));
}

static retrieveEditorText() {
return OperationsHelper.retriveTextFromElement(element(by.css('.readme')));
}

}
71 changes: 71 additions & 0 deletions packages/composer-playground/e2e/component/editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { OperationsHelper } from '../utils/operations-helper';

let scrollMe = (target) => {
target.scrollIntoView(true);
};

export class Editor {

// Click AddFile button
static clickAddFile() {
return OperationsHelper.click(element(by.id('editor_addfile')));
}

// Click Export button
static clickExportBND() {
return OperationsHelper.click(element(by.id('editor_export')));
}

// Click deploy button
static clickDeployBND() {
return OperationsHelper.click(element(by.id('editor_deploy')));
}

// Click import button
static clickImportBND() {
return OperationsHelper.click(element(by.id('editor_import')));
}

// RETRIEVE ACTIONS
// Retrieve Editor Side Navigation FileNames
static retrieveNavigatorFileNames() {
// Due to scroll bar, need to scroll element into view in order to inspect text
return OperationsHelper.retriveMatchingElementsByCSS('.side-bar-nav', '.flex-container')
.map((elm) => { browser.executeScript(scrollMe, elm);
browser.wait(ExpectedConditions.visibilityOf(elm), 5000);
return elm.getText(); });
}

// Retrieve Editor Side Navigation File Action buttons (Add/Deploy)
static retrieveNavigatorFileActionButtons() {
return OperationsHelper.retriveMatchingElementsByCSS('.files', '[type="button"]')
.map((elm) => { return {text: elm.getText(), enabled: elm.isEnabled()}; });
}

// Retrieve Editor Side Navigation Action Buttons
static retrieveBusinessArchiveActionButtons() {
return OperationsHelper.retriveMatchingElementsByCSS('.actions', '[type="button"]')
.map((elm) => { return {text: elm.getText(), enabled: elm.isEnabled()}; });
}

// Retrieve Editor Side Navigation File Elements
static retrieveNavigatorFileElements() {
return OperationsHelper.retriveMatchingElementsByCSS('.side-bar-nav', '.flex-container');
}

// Retrieve Editor Deployed Package Name, visible only when readme is selected
static retrieveDeployedPackageName() {
return OperationsHelper.retriveTextFromElement(element(by.id('editor_deployedPackageName')));
}

// Retrieve current 'active' file from navigator
static retrieveNavigatorActiveFile() {
return OperationsHelper.retriveMatchingElementsByCSS('.files', '.active')
.map((elm) => { browser.executeScript(scrollMe, elm);
browser.wait(ExpectedConditions.visibilityOf(elm), 5000);
return elm.getText(); });
}

}
20 changes: 20 additions & 0 deletions packages/composer-playground/e2e/component/error-alert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';

import { OperationsHelper } from '../utils/operations-helper';
import { dragDropFile } from '../utils/fileUtils';

export class ErrorAlert {

// Close
static clickCloseError() {
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.error'))), 5000);
return OperationsHelper.click(element(by.id('error_close')));
}

// wait to disappear
static waitToDisappear() {
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.error'))), 5000);
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { dragDropFile } from '../utils/fileUtils.ts';
import { dragDropFile } from '../utils/fileUtils';
import { OperationsHelper } from '../utils/operations-helper';

export class ImportModalHelper {
export class Import {

// Select BND from BNA file drop
static selectBusinessNetworkDefinitionFromFile(filePath: string) {
Expand All @@ -26,20 +27,23 @@ export class ImportModalHelper {
// Import modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
.then(() => {
return element(by.id('import_confirm')).click();
return OperationsHelper.click(element(by.id('import_confirm')));
});
}

// Cancel import
static cancelImport() {
// Import modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
.then(() => {
return element(by.id('import_cancel')).click();
});
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 5000);
OperationsHelper.click(element(by.id('import_cancel')));
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.import'))), 5000);
}

static waitForImportModalToAppear() {
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000);
static waitToAppear() {
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 5000);
}

static waitToDisappear() {
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.import'))), 5000);
}
}
21 changes: 21 additions & 0 deletions packages/composer-playground/e2e/component/replace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { OperationsHelper } from '../utils/operations-helper';

export class Replace {

// Cancel replace
static cancelReplace() {
// Replace modal should be present
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.replace'))), 5000);
OperationsHelper.click(element(by.id('replace_cancel')));
}

// Confirm Replace
static confirmReplace() {
// Replace modal should be present
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.replace'))), 5000);
OperationsHelper.click(element(by.id('replace_confirm')));
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.replace'))), 5000);
}
}
6 changes: 3 additions & 3 deletions packages/composer-playground/e2e/data/files/importQuery.qry
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Import query file
*/

query Q1 {
description: "Select all drivers"
description: "Select all SampleAsset"
statement: SELECT org.acme.sample.SampleAsset
}
}
Loading

0 comments on commit 6da2143

Please sign in to comment.