Skip to content

Commit

Permalink
Add build matrix acceptance test (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace authored Jul 19, 2016
1 parent dc8cc32 commit b7c5c2a
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
43 changes: 43 additions & 0 deletions tests/acceptance/job-view-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test } from 'qunit';
import moduleForAcceptance from 'travis/tests/helpers/module-for-acceptance';
import jobPage from 'travis/tests/pages/job';
import buildPage from 'travis/tests/pages/build';

moduleForAcceptance('Acceptance | job view');

Expand Down Expand Up @@ -31,6 +32,48 @@ test('visiting job-view', function (assert) {
});
});

test('visiting build matrix', function (assert) {
let repo = server.create('repository', { slug: 'travis-ci/travis-web' });
// create branch
server.create('branch', {});

let commit = server.create('commit', { author_email: '[email protected]', author_name: 'Mr T', committer_email: '[email protected]', committer_name: 'Mr T', branch: 'acceptance-tests', message: 'This is a message', branch_is_default: true });
let build = server.create('build', { repository_id: repo.id, state: 'passed', commit_id: commit.id, commit });

let firstJob = server.create('job', { number: '1234.1', repository_id: repo.id, state: 'passed', build_id: build.id, config: { env: 'JORTS', os: 'linux', language: 'node_js', node_js: 5 }, commit, build });
commit.job = firstJob;

firstJob.save();
commit.save();

server.create('job', { number: '1234.2', repository_id: repo.id, state: 'passed', build_id: build.id, config: { env: 'JANTS', os: 'osx', language: 'ruby', rvm: 2.2 }, commit, build });
server.create('job', { allow_failure: true, number: '1234.999', repository_id: repo.id, state: 'failed', build_id: build.id, commit, build });

visit(`/travis-ci/travis-web/builds/${build.id}`);

andThen(function () {
assert.equal(buildPage.requiredJobs().count, 2, 'expected two required jobs in the matrix');

const firstJobRow = buildPage.requiredJobs(0);
assert.ok(firstJobRow.state.isPassed, 'expected the first job to have passed');
assert.equal(firstJobRow.number, '1234.1');
assert.equal(firstJobRow.env, 'JORTS');
assert.equal(firstJobRow.os, 'linux');
assert.equal(firstJobRow.language, 'Node.js: 5');

const secondJobRow = buildPage.requiredJobs(1);
assert.equal(secondJobRow.number, '1234.2');
assert.equal(secondJobRow.env, 'JANTS');
assert.equal(secondJobRow.os, 'osx');
assert.equal(secondJobRow.language, 'Ruby: 2.2');

assert.equal(buildPage.allowedFailureJobs().count, 1, 'expected one allowed failure job');

const failedJobRow = buildPage.allowedFailureJobs(0);
assert.ok(failedJobRow.state.isFailed, 'expected the allowed failure job to have failed');
});
});


test('handling log error', function (assert) {
let repo = server.create('repository', { slug: 'travis-ci/travis-web' });
Expand Down
31 changes: 30 additions & 1 deletion tests/pages/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,44 @@ import PageObject from 'travis/tests/page-object';

let {
clickable,
collection,
hasClass,
visitable,
text
} = PageObject;

const jobComponent = {
state: {
scope: '.job-state',
isPassed: hasClass('passed'),
isFailed: hasClass('failed')
},

number: text('.job-number .label-align'),
env: text('.job-env .label-align'),
os: text('.job-os span'),
language: text('.job-lang .label-align')
};

export default PageObject.create({
visit: visitable('travis-ci/travis-web/builds/1'),
restartBuild: clickable('.button-circle-trigger'),
cancelBuild: clickable('.button-circle-cancel'),
restartedNotification: text('p.flash-message'),
cancelledNotification: text('p.flash-message'),
singleJobLogText: text('.log-body pre')
singleJobLogText: text('.log-body pre'),

requiredJobs: collection({
scope: '.jobs-list:eq(0)',
itemScope: '.jobs-item',

item: jobComponent
}),

allowedFailureJobs: collection({
scope: '.jobs-list:eq(1)',
itemScope: '.jobs-item',

item: jobComponent
})
});

0 comments on commit b7c5c2a

Please sign in to comment.