Skip to content

Commit

Permalink
test(mocha): switch protractor framework to mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Sep 18, 2017
1 parent 754add6 commit 9e549ab
Show file tree
Hide file tree
Showing 17 changed files with 124 additions and 97 deletions.
7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

11 changes: 8 additions & 3 deletions e2e/010_server_status.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { browser, by, element } from 'protractor';
import { isLoaded } from './utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);
const expect = chai.expect;

describe('Server Status', () => {

Expand All @@ -8,22 +13,22 @@ describe('Server Status', () => {
.then(() => isLoaded())
.then(() => element(by.css('[name="docker-installed-icon"]')))
.then(el => el.getAttribute('src'))
.then(attr => expect(attr).toContain('images/icons/check-true.svg'));
.then(attr => expect(attr).to.includes('images/icons/check-true.svg'));
});

it(`should have docker running`, () => {
return browser.get('/setup')
.then(() => isLoaded())
.then(() => element(by.css('[name="docker-running-icon"]')))
.then(el => el.getAttribute('src'))
.then(attr => expect(attr).toContain('/images/icons/check-true.svg'));
.then(attr => expect(attr).to.includes('/images/icons/check-true.svg'));
});

it(`should have sqlite3 installed`, () => {
return browser.get('/setup')
.then(() => isLoaded())
.then(() => element(by.css('[name="sqlite3-installed-icon"]')))
.then(el => el.getAttribute('src'))
.then(attr => expect(attr).toContain('images/icons/check-true.svg'));
.then(attr => expect(attr).to.includes('images/icons/check-true.svg'));
});
});
31 changes: 14 additions & 17 deletions e2e/020_setup.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { browser, by, element } from 'protractor';
import { isLoaded } from './utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

