Fixes #2925 - Macros with notes not working on overview "drop bar".

This commit is contained in:
Rolf Schmidt 2020-12-08 10:17:21 +01:00 committed by Thorsten Eckel
parent d3ffac279a
commit 3530ea7787
5 changed files with 45 additions and 2 deletions

View file

@ -243,10 +243,13 @@ class App.TicketOverview extends App.Controller
for item in items for item in items
#console.log "perform action #{action} with id #{id} on ", $(item).val() #console.log "perform action #{action} with id #{id} on ", $(item).val()
ticket = App.Ticket.find($(item).val()) ticket = App.Ticket.find($(item).val())
article = {}
App.Ticket.macro( App.Ticket.macro(
macro: macro.perform macro: macro.perform
ticket: ticket ticket: ticket
article: article
) )
ticket.article = article
ticket.save( ticket.save(
done: (r) => done: (r) =>
@batchCountIndex++ @batchCountIndex++

View file

@ -167,7 +167,7 @@ class App.Ticket extends App.Model
else if attributes[0] is 'article' else if attributes[0] is 'article'
# preload required attributes # preload required attributes
if attributes[1] if !content.type_id
type = App.TicketArticleType.findByAttribute('name', attributes[1]) type = App.TicketArticleType.findByAttribute('name', attributes[1])
if type if type
params.article.type_id = type.id params.article.type_id = type.id

View file

@ -83,6 +83,16 @@ module BrowserTestHelper
page.driver.browser.action.move_by(x_axis, y_axis).perform page.driver.browser.action.move_by(x_axis, y_axis).perform
end end
# Moves the mouse to element.
#
# @example
# move_mouse_to(page.find('button.hover_me'))
#
def move_mouse_to(element)
element.in_fixed_position
page.driver.browser.action.move_to_location(element.native.location.x, element.native.location.y).perform
end
# Clicks and hold (without releasing) in the middle of the given element. # Clicks and hold (without releasing) in the middle of the given element.
# #
# @example # @example

View file

@ -33,7 +33,7 @@ Capybara.add_selector(:macro) do
end end
Capybara.add_selector(:macro_batch) do Capybara.add_selector(:macro_batch) do
css { |id| %(.batch-overlay-macro-entry[data-id='#{id}']) } css { |id| %(.batch-overlay-macro-entry[data-id='#{id}'] .batch-overlay-macro-entry-name) }
end end
Capybara.add_selector(:table_row) do Capybara.add_selector(:table_row) do

View file

@ -5,6 +5,7 @@ RSpec.describe 'Ticket views', type: :system do
let!(:group1) { create :group } let!(:group1) { create :group }
let!(:group2) { create :group } let!(:group2) { create :group }
let!(:macro_without_group) { create :macro } let!(:macro_without_group) { create :macro }
let!(:macro_note) { create :macro, perform: { 'article.note'=>{ 'body' => 'macro body', 'internal' => 'true', 'subject' => 'macro note' } } }
let!(:macro_group1) { create :macro, groups: [group1] } let!(:macro_group1) { create :macro, groups: [group1] }
let!(:macro_group2) { create :macro, groups: [group2] } let!(:macro_group2) { create :macro, groups: [group2] }
@ -85,6 +86,35 @@ RSpec.describe 'Ticket views', type: :system do
end end
end end
it 'can use macro to create article', authenticated_as: true do
refresh
visit '#ticket/view/all_open'
within(:active_content) do
ticket = page.find(:table_row, Ticket.first.id).native
# click and hold first ticket in table
click_and_hold(ticket)
# move ticket to y -ticket.location.y
move_mouse_by(0, -ticket.location.y + 5)
# move a bit to the left to display macro batches
move_mouse_by(-250, 0)
expect(page).to have_selector(:macro_batch, macro_note.id, wait: 10)
macro = find(:macro_batch, macro_note.id)
move_mouse_to(macro)
release_mouse
await_empty_ajax_queue
expect(Ticket.first.articles.last.subject).to eq('macro note')
end
end
end end
context 'bulk note', authenticated_as: :user do context 'bulk note', authenticated_as: :user do