From 1d929159ba66d8b9405dcddb269a8f088ee9e567 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 1 Dec 2014 21:04:37 +0100 Subject: [PATCH] Let browser tests dance again. --- .../_application_controller_form.js.coffee | 2 - .../_application_controller_generic.js.coffee | 4 +- .../app/controllers/ticket_zoom.js.coffee | 48 ++++++----- .../javascripts/app/views/ticket_zoom.jst.eco | 85 ++++++++++--------- script/local_browser_tests.sh | 2 +- .../agent_ticket_actions_level1_test.rb | 4 +- .../agent_ticket_actions_level3_test.rb | 8 +- .../agent_ticket_actions_level5_test.rb | 6 +- 8 files changed, 85 insertions(+), 74 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index 3f178ab56..127afa8c9 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -30,8 +30,6 @@ class App.ControllerForm extends App.Controller fieldset = $('
') - fieldset.append('' + App.i18n.translatePlain('Discard your unsaved changes.') + '') - # collect form attributes @attributes = [] if @model.attributesGet diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index 2a05ee2d8..a231cf2a7 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -520,12 +520,12 @@ class App.Sidebar extends App.Controller toggleSidebar: => @el.parent().find('.tabsSidebar-sidebarSpacer').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: -> @el.parent().find('.tabsSidebar-sidebarSpacer').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) => diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index b3eaef1cb..e7c10dd97 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -175,7 +175,6 @@ class App.TicketZoom extends App.Controller @form_id = App.ControllerForm.formId() - new Edit( ticket: @ticket el: @el.find('.ticket-edit') @@ -189,12 +188,20 @@ class App.TicketZoom extends App.Controller editTicket = (el) => el.append('
') @editEl = el - console.log('EDIT TAB', @ticket.id) reset = (e) => e.preventDefault() @taskReset() 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) => console.log('SHOW', ticket.id) @@ -245,10 +252,10 @@ class App.TicketZoom extends App.Controller bookmarkable: true ) #console.log('Ichanges', modelDiff, task_state, ticket.attributes()) - @markFormDiff( modelDiff ) + #@markFormDiff( modelDiff ) # bind on reset link - @el.find('.edit .js-reset').on( + @$('.js-reset').on( 'click' (e) => reset(e) @@ -424,7 +431,7 @@ class App.TicketZoom extends App.Controller currentStore = ticket: @ticket.attributes() article: { - type: '' + type: 'note' body: '' internal: '' } @@ -434,7 +441,7 @@ class App.TicketZoom extends App.Controller # get diff of model modelDiff = - ticket: @getDiff( currentStore.ticket, currentParams.ticket ) + ticket: @getDiff( currentStore.ticket, currentParams.ticket ) article: @getDiff( currentStore.article, currentParams.article ) #console.log('modelDiff', modelDiff) @@ -446,7 +453,7 @@ class App.TicketZoom extends App.Controller console.log('model DIFF ', modelDiff) @autosaveLast = clone(currentParams) - @markFormDiff( modelDiff.ticket ) + @markFormDiff( modelDiff ) @taskUpdateAll( modelDiff ) @interval( update, 3000, 'autosave' ) @@ -464,30 +471,33 @@ class App.TicketZoom extends App.Controller result = difference( modelClone, params ) markFormDiff: (diff = {}) => - form = @$('.edit') + ticketForm = @$('.edit') + articleForm = @$('.article-add') - params = @formParam( form ) - #console.log('markFormDiff', diff, params) + params = {} + params.ticket = @formParam( ticketForm ) + params.article = @formParam( articleForm ) + console.log('markFormDiff', diff, params) # clear all changes - if _.isEmpty(diff) - form.removeClass('form-changed') - form.find('.form-group').removeClass('is-changed') - form.find('.js-reset').addClass('hide') + if _.isEmpty(diff.ticket) && _.isEmpty(diff.article) + ticketForm.removeClass('form-changed') + ticketForm.find('.form-group').removeClass('is-changed') + @$('.js-reset').addClass('hide') # set changes else - form.addClass('form-changed') - for currentKey, currentValue of params + ticketForm.addClass('form-changed') + for currentKey, currentValue of params.ticket element = @$('.edit [name="' + currentKey + '"]').parents('.form-group') - if diff[currentKey] + if diff.ticket[currentKey] if !element.hasClass('is-changed') element.addClass('is-changed') else if element.hasClass('is-changed') element.removeClass('is-changed') - form.find('.js-reset').removeClass('hide') + @$('.js-reset').removeClass('hide') submit: (e) => @@ -643,7 +653,7 @@ class App.TicketZoom extends App.Controller taskReset: (area, data) => @localTaskData = - ticket: {} + ticket: {} article: {} App.TaskManager.update( @task_key, { 'state': @localTaskData }) diff --git a/app/assets/javascripts/app/views/ticket_zoom.jst.eco b/app/assets/javascripts/app/views/ticket_zoom.jst.eco index 58e9caaa1..b66fe5fe6 100644 --- a/app/assets/javascripts/app/views/ticket_zoom.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom.jst.eco @@ -53,46 +53,51 @@
-
+
+ +
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ +
- - -
+ +
-
- - -
-
-
- - -
-
-
- - -
-
-
- -
-
+ +
\ No newline at end of file diff --git a/script/local_browser_tests.sh b/script/local_browser_tests.sh index 53cfa6ca5..8188a0027 100755 --- a/script/local_browser_tests.sh +++ b/script/local_browser_tests.sh @@ -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 # 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 script/websocket-server.rb stop diff --git a/test/browser/agent_ticket_actions_level1_test.rb b/test/browser/agent_ticket_actions_level1_test.rb index 2fac7b8e1..b94d1fdf7 100644 --- a/test/browser/agent_ticket_actions_level1_test.rb +++ b/test/browser/agent_ticket_actions_level1_test.rb @@ -118,11 +118,11 @@ class AgentTicketActionLevel1Test < TestCase :action => [ { :execute => 'click', - :css => '.active .actions button', + :css => '.active div[data-tab="ticket"] .js-actions .select-arrow', }, { :execute => 'click', - :css => '.active a[data-type="merge"]', + :css => '.active div[data-tab="ticket"] .js-actions a[data-type="ticket-merge"]', }, { :execute => 'wait', diff --git a/test/browser/agent_ticket_actions_level3_test.rb b/test/browser/agent_ticket_actions_level3_test.rb index 483c6bd97..29791adee 100644 --- a/test/browser/agent_ticket_actions_level3_test.rb +++ b/test/browser/agent_ticket_actions_level3_test.rb @@ -136,7 +136,7 @@ class AgentTicketActionsLevel3Test < TestCase { :where => :instance1, :execute => 'match', - :css => '.active div.ticket-article-view', + :css => '.active div.ticket-article', :value => 'some level 3 body in instance 2', :match_result => true, }, @@ -176,14 +176,14 @@ class AgentTicketActionsLevel3Test < TestCase { :where => :instance2, :execute => 'match', - :css => '.active div.ticket-article-view', + :css => '.active div.ticket-article', :value => 'some level 3 body in instance 1', :match_result => true, }, { :where => :instance2, :execute => 'match', - :css => '.active div.ticket-article-view', + :css => '.active div.ticket-article', :value => 'some level 3 body in instance 2', :match_result => true, }, @@ -310,7 +310,7 @@ class AgentTicketActionsLevel3Test < TestCase { :where => :instance2, :execute => 'match', - :css => '.active div.ticket-article-view', + :css => '.active div.ticket-article', :value => '22 some level 3 body in instance 2', :match_result => true, }, diff --git a/test/browser/agent_ticket_actions_level5_test.rb b/test/browser/agent_ticket_actions_level5_test.rb index 17fb567c1..e41928754 100644 --- a/test/browser/agent_ticket_actions_level5_test.rb +++ b/test/browser/agent_ticket_actions_level5_test.rb @@ -446,17 +446,15 @@ class AgentTicketActionLevel5Test < TestCase :execute => 'click', :css => 'a[href="#manage"]', }, - - # create ticket { :where => :instance2, :execute => 'click', - :css => '.content.active .tabsSidebar-tabs [data-tab="customer"]', + :css => '.active div[data-tab="ticket"] .js-actions .select-arrow', }, { :where => :instance2, :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',