Let browser tests dance again.

This commit is contained in:
Martin Edenhofer 2014-12-01 21:04:37 +01:00
parent df6c2d1132
commit 1d929159ba
8 changed files with 85 additions and 74 deletions

View file

@ -30,8 +30,6 @@ class App.ControllerForm extends App.Controller
fieldset = $('<fieldset></fieldset>') fieldset = $('<fieldset></fieldset>')
fieldset.append('<a href="#" class="js-reset hide">' + App.i18n.translatePlain('Discard your unsaved changes.') + '</a>')
# collect form attributes # collect form attributes
@attributes = [] @attributes = []
if @model.attributesGet if @model.attributesGet

View file

@ -520,12 +520,12 @@ class App.Sidebar extends App.Controller
toggleSidebar: => toggleSidebar: =>
@el.parent().find('.tabsSidebar-sidebarSpacer').toggleClass('is-closed') @el.parent().find('.tabsSidebar-sidebarSpacer').toggleClass('is-closed')
@el.parent().find('.tabsSidebar').toggleClass('is-closed') @el.parent().find('.tabsSidebar').toggleClass('is-closed')
@el.parent().next('.attributeBar').toggleClass('is-closed') #@el.parent().next('.attributeBar').toggleClass('is-closed')
showSidebar: -> showSidebar: ->
@el.parent().find('.tabsSidebar-sidebarSpacer').removeClass('is-closed') @el.parent().find('.tabsSidebar-sidebarSpacer').removeClass('is-closed')
@el.parent().find('.tabsSidebar').removeClass('is-closed') @el.parent().find('.tabsSidebar').removeClass('is-closed')
@el.parent().next('.attributeBar').addClass('is-closed') #@el.parent().next('.attributeBar').addClass('is-closed')
toggleTab: (e) => toggleTab: (e) =>

View file

