Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/composer-playground/e2e/tests/editor-define.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import { dragDropFile, waitForFileToExist, retrieveZipContentList } from '../uti

import * as chai from 'chai';
import * as fs from 'fs';
import * as JSZip from 'jszip';

let should = chai.should();

describe('Editor Define', (() => {

// Navigate to Editor base page and move past welcome splash
beforeAll(() => {
OperationsHelper.navigatePastWelcome();
OperationsHelper.navigatePastWelcomeAndLogin();
});

describe('On initialise', (() => {
Expand Down Expand Up @@ -183,7 +182,7 @@ describe('Editor Define', (() => {
// ExportBND appears to kick off processes that cause timeout in protractor
// -current work around is to refresh the page before continuing tests
// -this was previously at the start as a beforeEach, but consumes time
OperationsHelper.navigatePastWelcome();
OperationsHelper.navigatePastWelcomeAndLogin();
});
}));
}));
Expand Down Expand Up @@ -256,7 +255,7 @@ describe('Editor Define', (() => {
});
}));

it('should enable the addition of a script file via radio button selection', (() => {
fit('should enable the addition of a script file via radio button selection', (() => {
let startFiles = EditorHelper.retrieveNavigatorFileNames()
.then((names) => {
startFiles = names;
Expand All @@ -275,22 +274,27 @@ describe('Editor Define', (() => {
.then((list: any) => {
// Previous files should still exist
startFiles.forEach((element) => {
console.log('CAZ', list);
console.log('ISAAC', element);
list.includes(element).should.be.true;
});
// We should have added one file
list.length.should.be.equal(startFiles.length + 1);
console.log('BOB');
list.includes('Script File\nlib/script.js').should.be.true;
browser.waitForAngularEnabled(true);
});
// -deploy enabled
EditorHelper.retrieveNavigatorFileActionButtons()
.then((array: any) => {
console.log('CAKE');
array[1].enabled.should.be.equal(true);
});
// -active file
EditorHelper.retrieveNavigatorActiveFile()
.then((list: any) => {
list.length.should.equal(1);
console.log('FISH');
list.includes('Script File\nlib/script.js').should.be.true;
});
// deploy new item
Expand Down
52 changes: 29 additions & 23 deletions packages/composer-playground/e2e/tests/welcome.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,36 @@ let should = chai.should();

describe('Welcome Splash', (() => {

// Navigate to Editor base page
beforeEach(() => {
browser.get(browser.baseUrl);
});

it('should welcome the user to Composer Playground', (() => {
let myElement = element(by.css('.welcome')).getText()
.then((myText) => {
myText.should.contain('Welcome to Hyperledger Composer Playground!');
// Navigate to Editor base page
beforeEach(() => {
return browser.get(browser.baseUrl)
.then(() => {
return browser.executeScript('window.localStorage.clear();');
})
.then(() => {
return browser.refresh();
});
});
}));

it('should dissappear when the user clicks cancel button', (() => {
let myButton = element(by.id('welcome_exit')).click()
.then(() => {
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.welcome'))), 5000);
});
}));

it('should dissappear when the user clicks "Let\'s Blockchain" button', (() => {
let myButton = element(by.id('welcome_start')).click()
.then(() => {
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.welcome'))), 5000);
});
}));
it('should welcome the user to Composer Playground', (() => {
let myElement = element(by.css('.welcome')).getText()
.then((myText) => {
myText.should.contain('Welcome to Hyperledger Composer Playground!');
});
}));

it('should dissappear when the user clicks cancel button', (() => {
let myButton = element(by.id('welcome_exit')).click()
.then(() => {
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.welcome'))), 5000);
});
}));

it('should dissappear when the user clicks "Let\'s Blockchain" button', (() => {
let myButton = element(by.id('welcome_start')).click()
.then(() => {
browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.welcome'))), 5000);
});
}));

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

export class LoginHelper {

// Click login button
static login() {
return element(by.id('login-0-admin')).click();
}
}
34 changes: 24 additions & 10 deletions packages/composer-playground/e2e/utils/operations-helper.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
import { browser, element, by } from 'protractor';
import { ExpectedConditions } from 'protractor';

import { LoginHelper } from '../utils/login-helper.ts';

export class OperationsHelper {

// Navigate to Editor base page and move past welcome splash
static navigatePastWelcome() {
browser.get(browser.baseUrl)
.then(() => {
return element(by.id('welcome_start')).click()
.then(() => {
return browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.welcome'))), 5000);
});
});
};
// Navigate to Editor base page and move past welcome splash and login
static navigatePastWelcomeAndLogin() {
return browser.get(browser.baseUrl)
.then(() => {
return browser.isElementPresent(element(by.css('.welcome')));
})
.then((welcomeOpen) => {
if (welcomeOpen) {
return element(by.id('welcome_start')).click()
.then(() => {
return browser.wait(ExpectedConditions.invisibilityOf(element(by.css('.welcome'))), 5000);
})
.then(() => {
return LoginHelper.login();
})
.then(() => {
return browser.wait(ExpectedConditions.invisibilityOf(element(by.tagName('login'))), 5000);
});
}
});

}
}
13 changes: 9 additions & 4 deletions packages/composer-playground/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
import { NoContentComponent } from './no-content';
import { CanActivateViaLogin } from './can-activate';
import { LoginComponent } from './login';

export const ROUTES: Routes = [
{path: 'editor', loadChildren: 'app/editor/editor.module#EditorModule'},
{path: 'test', loadChildren: 'app/test/test.module#TestModule'},
{path: 'identity', loadChildren: 'app/identity/identity.module#IdentityModule'},
{path: 'profile', loadChildren: 'app/connection-profile/connection-profile.module#ConnectionProfileModule'},
{path: 'editor', loadChildren: 'app/editor/editor.module#EditorModule', canActivate: [CanActivateViaLogin]},
{path: 'test', loadChildren: 'app/test/test.module#TestModule', canActivate: [CanActivateViaLogin]},
{path: 'identity', loadChildren: 'app/identity/identity.module#IdentityModule', canActivate: [CanActivateViaLogin]},
{path: 'profile', loadChildren: 'app/connection-profile/connection-profile.module#ConnectionProfileModule',
canActivate: [CanActivateViaLogin]},
{path: 'login', component: LoginComponent},
{path: '', redirectTo: 'editor', pathMatch: 'full'},
{path: '**', component: NoContentComponent}
];

@NgModule({
imports: [RouterModule.forRoot(ROUTES, {useHash: false, preloadingStrategy: PreloadAllModules})],
providers: [CanActivateViaLogin],
exports: [RouterModule]
})

Expand Down
65 changes: 34 additions & 31 deletions packages/composer-playground/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,40 @@
<div class="navlogo">
<p><b>Hyperledger</b> Composer Playground</p>
</div>
<ul class="links navleft">
<li>
<button class="action" [routerLink]="['editor']" [routerLinkActive]="['active']">Define</button>
</li>
<li>
<button class="action" [routerLink]="['test']" [routerLinkActive]="['active']">Test</button>
</li>
</ul>
<ul class="links navright">
<li class="withseparator">
<button class="action" [routerLink]="['identity']" [routerLinkActive]="['active']">
<span class="currentid" title="{{ identityService.currentIdentity | async }}">{{ identityService.currentIdentity | async }}</span>
</button>
</li>
<li *ngIf="!usingLocally">
<a href="https://hyperledger.github.io/composer/installing/using-playground-locally.html"
target="_blank">
<svg class="nav-icon" aria-hidden="true">
<use xlink:href="#icon-simple_docker"></use>
</svg>
<span>Get local version</span>
</a>
</li>
<li *ngIf="usingLocally">
<button class="action" [routerLink]="['profile']" [routerLinkActive]="['active']">
<svg class="nav-icon" aria-hidden="true">
<use xlink:href="#icon-world_24"></use>
</svg>
</button>
</li>
</ul>
<div *ngIf="showHeaderLinks" class="flex-container flex">
<ul class="links navleft">
<li>
<button class="action" [routerLink]="['editor']" [routerLinkActive]="['active']">Define
</button>
</li>
<li>
<button class="action" [routerLink]="['test']" [routerLinkActive]="['active']">Test</button>
</li>
</ul>
<ul class="links navright">
<li class="withseparator">
<button class="action" [routerLink]="['identity']" [routerLinkActive]="['active']">
<span class="currentid" title="{{ identityService.currentIdentity | async }}">{{ identityService.currentIdentity | async }}</span>
</button>
</li>
<li *ngIf="!usingLocally">
<a href="https://hyperledger.github.io/composer/installing/using-playground-locally.html"
target="_blank">
<svg class="nav-icon" aria-hidden="true">
<use xlink:href="#icon-simple_docker"></use>
</svg>
<span>Get local version</span>
</a>
</li>
<li *ngIf="usingLocally">
<button class="action" [routerLink]="['profile']" [routerLinkActive]="['active']">
<svg class="nav-icon" aria-hidden="true">
<use xlink:href="#icon-world_24"></use>
</svg>
</button>
</li>
</ul>
</div>
</div>
</nav>
</header>
Expand Down
Loading