gitlab-org--gitlab-foss/spec/javascripts/issue_spec.js.coffee

110 lines
3.7 KiB
CoffeeScript
Raw Normal View History

2016-06-23 13:21:35 -04:00
#= require lib/utils/text_utility
2015-05-04 23:06:57 -04:00
#= require issue
describe 'Issue', ->
describe 'task lists', ->
fixture.preload('issues_show.html')
2015-05-04 23:06:57 -04:00
beforeEach ->
fixture.load('issues_show.html')
2015-05-04 23:06:57 -04:00
@issue = new Issue()
it 'modifies the Markdown field', ->
2015-05-06 17:02:14 -04:00
spyOn(jQuery, 'ajax').and.stub()
$('input[type=checkbox]').attr('checked', true).trigger('change')
expect($('.js-task-list-field').val()).toBe('- [x] Task List Item')
2015-05-04 23:06:57 -04:00
it 'submits an ajax request on tasklist:changed', ->
2015-05-06 17:02:14 -04:00
spyOn(jQuery, 'ajax').and.callFake (req) ->
2015-05-04 23:06:57 -04:00
expect(req.type).toBe('PATCH')
expect(req.url).toBe('/foo')
expect(req.data.issue.description).not.toBe(null)
$('.js-task-list-field').trigger('tasklist:changed')
describe 'reopen/close issue', ->
fixture.preload('issues_show.html')
beforeEach ->
fixture.load('issues_show.html')
@issue = new Issue()
it 'closes an issue', ->
2016-01-07 12:27:01 -05:00
spyOn(jQuery, 'ajax').and.callFake (req) ->
expect(req.type).toBe('PUT')
expect(req.url).toBe('http://gitlab.com/issues/6/close')
2016-04-05 16:13:49 -04:00
req.success id: 34
$btnClose = $('a.btn-close')
$btnReopen = $('a.btn-reopen')
expect($btnReopen).toBeHidden()
expect($btnClose.text()).toBe('Close')
expect(typeof $btnClose.prop('disabled')).toBe('undefined')
$btnClose.trigger('click')
2016-06-20 03:54:57 -04:00
expect($btnReopen).toBeVisible()
expect($btnClose).toBeHidden()
expect($('div.status-box-closed')).toBeVisible()
expect($('div.status-box-open')).toBeHidden()
it 'fails to close an issue with success:false', ->
2016-01-07 12:27:01 -05:00
spyOn(jQuery, 'ajax').and.callFake (req) ->
expect(req.type).toBe('PUT')
expect(req.url).toBe('http://goesnowhere.nothing/whereami')
req.success saved: false
2016-06-20 03:54:57 -04:00
$btnClose = $('a.btn-close')
$btnReopen = $('a.btn-reopen')
$btnClose.attr('href','http://goesnowhere.nothing/whereami')
expect($btnReopen).toBeHidden()
expect($btnClose.text()).toBe('Close')
expect(typeof $btnClose.prop('disabled')).toBe('undefined')
$btnClose.trigger('click')
2016-06-20 03:54:57 -04:00
expect($btnReopen).toBeHidden()
expect($btnClose).toBeVisible()
expect($('div.status-box-closed')).toBeHidden()
expect($('div.status-box-open')).toBeVisible()
expect($('div.flash-alert')).toBeVisible()
expect($('div.flash-alert').text()).toBe('Unable to update this issue at this time.')
it 'fails to closes an issue with HTTP error', ->
2016-01-07 12:27:01 -05:00
spyOn(jQuery, 'ajax').and.callFake (req) ->
expect(req.type).toBe('PUT')
expect(req.url).toBe('http://goesnowhere.nothing/whereami')
req.error()
2016-06-20 03:54:57 -04:00
$btnClose = $('a.btn-close')
$btnReopen = $('a.btn-reopen')
$btnClose.attr('href','http://goesnowhere.nothing/whereami')
expect($btnReopen).toBeHidden()
expect($btnClose.text()).toBe('Close')
expect(typeof $btnClose.prop('disabled')).toBe('undefined')
$btnClose.trigger('click')
2016-06-20 03:54:57 -04:00
expect($btnReopen).toBeHidden()
expect($btnClose).toBeVisible()
expect($('div.status-box-closed')).toBeHidden()
expect($('div.status-box-open')).toBeVisible()
expect($('div.flash-alert')).toBeVisible()
expect($('div.flash-alert').text()).toBe('Unable to update this issue at this time.')
it 'reopens an issue', ->
2016-01-07 12:27:01 -05:00
spyOn(jQuery, 'ajax').and.callFake (req) ->
expect(req.type).toBe('PUT')
expect(req.url).toBe('http://gitlab.com/issues/6/reopen')
2016-04-05 16:13:49 -04:00
req.success id: 34
$btnClose = $('a.btn-close')
$btnReopen = $('a.btn-reopen')
expect($btnReopen.text()).toBe('Reopen')
$btnReopen.trigger('click')
expect($btnReopen).toBeHidden()
expect($btnClose).toBeVisible()
expect($('div.status-box-open')).toBeVisible()
2016-06-20 03:54:57 -04:00
expect($('div.status-box-closed')).toBeHidden()