Skip to content

Commit

Permalink
Add getting started sample card (hyperledger-archives#2281)
Browse files Browse the repository at this point in the history
Added a getting started sample card
Updated my wallet to business network card
Changed logout to my business networks
updated all places refering to id cards
updated coverage check

contributes to hyperledger/composer#2269
Signed-off-by: Caroline Church <[email protected]>
cazfletch authored Oct 10, 2017
1 parent 50eecb1 commit b5e3d92
Showing 30 changed files with 567 additions and 240 deletions.
6 changes: 3 additions & 3 deletions packages/composer-playground/.istanbul.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ instrumentation:
- "docker/*"
check:
global:
statements: 99
branches: 96.3
statements: 99.4
branches: 96.45
functions: 98.8
lines: 99.3
lines: 99.4
23 changes: 12 additions & 11 deletions packages/composer-playground/e2e/component/add-file.ts
Original file line number Diff line number Diff line change
@@ -3,30 +3,31 @@ import { ExpectedConditions } from 'protractor';

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

export class AddFile {

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

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

// Cancel Add
static clickCancelAdd() {
browser.wait(ExpectedConditions.visibilityOf(element(by.id('add-file_cancel'))), 5000);
browser.wait(ExpectedConditions.visibilityOf(element(by.id('add-file_cancel'))), Constants.shortWait);
return OperationsHelper.click(element(by.id('add-file_cancel')));
}

// Exit Add
static clickExitAdd() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), Constants.shortWait)
.then(() => {
return OperationsHelper.click(element(by.id('add-file_exit')));
});
@@ -35,7 +36,7 @@ export class AddFile {
// Confirm Add
static clickConfirmAdd() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), Constants.shortWait)
.then(() => {
return OperationsHelper.click(element(by.id('add-file_confirm')));
});
@@ -44,7 +45,7 @@ export class AddFile {
// Select Script file via Radio Button
static selectAddScriptViaRadioOption() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), Constants.shortWait)
.then(() => {
return OperationsHelper.click(element(by.css('[for="file-type-js"]')));
});
@@ -53,7 +54,7 @@ export class AddFile {
// Select Model file via Radio Button
static selectAddModelViaRadioOption() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), Constants.shortWait)
.then(() => {
return OperationsHelper.click(element(by.css('[for="file-type-cto"]')));
});
@@ -62,7 +63,7 @@ export class AddFile {
// Select ACL file via Radio Button
static selectAddAclViaRadioOption() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), Constants.shortWait)
.then(() => {
return OperationsHelper.click(element(by.css('[for="file-type-acl"]')));
});
@@ -71,7 +72,7 @@ export class AddFile {
// Select Query file via Radio Button
static selectAddQueryViaRadioOption() {
// AddFile modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), Constants.shortWait)
.then(() => {
return OperationsHelper.click(element(by.css('[for="file-type-qry"]')));
});
@@ -80,7 +81,7 @@ export class AddFile {
// Select BND from BNA file drop
static selectFromFile(filePath: string) {
// Import modal should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), 10000)
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.import'))), Constants.shortWait)
.then(() => {
let inputFileElement = element(by.id('file-importer_input'));
dragDropFile(inputFileElement, filePath);
17 changes: 17 additions & 0 deletions packages/composer-playground/e2e/component/alert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { Constants } from '../utils/constants';

export class BusyAlert {

// wait to disappear
static waitToAppear() {
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.busy-text'))), Constants.shortWait);
}

// wait to disappear
static waitToDisappear() {
return browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.busy-text'))), Constants.shortWait);
}

}
30 changes: 13 additions & 17 deletions packages/composer-playground/e2e/component/deploy.ts
Original file line number Diff line number Diff line change
@@ -3,28 +3,29 @@ import { ExpectedConditions } from 'protractor';

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

let baseTiles = ['basic-sample-network', 'empty-business-network', 'drag-drop'];

export class Deploy {

// Wait for appear
static waitToAppear() {
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.choose-network'))), 5000);
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.choose-network'))), Constants.shortWait);
}

static waitToLoadDeployBasisOptions() {
return browser.wait(OperationsHelper.elementsPresent(element(by.css('.sample-network-list-container')).all(by.css('.sample-network-list-item')), baseTiles.length), 10000);
return browser.wait(OperationsHelper.elementsPresent(element(by.css('.sample-network-list-container')).all(by.css('.sample-network-list-item')), baseTiles.length), Constants.shortWait);
}

// Wait for disappear
static waitToDisappear() {
return browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.choose-network'))), 5000);
return browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.choose-network'))), Constants.shortWait);
}

// Name the network
static nameBusinessNetwork(name: string) {
return element(by.id('import-businessNetworkName')).sendKeys(name);
return element(by.id('import-businessNetworkName')).sendKeys(name);
}

// Deploy selected Tile option from Base tiles
@@ -34,28 +35,23 @@ export class Deploy {
.then((options) => {
// Figure out which one we want
let index = baseTiles.findIndex((tile) => tile === importOption);
let optionElement = options[index].getWebElement();
// Scroll into view
browser.executeScript('arguments[0].scrollIntoView();', optionElement);

// Click
optionElement.click();

// Confirm
let confirmElement = element(by.id('import_confirm'));
browser.executeScript('arguments[0].scrollIntoView();', confirmElement);
return OperationsHelper.click(confirmElement);
return options[index].getWebElement();
})
.then((option) => {
// Scroll into view and click
browser.wait(browser.executeScript('arguments[0].scrollIntoView();', option), Constants.shortWait);
return option.click();
});
}

static retrieveBaseTileOptions() {
this.waitToLoadDeployBasisOptions();
return element(by.css('.sample-network-list-container')).all(by.css('.sample-network-list-item'));

}

// Deploy
static clickDeploy() {
let deployElement = element(by.id('import_confirm'));
return OperationsHelper.click(deployElement);
return OperationsHelper.click(element(by.id('import_confirm')));
}
}
5 changes: 3 additions & 2 deletions packages/composer-playground/e2e/component/editor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { OperationsHelper } from '../utils/operations-helper';
import { Constants } from '../utils/constants';

let scrollMe = (target) => {
target.scrollIntoView(true);
@@ -10,7 +11,7 @@ export class Editor {

// Wait to appear
static waitToAppear() {
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.main-view'))), 5000);
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.main-view'))), Constants.shortWait);
}

// Click AddFile button
@@ -72,7 +73,7 @@ export class Editor {
static retrieveNavigatorActiveFiles() {
return OperationsHelper.retriveMatchingElementsByCSS('.files', '.active', 0)
.map((elm) => { browser.executeScript(scrollMe, elm);
browser.wait(ExpectedConditions.visibilityOf(elm), 5000);
browser.wait(ExpectedConditions.visibilityOf(elm), Constants.shortWait);
return elm.getText(); });
}

5 changes: 3 additions & 2 deletions packages/composer-playground/e2e/component/error-alert.ts
Original file line number Diff line number Diff line change
@@ -3,18 +3,19 @@ import { ExpectedConditions } from 'protractor';

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

export class ErrorAlert {

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

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

}
22 changes: 11 additions & 11 deletions packages/composer-playground/e2e/component/import.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';
import { dragDropFile } from '../utils/fileUtils';
import { OperationsHelper } from '../utils/operations-helper';
import { Constants } from '../utils/constants';

// Initialise known tile orderings
let baseTiles = ['basic-sample-network', 'empty-business-network', 'drag-drop'];
@@ -15,19 +16,19 @@ export class Import {
// Select BND from BNA file drop
static selectBusinessNetworkDefinitionFromFile(filePath: string) {
// Import slide out should be present
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.drawer'))), 10000)
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.drawer'))), Constants.longWait)
.then(() => {
// must have file drag drop visible
OperationsHelper.retriveMatchingElementsByCSS('.sample-network-list-container', '.sample-network-list-item', 3);
return browser.wait(ExpectedConditions.visibilityOf(element(by.id('file-importer_input'))), 10000);
return browser.wait(ExpectedConditions.visibilityOf(element(by.id('file-importer_input'))), Constants.longWait);
})
.then(() => {
let inputFileElement = element(by.id('file-importer_input'));
return dragDropFile(inputFileElement, filePath);
})
.then(() => {
let importElement = element(by.id('import_confirm'));
return browser.wait(ExpectedConditions.elementToBeClickable(importElement), 10000)
return browser.wait(ExpectedConditions.elementToBeClickable(importElement), Constants.longWait)
.then(() => {
return importElement.click();
});
@@ -90,7 +91,7 @@ export class Import {
// Confirm import
static confirmImport() {
// Import drawer should be present and populated with chosen-network div
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.chosen-network'))), 10000);
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.chosen-network'))), Constants.longWait);

// Wait for poplation of sample-network-list-item(s)
OperationsHelper.retriveMatchingElementsByCSS('.sample-network-list-container', '.sample-network-list-item', 3)
@@ -104,32 +105,32 @@ export class Import {
// Cancel import
static cancelImport() {
// Import drawer should be present, button should be visible within chosen-network div
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.chosen-network'))), 5000);
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.chosen-network'))), Constants.longWait);

// Wait for poplation of sample-network-list-item(s)
OperationsHelper.retriveMatchingElementsByCSS('.sample-network-list-container', '.sample-network-list-item', 3)
.then(() => {
let cancelElement = element(by.id('import_cancel'));
browser.executeScript('arguments[0].scrollIntoView();', cancelElement.getWebElement());
OperationsHelper.click(cancelElement);
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.drawer'))), 5000);
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.drawer'))), Constants.longWait);
});
}

static waitToAppear() {
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.drawer'))), 5000);
browser.wait(ExpectedConditions.visibilityOf(element(by.css('.drawer'))), Constants.longWait);
}

static waitToDisappear() {
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.drawer'))), 5000);
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.drawer'))), Constants.longWait);
}

static waitToLoadBaseOptions() {
browser.wait(OperationsHelper.elementsPresent(element(by.id('base-samples')).all(by.css('.sample-network-list-item')), baseTiles.length), 20000);
browser.wait(OperationsHelper.elementsPresent(element(by.id('base-samples')).all(by.css('.sample-network-list-item')), baseTiles.length), Constants.mlongwait);
}

static waitToLoadNpmOptions() {
browser.wait(OperationsHelper.elementsPresent(element(by.id('npm-samples')).all(by.css('.sample-network-list-item')), npmTiles.length), 20000);
browser.wait(OperationsHelper.elementsPresent(element(by.id('npm-samples')).all(by.css('.sample-network-list-item')), npmTiles.length), Constants.mlongwait);
}

static retrieveBaseTileOptions() {
@@ -142,5 +143,4 @@ export class Import {
return element(by.id('npm-samples')).all(by.css('.sample-network-list-item'));
}


}
Loading

0 comments on commit b5e3d92

Please sign in to comment.