@ -175,7 +175,6 @@ class App.TicketZoom extends App.Controller
@form_id = App.ControllerForm.formId() @form_id = App.ControllerForm.formId()
new Edit( new Edit(
ticket: @ticket ticket: @ticket
el: @el.find('.ticket-edit') el: @el.find('.ticket-edit')
@ -189,12 +188,20 @@ class App.TicketZoom extends App.Controller
editTicket = (el) => editTicket = (el) =>
el.append('<form class="edit"></form>') el.append('<form class="edit"></form>')
@editEl = el @editEl = el
console.log('EDIT TAB', @ticket.id)
reset = (e) => reset = (e) =>
e.preventDefault() e.preventDefault()
@taskReset() @taskReset()
show(@ticket) show(@ticket)
new Edit(
ticket: @ticket
el: @el.find('.ticket-edit')
#el: @el.find('.edit')
form_meta: @form_meta
form_id: @form_id
defaults: @taskGet('article')
ui: @
)
show = (ticket) => show = (ticket) =>
console.log('SHOW', ticket.id) console.log('SHOW', ticket.id)
@ -245,10 +252,10 @@ class App.TicketZoom extends App.Controller
bookmarkable: true bookmarkable: true
) )
#console.log('Ichanges', modelDiff, task_state, ticket.attributes()) #console.log('Ichanges', modelDiff, task_state, ticket.attributes())
@markFormDiff( modelDiff ) #@markFormDiff( modelDiff )
# bind on reset link # bind on reset link
@el.find('.edit .js-reset').on( @$('.js-reset').on(
'click' 'click'
(e) => (e) =>
reset(e) reset(e)
@ -424,7 +431,7 @@ class App.TicketZoom extends App.Controller
currentStore = currentStore =
ticket: @ticket.attributes() ticket: @ticket.attributes()
article: { article: {
type: '' type: 'note'
body: '' body: ''
internal: '' internal: ''
} }
@ -446,7 +453,7 @@ class App.TicketZoom extends App.Controller
console.log('model DIFF ', modelDiff) console.log('model DIFF ', modelDiff)
@autosaveLast = clone(currentParams) @autosaveLast = clone(currentParams)
@markFormDiff( modelDiff.ticket ) @markFormDiff( modelDiff )
@taskUpdateAll( modelDiff ) @taskUpdateAll( modelDiff )
@interval( update, 3000, 'autosave' ) @interval( update, 3000, 'autosave' )
@ -464,30 +471,33 @@ class App.TicketZoom extends App.Controller
result = difference( modelClone, params ) result = difference( modelClone, params )
markFormDiff: (diff = {}) => markFormDiff: (diff = {}) =>
form = @$('.edit') ticketForm = @$('.edit')
articleForm = @$('.article-add')
params = @formParam( form ) params = {}
#console.log('markFormDiff', diff, params) params.ticket = @formParam( ticketForm )
params.article = @formParam( articleForm )
console.log('markFormDiff', diff, params)
# clear all changes # clear all changes
if _.isEmpty(diff) if _.isEmpty(diff.ticket) && _.isEmpty(diff.article)
form.removeClass('form-changed') ticketForm.removeClass('form-changed')
form.find('.form-group').removeClass('is-changed') ticketForm.find('.form-group').removeClass('is-changed')
form.find('.js-reset').addClass('hide') @$('.js-reset').addClass('hide')
# set changes # set changes
else else
form.addClass('form-changed') ticketForm.addClass('form-changed')
for currentKey, currentValue of params for currentKey, currentValue of params.ticket
element = @$('.edit [name="' + currentKey + '"]').parents('.form-group') element = @$('.edit [name="' + currentKey + '"]').parents('.form-group')
if diff[currentKey] if diff.ticket[currentKey]
if !element.hasClass('is-changed') if !element.hasClass('is-changed')
element.addClass('is-changed') element.addClass('is-changed')
else else
if element.hasClass('is-changed') if element.hasClass('is-changed')
element.removeClass('is-changed') element.removeClass('is-changed')
form.find('.js-reset').removeClass('hide') @$('.js-reset').removeClass('hide')
submit: (e) => submit: (e) =>

View file

@ -53,7 +53,8 @@
<div class="tabsSidebar vertical"></div> <div class="tabsSidebar vertical"></div>
</div> </div>
<form class="attributeBar form-inline is-closed" role="form"> <div class="attributeBar">
<form class="form-inline is-closed hide" role="form">
<div class="form-group"> <div class="form-group">
<label for="update_ticket_1_state_id123" class="input-group-addon u-clickable">State</label> <label for="update_ticket_1_state_id123" class="input-group-addon u-clickable">State</label>
<select id="update_ticket_1_state_id123" class="form-control level-1" name="state_id"> <select id="update_ticket_1_state_id123" class="form-control level-1" name="state_id">
@ -91,8 +92,12 @@
</select> </select>
<div class="select-arrow icon"></div> <div class="select-arrow icon"></div>
</div> </div>
</form>
<form class="form-inline">
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn--primary js-submit"><%- @T('Update') %></button> <button type="submit" class="btn js-reset pull-right hide"><%- @T('Discard your unsaved changes.') %></button>
<button type="submit" class="btn btn--primary js-submit pull-right"><%- @T('Update') %></button>
</div> </div>
</form> </form>
</div> </div>
</div>

View file

@ -29,7 +29,7 @@ rake db:seed
cat config/environments/production.rb | sed -e 's/config.serve_static_assets = false/config.serve_static_assets = true/' > /tmp/production.rb && cp /tmp/production.rb config/environments/production.rb cat config/environments/production.rb | sed -e 's/config.serve_static_assets = false/config.serve_static_assets = true/' > /tmp/production.rb && cp /tmp/production.rb config/environments/production.rb
# mofidy auth backend # mofidy auth backend
cat lib/auth/test.rb | sed 's/development/production/' > /tmp/test.rb && cp /tmp/test.rb lib/auth/test.rb cat lib/auth/test.rb | sed 's/test/production/' > /tmp/test.rb && cp /tmp/test.rb lib/auth/test.rb
pumactl --pidfile tmp/pids/puma.pid stop pumactl --pidfile tmp/pids/puma.pid stop
script/websocket-server.rb stop script/websocket-server.rb stop

View file

@ -118,11 +118,11 @@ class AgentTicketActionLevel1Test < TestCase
:action => [ :action => [
{ {
:execute => 'click', :execute => 'click',
:css => '.active .actions button', :css => '.active div[data-tab="ticket"] .js-actions .select-arrow',
}, },
{ {
:execute => 'click', :execute => 'click',
:css => '.active a[data-type="merge"]', :css => '.active div[data-tab="ticket"] .js-actions a[data-type="ticket-merge"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',

View file

@ -136,7 +136,7 @@ class AgentTicketActionsLevel3Test < TestCase
{ {
:where => :instance1, :where => :instance1,
:execute => 'match', :execute => 'match',
:css => '.active div.ticket-article-view', :css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 2', :value => 'some level 3 <b>body</b> in instance 2',
:match_result => true, :match_result => true,
}, },
@ -176,14 +176,14 @@ class AgentTicketActionsLevel3Test < TestCase
{ {
:where => :instance2, :where => :instance2,
:execute => 'match', :execute => 'match',
:css => '.active div.ticket-article-view', :css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 1', :value => 'some level 3 <b>body</b> in instance 1',
:match_result => true, :match_result => true,
}, },
{ {
:where => :instance2, :where => :instance2,
:execute => 'match', :execute => 'match',
:css => '.active div.ticket-article-view', :css => '.active div.ticket-article',
:value => 'some level 3 <b>body</b> in instance 2', :value => 'some level 3 <b>body</b> in instance 2',
:match_result => true, :match_result => true,
}, },
@ -310,7 +310,7 @@ class AgentTicketActionsLevel3Test < TestCase
{ {
:where => :instance2, :where => :instance2,
:execute => 'match', :execute => 'match',
:css => '.active div.ticket-article-view', :css => '.active div.ticket-article',
:value => '22 some level 3 <b>body</b> in instance 2', :value => '22 some level 3 <b>body</b> in instance 2',
:match_result => true, :match_result => true,
}, },

View file

@ -446,17 +446,15 @@ class AgentTicketActionLevel5Test < TestCase
:execute => 'click', :execute => 'click',
:css => 'a[href="#manage"]', :css => 'a[href="#manage"]',
}, },
# create ticket
{ {
:where => :instance2, :where => :instance2,
:execute => 'click', :execute => 'click',
:css => '.content.active .tabsSidebar-tabs [data-tab="customer"]', :css => '.active div[data-tab="ticket"] .js-actions .select-arrow',
}, },
{ {
:where => :instance2, :where => :instance2,
:execute => 'click', :execute => 'click',
:css => '.content.active .tabsSidebar [data-name="Change Customer"]', :css => '.active div[data-tab="ticket"] .js-actions a[data-type="customer-change"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',