diff --git a/assets/javascripts/spec/current_spec.coffee b/assets/javascripts/spec/current_spec.coffee index d3ab3167..eea24c0b 100644 --- a/assets/javascripts/spec/current_spec.coffee +++ b/assets/javascripts/spec/current_spec.coffee @@ -3,6 +3,9 @@ describe 'on the "current" state', -> app 'travis-ci/travis-core' waitFor buildRendered + afterEach -> + window.history.pushState({}, null, '/spec.html') + it 'displays the expected stuff', -> listsRepos [ { slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } } diff --git a/assets/javascripts/spec/job_spec.coffee b/assets/javascripts/spec/job_spec.coffee index b505bafc..c0ab3312 100644 --- a/assets/javascripts/spec/job_spec.coffee +++ b/assets/javascripts/spec/job_spec.coffee @@ -1,36 +1,40 @@ -# describe 'on the "job" state', -> -# beforeEach -> -# app '!/travis-ci/travis-core/jobs/1' -# waitFor jobRendered -# waitFor hasText('#tab_build', 'Build #1') -# -# it 'displays the expected stuff', -> -# listsRepos [ -# { slug: 'travis-ci/travis-core', build: { number: 1, url: '#!/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } } -# { slug: 'travis-ci/travis-assets', build: { number: 3, url: '#!/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } } -# { slug: 'travis-ci/travis-hub', build: { number: 4, url: '#!/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } } -# ] -# -# displaysRepository -# href: 'http://github.com/travis-ci/travis-core' -# -# displaysSummary -# id: 1 -# type: 'job' -# repo: 'travis-ci/travis-core' -# commit: '1234567' -# branch: 'master' -# compare: '0123456..1234567' -# finishedAt: '3 minutes ago' -# duration: '30 sec' -# message: 'commit message 1' -# -# displaysTabs -# current: { href: '#!/travis-ci/travis-core' } -# builds: { href: '#!/travis-ci/travis-core/builds' } -# build: { href: '#!/travis-ci/travis-core/builds/1' } -# job: { href: '#!/travis-ci/travis-core/jobs/1', active: true } -# -# displaysLog [ -# 'log 1' -# ] +describe 'on the "job" state', -> + beforeEach -> + app 'travis-ci/travis-core/jobs/1' + waitFor jobRendered + runs -> + waitFor hasText('#tab_build', 'Build #1') + + afterEach -> + window.history.pushState({}, null, '/spec.html') + + it 'displays the expected stuff', -> + listsRepos [ + { slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } } + { slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } } + { slug: 'travis-ci/travis-assets', build: { number: 3, url: '/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } } + ] + + displaysRepository + href: 'http://github.com/travis-ci/travis-core' + + displaysSummary + id: 1 + type: 'job' + repo: 'travis-ci/travis-core' + commit: '1234567' + branch: 'master' + compare: '0123456..1234567' + finishedAt: '3 minutes ago' + duration: '30 sec' + message: 'commit message 1' + + displaysTabs + current: { href: '/travis-ci/travis-core' } + builds: { href: '/travis-ci/travis-core/builds' } + build: { href: '/travis-ci/travis-core/builds/1' } + job: { href: '/travis-ci/travis-core/jobs/1', active: true } + + displaysLog [ + 'log 1' + ] diff --git a/assets/javascripts/spec/sidebar_spec.coffee b/assets/javascripts/spec/sidebar_spec.coffee index 2be9a971..327fba12 100644 --- a/assets/javascripts/spec/sidebar_spec.coffee +++ b/assets/javascripts/spec/sidebar_spec.coffee @@ -1,11 +1,15 @@ -# describe 'the sidebar', -> -# beforeEach -> -# app '!/travis-ci/travis-core/jobs/1' -# waitFor jobRendered -# waitFor hasText('#tab_build', 'Build #1') -# -# it 'displays the expected stuff', -> -# listsQueues [ -# { name: 'common', item: { number: '5.1', repo: 'travis-ci/travis-core' } } -# { name: 'common', item: { number: '5.2', repo: 'travis-ci/travis-core' } } -# ] +describe 'the sidebar', -> + beforeEach -> + app 'travis-ci/travis-core/jobs/1' + waitFor jobRendered + runs -> + waitFor hasText('#tab_build', 'Build #1') + + afterEach -> + window.history.pushState({}, null, '/spec.html') + + it 'displays the expected stuff', -> + listsQueues [ + { name: 'common', item: { number: '5.1', repo: 'travis-ci/travis-core' } } + { name: 'common', item: { number: '5.2', repo: 'travis-ci/travis-core' } } + ] diff --git a/assets/javascripts/spec/support/expectations.coffee b/assets/javascripts/spec/support/expectations.coffee index b8f26bfc..f59f5d10 100644 --- a/assets/javascripts/spec/support/expectations.coffee +++ b/assets/javascripts/spec/support/expectations.coffee @@ -105,9 +105,17 @@ expect(text).toContain job.repo expect(text).toContain "##{job.number}" +@listsQueue = (data) -> + name = data.item.name + job = data.item.item + text = $($("#queue_#{name} li")[data.row - 1]).text() + expect(text).toContain job.repo + expect(text).toContain "##{job.number}" + @listsItems = (type, items) -> $.each items, (row, item) => this["lists#{$.camelize(type)}"](item: item, row: row + 1) - +@listsQueues = (queues) -> + listsItems('queue', queues) diff --git a/public/javascripts/specs/specs.js b/public/javascripts/specs/specs.js index dc97a134..e26e0f7d 100644 --- a/public/javascripts/specs/specs.js +++ b/public/javascripts/specs/specs.js @@ -200,6 +200,9 @@ app('travis-ci/travis-core'); return waitFor(buildRendered); }); + afterEach(function() { + return window.history.pushState({}, null, '/spec.html'); + }); return it('displays the expected stuff', function() { listsRepos([ { @@ -415,12 +418,110 @@ }).call(this); (function() { - + describe('on the "job" state', function() { + beforeEach(function() { + app('travis-ci/travis-core/jobs/1'); + waitFor(jobRendered); + return runs(function() { + return waitFor(hasText('#tab_build', 'Build #1')); + }); + }); + afterEach(function() { + return window.history.pushState({}, null, '/spec.html'); + }); + return it('displays the expected stuff', function() { + listsRepos([ + { + slug: 'travis-ci/travis-hub', + build: { + number: 4, + url: '/travis-ci/travis-hub/builds/4', + duration: '1 min', + finishedAt: '-' + } + }, { + slug: 'travis-ci/travis-core', + build: { + number: 1, + url: '/travis-ci/travis-core/builds/1', + duration: '30 sec', + finishedAt: '3 minutes ago' + } + }, { + slug: 'travis-ci/travis-assets', + build: { + number: 3, + url: '/travis-ci/travis-assets/builds/3', + duration: '30 sec', + finishedAt: 'a day ago' + } + } + ]); + displaysRepository({ + href: 'http://github.com/travis-ci/travis-core' + }); + displaysSummary({ + id: 1, + type: 'job', + repo: 'travis-ci/travis-core', + commit: '1234567', + branch: 'master', + compare: '0123456..1234567', + finishedAt: '3 minutes ago', + duration: '30 sec', + message: 'commit message 1' + }); + displaysTabs({ + current: { + href: '/travis-ci/travis-core' + }, + builds: { + href: '/travis-ci/travis-core/builds' + }, + build: { + href: '/travis-ci/travis-core/builds/1' + }, + job: { + href: '/travis-ci/travis-core/jobs/1', + active: true + } + }); + return displaysLog(['log 1']); + }); + }); }).call(this); (function() { - + describe('the sidebar', function() { + beforeEach(function() { + app('travis-ci/travis-core/jobs/1'); + waitFor(jobRendered); + return runs(function() { + return waitFor(hasText('#tab_build', 'Build #1')); + }); + }); + afterEach(function() { + return window.history.pushState({}, null, '/spec.html'); + }); + return it('displays the expected stuff', function() { + return listsQueues([ + { + name: 'common', + item: { + number: '5.1', + repo: 'travis-ci/travis-core' + } + }, { + name: 'common', + item: { + number: '5.2', + repo: 'travis-ci/travis-core' + } + } + ]); + }); + }); }).call(this); (function() { @@ -636,6 +737,15 @@ return expect(text).toContain("#" + job.number); }; + this.listsQueue = function(data) { + var job, name, text; + name = data.item.name; + job = data.item.item; + text = $($("#queue_" + name + " li")[data.row - 1]).text(); + expect(text).toContain(job.repo); + return expect(text).toContain("#" + job.number); + }; + this.listsItems = function(type, items) { var _this = this; return $.each(items, function(row, item) { @@ -646,6 +756,10 @@ }); }; + this.listsQueues = function(queues) { + return listsItems('queue', queues); + }; + }).call(this); (function() {