forked from hyperledger-archives/composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable protractor testing of create and login to BusNet (hyperledger-…
- Loading branch information
Showing
13 changed files
with
212 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { browser, element, by } from 'protractor'; | ||
import { ExpectedConditions } from 'protractor'; | ||
|
||
import { OperationsHelper } from '../utils/operations-helper'; | ||
import { dragDropFile } from '../utils/fileUtils'; | ||
|
||
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); | ||
} | ||
|
||
static waitToLoadDeployBasisOptions() { | ||
return browser.wait(OperationsHelper.elementsPresent(element(by.css('.sample-network-list-container')).all(by.css('.sample-network-list-item')), baseTiles.length), 10000); | ||
} | ||
|
||
// Wait for disappear | ||
static waitToDisappear() { | ||
return browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.choose-network'))), 5000); | ||
} | ||
|
||
// Name the network | ||
static nameBusinessNetwork(name: string) { | ||
return element(by.id('import-businessNetworkName')).sendKeys(name); | ||
} | ||
|
||
// Deploy selected Tile option from Base tiles | ||
static selectDeployBasisOption(importOption: string) { | ||
// Wait for poplation of sample-network-list-item(s) | ||
this.retrieveBaseTileOptions() | ||
.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); | ||
}); | ||
} | ||
|
||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { browser, element, by, ElementFinder, WebElement } from 'protractor'; | ||
import { ExpectedConditions } from 'protractor'; | ||
|
||
import { OperationsHelper } from '../utils/operations-helper'; | ||
|
||
export class Login { | ||
|
||
static deployNewToProfile(profile: string) { | ||
// Wish to find named connection profile and then select/click the 'empty' deploy card | ||
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.connection-profile'))), 10000) | ||
.then(() => { | ||
return element.all(by.css('.connection-profile')).filter((item) => { | ||
return item.element(by.css('.connection-profile-title')).getText() | ||
.then((text) => { if (text.includes(profile)) { return true; } }); | ||
}) | ||
.then((matchedItems: [ElementFinder]) => { | ||
if(matchedItems.length >1) { | ||
return Promise.reject('Multiple conection profile name match occured'); | ||
} else { | ||
return matchedItems[0].element(by.css('.connection-profile-card')); | ||
} | ||
}) | ||
.then((deployCard: ElementFinder) => { | ||
return OperationsHelper.click(deployCard); | ||
}); | ||
}); | ||
} | ||
|
||
// Connect to Playground via named ID Card under named connectino profile | ||
static connectViaIdCard(profile: string, networkName: string) { | ||
return browser.wait(ExpectedConditions.visibilityOf(element(by.css('.connection-profile'))), 10000) | ||
.then(() => { | ||
// Retrieve components under named connection-profile | ||
return element.all(by.css('.connection-profile')).filter((item) => { | ||
return item.element(by.css('.connection-profile-title')).getText() | ||
.then((text) => { if (text.includes(profile)) { return true; } }); | ||
}) | ||
.then((matchedItems) => { | ||
if(matchedItems.length >1) { | ||
return Promise.reject('Multiple conection profile name match occured'); | ||
} else { | ||
return matchedItems[0]; | ||
} | ||
}) | ||
.then((matchedItem) => { | ||
return matchedItem.all(by.css('.identity-card')).filter((item) => { | ||
return item.element(by.css('.business-network-details')).getText() | ||
.then((text) => { if (text.includes(networkName)) { return true; } }); | ||
}) | ||
}) | ||
.then((cards) => { | ||
let connect = cards[0].getWebElement().findElement(by.css('.connect')); | ||
browser.wait(() => { return browser.isElementPresent(connect); }, 5000); | ||
connect.click(); | ||
}) | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/composer-playground/e2e/specs/login-define.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { browser, element, by } from 'protractor'; | ||
import { ExpectedConditions } from 'protractor'; | ||
import { OperationsHelper } from '../utils/operations-helper'; | ||
import { Login } from '../component/login'; | ||
import { Deploy } from '../component/deploy'; | ||
import { Editor } from '../component/editor'; | ||
|
||
import * as chai from 'chai'; | ||
import * as fs from 'fs'; | ||
import * as JSZip from 'jszip'; | ||
|
||
let expect = chai.expect; | ||
|
||
describe('Login Define', (() => { | ||
|
||
// Navigate to Playground base page and move past welcome splash | ||
beforeAll(() => { | ||
// Important angular configuration and intial step passage to reach login | ||
browser.waitForAngularEnabled(false); | ||
OperationsHelper.navigatePastWelcome(); | ||
}); | ||
|
||
afterAll(() => { | ||
browser.waitForAngularEnabled(true); | ||
browser.executeScript('window.sessionStorage.clear();'); | ||
browser.executeScript('window.localStorage.clear();'); | ||
}); | ||
|
||
describe('Create BusinessNetwork', (() =>{ | ||
it('should enable default BNetwork deploy on named connection profile', (() => { | ||
|
||
let networkName = 'test-network'; | ||
let profile = 'Web Browser'; | ||
|
||
// Click to deploy on desired profile | ||
Login.deployNewToProfile(profile) | ||
|
||
// Deploy item should appear | ||
Deploy.waitToAppear(); | ||
Deploy.waitToLoadDeployBasisOptions(); | ||
|
||
// Name the network and base it on empty network | ||
Deploy.nameBusinessNetwork(networkName); | ||
Deploy.selectDeployBasisOption('empty-business-network'); | ||
|
||
// Deploy | ||
Deploy.clickDeploy(); | ||
|
||
// Should disappear and return to login page | ||
Deploy.waitToDisappear(); | ||
|
||
// Should now have an ID Card with the business network name defined above | ||
Login.connectViaIdCard(profile, networkName); | ||
|
||
// Should now be on main editor page for the business network | ||
Editor.waitToAppear(); | ||
|
||
// Should have the correct named busnet once loaded | ||
Editor.waitForProjectFilesToLoad(); | ||
Editor.retrieveDeployedPackageName() | ||
.then((packageName) => { | ||
expect(packageName).to.be.equal(networkName); | ||
}); | ||
|
||
})); | ||
})); | ||
|
||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/composer-playground/src/app/login/login.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters