Skip to content

Commit

Permalink
Add version editor to playground (hyperledger-archives#3671)
Browse files Browse the repository at this point in the history
Simplifiy the process of editing/updating business network versions
in the Playground editor. Versions can now be edited without opening
the package.json file, and versions are incremented automatically when
changes are deployed

Also includes version validation

Contributes to #3241

Signed-off-by: James Taylor <[email protected]>
  • Loading branch information
jt-nti authored Mar 23, 2018
1 parent dc73cfe commit bd0f224
Show file tree
Hide file tree
Showing 22 changed files with 940 additions and 628 deletions.
12 changes: 6 additions & 6 deletions packages/composer-playground/e2e/component/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ export class Editor {
return OperationsHelper.retrieveTextFromElement(elm); });
}

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

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

Expand Down
4 changes: 4 additions & 0 deletions packages/composer-playground/e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ export class Constants {
static readonly fabricBaseDir = path.join(__dirname, 'fabric');
static readonly fabricConfigDir = path.join(Constants.fabricBaseDir, 'hlfv1');
static readonly peerAdminCardName = 'TestPeerAdmin.card';

static readonly addFileActionLabel = 'Add a file...';
static readonly exportActionLabel = 'Export';
static readonly deployButtonLabel = 'Deploy changes';
}
148 changes: 64 additions & 84 deletions packages/composer-playground/e2e/specs/editor-define.spec.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ let expect = chai.expect;

describe('Playground Tutorial Define', (() => {

const deployButtonLabel = Constants.deployButtonLabel;

let baseTiles: Array<string> = null;
let npmTiles: Array<string> = null;
let sampleOptions;
Expand Down Expand Up @@ -114,11 +116,10 @@ describe('Playground Tutorial Define', (() => {
filelist.forEach((file) => {
expect(file).to.be.oneOf(expectedFiles);
});
return Editor.retrieveNavigatorFileActionButtons()
return Editor.retrieveUpdateBusinessNetworkButtons()
.then((buttonlist: any) => {
expect(buttonlist).to.be.an('array').lengthOf(2);
expect(buttonlist[0]).to.deep.equal({ text: '+ Add a file...', enabled: true });
expect(buttonlist[1]).to.deep.equal({ text: 'Update', enabled: false });
expect(buttonlist[1]).to.deep.equal({ text: deployButtonLabel, enabled: true });
});
});
})
Expand Down Expand Up @@ -148,12 +149,11 @@ describe('Playground Tutorial Define', (() => {
.then((text) => {
let lines = text.toString().split(/\r\n|\n/);
expect(lines.map((e) => { return e.trim(); })).to.deep.equal(modelFileCode.split(/\r\n|\n/).map((e) => { return e.trim(); })); // Use trim to handle that codemirror autotabs so file is formatted differently
return Editor.retrieveNavigatorFileActionButtons();
return Editor.retrieveUpdateBusinessNetworkButtons();
})
.then((buttonlist: any) => {
expect(buttonlist).to.be.an('array').lengthOf(2);
expect(buttonlist[0]).to.deep.equal({ text: '+ Add a file...', enabled: true });
expect(buttonlist[1]).to.deep.equal({ text: 'Update', enabled: true });
expect(buttonlist[1]).to.deep.equal({ text: deployButtonLabel, enabled: true });
})
.catch((err) => {
fail(err);
Expand Down Expand Up @@ -210,11 +210,10 @@ describe('Playground Tutorial Define', (() => {
expect(lines.map((e) => { return e.trim(); })).to.deep.equal(scriptFileCode.split(/\r\n|\n/).map((e) => { return e.trim(); })); // Use trim to handle that codemirror autotabs so file is formatted differently
});

Editor.retrieveNavigatorFileActionButtons()
Editor.retrieveUpdateBusinessNetworkButtons()
.then((buttonlist: any) => {
expect(buttonlist).to.be.an('array').lengthOf(2);
expect(buttonlist[0]).to.deep.equal({ text: '+ Add a file...', enabled: true });
expect(buttonlist[1]).to.deep.equal({ text: 'Update', enabled: true });
expect(buttonlist[1]).to.deep.equal({ text: deployButtonLabel, enabled: true });
});
})
.catch((err) => {
Expand Down
Loading

0 comments on commit bd0f224

Please sign in to comment.