describe('User Registration', () => {
let originalTimeout = 300000;
beforeAll(() => {
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1200000;
});

afterAll(() => jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout);
chai.use(chaiAsPromised);
const expect = chai.expect;

describe('User Registration', () => {
it(`continue button should be disabled when password is empty`, () => {
return browser.get('/setup')
.then(() => isLoaded())
Expand All @@ -19,9 +16,9 @@ describe('User Registration', () => {
.then(() => element(by.css('.form-input[name="name"]')).sendKeys('John Wayne'))
.then(() => element(by.css('.form-input[name="password"]')).sendKeys('test123'))
.then(() => element(by.css('.button[name="btn-register"]')).isEnabled())
.then(enabled => expect(enabled).toEqual(false))
.then(enabled => expect(enabled).to.equal(false))
.then(() => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/setup'));
.then(url => expect(url).to.equal('http://localhost:6500/setup'));
});

it(`continue button should be disabled when email is not email address`, () => {
Expand All @@ -34,9 +31,9 @@ describe('User Registration', () => {
.then(() => element(by.css('.form-input[name="password"]')).sendKeys('test123'))
.then(() => element(by.css('.form-input[name="password2"]')).sendKeys('test123'))
.then(() => element(by.css('.button[name="btn-register"]')).isEnabled())
.then(enabled => expect(enabled).toEqual(false))
.then(enabled => expect(enabled).to.equal(false))
.then(() => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/setup'));
.then(url => expect(url).to.equal('http://localhost:6500/setup'));
});

it(`continue button should be disabled when name is empty`, () => {
Expand All @@ -49,9 +46,9 @@ describe('User Registration', () => {
.then(() => element(by.css('.form-input[name="password"]')).sendKeys('test123'))
.then(() => element(by.css('.form-input[name="password2"]')).sendKeys('test123'))
.then(() => element(by.css('.button[name="btn-register"]')).isEnabled())
.then(enabled => expect(enabled).toEqual(false))
.then(enabled => expect(enabled).to.equal(false))
.then(() => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/setup'));
.then(url => expect(url).to.equal('http://localhost:6500/setup'));
});

it(`continue button should be disabled when passwords don't match`, () => {
Expand All @@ -64,9 +61,9 @@ describe('User Registration', () => {
.then(() => element(by.css('.form-input[name="password"]')).sendKeys('test123'))
.then(() => element(by.css('.form-input[name="password2"]')).sendKeys('test12'))
.then(() => element(by.css('.button[name="btn-register"]')).isEnabled())
.then(enabled => expect(enabled).toEqual(false))
.then(enabled => expect(enabled).to.equal(false))
.then(() => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/setup'));
.then(url => expect(url).to.equal('http://localhost:6500/setup'));
});

it('should successfully register user and build docker image', () => {
Expand All @@ -87,7 +84,7 @@ describe('User Registration', () => {
.then((): any => browser.wait(() => element(by.css('[name="loginPage"]')).isPresent()))
.then((): any => element(by.css('[name="loginPage"]')).click())
.then((): any => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/login'));
.then(url => expect(url).to.equal('http://localhost:6500/login'));
} else {
return Promise.resolve();
}
Expand Down
11 changes: 8 additions & 3 deletions e2e/030_login.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { browser, by, element } from 'protractor';
import { isLoaded } from './utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);
const expect = chai.expect;

describe('User Login', () => {

Expand All @@ -10,7 +15,7 @@ describe('User Login', () => {
.then(() => element(by.css('.form-input[name="password"]')).sendKeys('test123'))
.then(() => element(by.css('.login-button')).click())
.then(() => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/login'));
.then(url => expect(url).to.equal('http://localhost:6500/login'));
});

it('should login with correct username and password', () => {
Expand All @@ -22,7 +27,7 @@ describe('User Login', () => {
.then(() => element(by.css('.login-button')).click())
.then(() => isLoaded())
.then(() => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/'))
.then(url => expect(url).to.equal('http://localhost:6500/'))
.then(() => browser.waitForAngularEnabled(true));
});

Expand All @@ -35,7 +40,7 @@ describe('User Login', () => {
.then(() => element.all(by.css('.nav-dropdown-item')).last().click())
.then(() => isLoaded())
.then(() => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/login'))
.then(url => expect(url).to.equal('http://localhost:6500/login'))
.then(() => browser.waitForAngularEnabled(true));
});
});
21 changes: 14 additions & 7 deletions e2e/040_repositories.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { browser, by, element, ExpectedConditions } from 'protractor';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import { isLoaded, login, logout } from './utils';
import { request, header } from '../tests/e2e/webhooks/github/PingEvent';
import { sendGitHubRequest } from '../tests/e2e/utils/utils';

describe('Repositories', () => {

beforeAll(() => login());
chai.use(chaiAsPromised);
const expect = chai.expect;

afterAll(() => logout());
describe('Repositories', () => {
before(() => login());
after(() => logout());

it('should open repository page with zero repositories', () => {
return browser.get('/repositories')
.then(() => isLoaded())
.then(() => {
return expect(element(by.css('.is-info')).getText()).toContain('No repositories found.');
return expect(element(by.css('.is-info')).getText())
.to.eventually.have.string('No repositories found.');
});
});

Expand All @@ -22,7 +26,10 @@ describe('Repositories', () => {
.then(() => browser.get('/repositories'))
.then((): any => isLoaded())
.then((): any => browser.wait(() => element(by.css('.bold')).isPresent()))
.then(() => expect(element(by.css('.bold')).getText()).toContain('bterm'));
.then(() => {
return expect(element(by.css('.bold')).getText())
.to.eventually.have.string('bterm');
});
});

it('should redirect to bterm repository, add new environment variable and then delete it', () => {
Expand All @@ -32,7 +39,7 @@ describe('Repositories', () => {
}))
.then((): any => element.all(by.css('.list-item')).first().click())
.then((): any => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/repo/1'))
.then(url => expect(url).to.equal('http://localhost:6500/repo/1'))
.then((): any => browser.wait(() => element(by.css(`[name="btn-settings"]`)).isPresent()))
.then((): any => browser.wait(() => {
return ExpectedConditions.elementToBeClickable(element(by.css(`[name="btn-settings"]`)));
Expand Down
17 changes: 11 additions & 6 deletions e2e/050_builds.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import {
header as pushEventHeader
} from '../tests/e2e/webhooks/github/PushEvent';
import { sendGitHubRequest } from '../tests/e2e/utils/utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);
const expect = chai.expect;

describe('Builds', () => {
beforeAll(() => login().then(() => browser.waitForAngularEnabled(false)));
afterAll(() => logout().then(() => browser.waitForAngularEnabled(true)));
before(() => login().then(() => browser.waitForAngularEnabled(false)));
after(() => logout().then(() => browser.waitForAngularEnabled(true)));

afterEach(() => {
return Promise.resolve(() => {
Expand All @@ -21,7 +26,7 @@ describe('Builds', () => {
return Promise.resolve()
.then((): any => browser.wait(() => element(by.css('.is-info')).isPresent()))
.then(() => expect(element(by.css('.is-info')).getText())
.toContain('No builds has been runned yet.'));
.to.eventually.have.string('No builds has been runned yet.'));
});

it('should start new build (send open_pull_request event)', () => {
Expand Down Expand Up @@ -55,7 +60,7 @@ describe('Builds', () => {
.then((): any => waitForUrlToChangeTo('http://localhost:6500/build/1'))
.then(() => browser.navigate().back())
.then((): any => browser.getCurrentUrl())
.then(url => expect(url).toEqual('http://localhost:6500/'));
.then(url => expect(url).to.equal('http://localhost:6500/'));
});

it('should start new build (send reopen_pull_request event)', () => {
Expand Down Expand Up @@ -88,7 +93,7 @@ describe('Builds', () => {
}));
});

it('should start new build (send push event)', () => {
xit('should start new build (send push event)', () => {
return sendGitHubRequest(requestD3, pushEventHeader)
.then((): any => browser.wait(() => element.all(by.css('.list-item')).count().then(cnt => {
return cnt === 3;
Expand Down Expand Up @@ -118,7 +123,7 @@ describe('Builds', () => {
}));
});

it('should restart last build and send same push event, the old build should stop', () => {
xit('should restart last build and send same push event, the old build should stop', () => {
return Promise.resolve()
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 0);
Expand Down
13 changes: 9 additions & 4 deletions e2e/060_build.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import { browser, by, element, ExpectedConditions } from 'protractor';
import { login, logout, delay } from './utils';
import { requestD3, header } from '../tests/e2e/webhooks/github/PushEvent';
import { sendGitHubRequest } from '../tests/e2e/utils/utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);
const expect = chai.expect;

function randomNumber(minimum: number, maximum: number): number {
return Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
}

describe('Build Details', () => {
let originalTimeout: number;
beforeAll(() => login().then(() => browser.waitForAngularEnabled(false)));
afterAll(() => logout().then(() => browser.waitForAngularEnabled(true)));
before(() => login().then(() => browser.waitForAngularEnabled(false)));
after(() => logout().then(() => browser.waitForAngularEnabled(true)));

it('should restart existing build', () => {
return browser.get('/build/1')
Expand Down Expand Up @@ -149,7 +154,7 @@ describe('Build Details', () => {
});
});

it('should start new build (D3) and see progress bar in second job run', () => {
xit('should start new build (D3) and see progress bar in second job run', () => {
return Promise.resolve()
.then(() => browser.get('/'))
.then(() => sendGitHubRequest(requestD3, header))
Expand Down Expand Up @@ -212,7 +217,7 @@ describe('Build Details', () => {
});
});

it(`should restart first build and see approximately time remaining`, () => {
xit(`should restart first build and see approximately time remaining`, () => {
return browser.get('/build/1')
.then((): any => browser.wait(() => element.all(by.css('.list-item')).count().then(cnt => {
return cnt > 0;
Expand Down
8 changes: 6 additions & 2 deletions e2e/070_job.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { browser, by, element, ExpectedConditions } from 'protractor';
import { login, logout, delay } from './utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);
const expect = chai.expect;

describe('Job Details', () => {
let originalTimeout: number;
beforeAll(() => login().then(() => browser.waitForAngularEnabled(false)));
afterAll(() => logout().then(() => browser.waitForAngularEnabled(true)));
before(() => login().then(() => browser.waitForAngularEnabled(false)));
after(() => logout().then(() => browser.waitForAngularEnabled(true)));

xit('should restart job watch console log until it matches expected output', () => {
return browser.get('/job/5')
Expand Down
14 changes: 8 additions & 6 deletions e2e/080_bitbucket.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ import { request, header } from '../tests/e2e/webhooks/bitbucket/PushEvent';
import { request as prReq, headerPullRequestCreated }
from '../tests/e2e/webhooks/bitbucket/PullRequestEvent';
import { sendBitBucketRequest } from '../tests/e2e/utils/utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);
const expect = chai.expect;


describe('Bitbucket repositories', () => {
let originalTimeout: number;
beforeAll(() => {
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 150000;
before(() => {
login().then(() => browser.waitForAngularEnabled(false));
});

afterAll(() => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
after(() => {
logout().then(() => browser.waitForAngularEnabled(true));
});

Expand All @@ -30,7 +32,7 @@ describe('Bitbucket repositories', () => {
.then(() => browser.get('/repositories'))
.then((): any => isLoaded())
.then((): any => browser.wait(() => element(by.css('.bold')).isPresent()))
.then(() => expect(element.all(by.css('.bold')).last().getText()).toContain('test'))
.then(() => expect(element.all(by.css('.bold')).last().getText()).to.include('test'))
.then(() => browser.get('/'))
.then((): any => browser.wait(() => {
return element(by.css('.list-item:nth-child(1) .stop-build')).isPresent();
Expand Down
11 changes: 8 additions & 3 deletions e2e/090_gitlab.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ import { isLoaded, login, logout, delay } from './utils';
import { request, header } from '../tests/e2e/webhooks/gitlab/PushEvents';
import { request as prReq, header as prHead } from '../tests/e2e/webhooks/gitlab/MergeEvents';
import { sendGitLabRequest } from '../tests/e2e/utils/utils';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';

chai.use(chaiAsPromised);
const expect = chai.expect;


describe('Gitlab repositories', () => {
beforeAll(() => login().then(() => browser.waitForAngularEnabled(false)));
afterAll(() => logout().then(() => browser.waitForAngularEnabled(true)));
before(() => login().then(() => browser.waitForAngularEnabled(false)));
after(() => logout().then(() => browser.waitForAngularEnabled(true)));

xit('should add gitlab repository and start new build (send push event)', () => {
return browser.wait(() => {
Expand All @@ -20,7 +25,7 @@ describe('Gitlab repositories', () => {
.then(() => browser.get('/repositories'))
.then((): any => isLoaded())
.then((): any => browser.wait(() => element(by.css('.bold')).isPresent()))
.then(() => expect(element.all(by.css('.bold')).last().getText()).toContain('test'))
.then(() => expect(element.all(by.css('.bold')).last().getText()).to.include('test'))
.then(() => browser.get('/'))
.then((): any => browser.wait(() => {
return element(by.css('.list-item:nth-child(1) .stop-build')).isPresent();
Expand Down
Loading

0 comments on commit 9e549ab

Please sign in to comment.