Skip to content

Commit

Permalink
test(): added protractor tests for gitlab integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Izak88 committed Aug 25, 2017
1 parent b5429c6 commit 111d209
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions e2e/080_gitlab.e2e.ts
@@ -0,0 +1,92 @@
import { browser, by, element, ExpectedConditions } from 'protractor';
import { isLoaded, login, logout } 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';


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

it('should add gitlab repository and start new build (send push event)', () => {
return browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 0);
})
.then(() => sendGitLabRequest(request, header))
.then(() => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 1);
}))
.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(() => browser.get('/'))
.then((): any => browser.wait(() => {
return element(by.css('.list-item:nth-child(1) .stop-build')).isPresent();
}))
.then((): any => element.all(by.css('.list-item:nth-child(1) .stop-build')).click())
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 0);
}));
});

it('should start new build (send reopen_pull_request event)', () => {
return sendGitLabRequest(prReq, prHead)
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 1);
}))
.then((): any => browser.wait(() => {
return element(by.css('.build-time')).isPresent();
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.disabled')).count().then(cnt => cnt === 0);
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.list-item:nth-child(1) .stop-build')).isPresent();
}))
.then((): any => {
return browser.wait(() => {
const el = element(by.css('.list-item:nth-child(1) .stop-build'));
return ExpectedConditions.elementToBeClickable(el);
});
})
.then((): any => element.all(by.css('.stop-build')).first().click())
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 0);
}));
});

it('should restart last build', () => {
return Promise.resolve()
.then((): any => browser.wait(() => {
return element.all(by.css('.disabled')).count().then(cnt => cnt === 0);
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.restart-build')).first().isPresent();
}))
.then((): any => element.all(by.css('.restart-build')).first().click())
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count > 0);
}))
.then((): any => browser.wait(() => {
return element(by.css('.build-time')).isPresent();
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.disabled')).count().then(cnt => cnt === 0);
}))
.then((): any => browser.wait(() => {
return element.all(by.css('.stop-build')).first().isPresent();
}))
.then((): any => {
return browser.wait(() => {
const el = element(by.css('.stop-build'));
return ExpectedConditions.elementToBeClickable(el);
});
})
.then((): any => element.all(by.css('.stop-build')).first().click())
.then((): any => browser.wait(() => {
return element.all(by.css('.is-running')).count().then(count => count === 0);
}));
});
});

0 comments on commit 111d209

Please sign in to comment.