Skip to content

Commit

Permalink
Maintenance: Add test for ticket create from template in desktop view
Browse files Browse the repository at this point in the history
  • Loading branch information
mgruner committed Sep 3, 2024
1 parent 98f3e11 commit 8080220
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ const submitCreateTicket = async (event: FormSubmitData<TicketFormData>) => {
>
<div class="w-full max-w-screen-2xl px-28 pt-3.5">
<Form
id="ticket-create"
ref="form"
:key="tabId"
:form-id="activeTaskbarTabFormId"
Expand Down
6 changes: 3 additions & 3 deletions i18n/zammad.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ msgstr ""
#: app/frontend/apps/desktop/pages/authentication/views/PasswordResetVerify.vue:158
#: app/frontend/apps/desktop/pages/authentication/views/Signup.vue:140
#: app/frontend/apps/desktop/pages/ticket/components/TicketSidebar/TicketSidebarSharedDraftStart/TicketSidebarSharedDraftFlyout.vue:188
#: app/frontend/apps/desktop/pages/ticket/views/TicketCreate.vue:424
#: app/frontend/apps/desktop/pages/ticket/views/TicketCreate.vue:425
msgid "Cancel & Go Back"
msgstr ""

Expand Down Expand Up @@ -3363,7 +3363,7 @@ msgstr ""
#: app/assets/javascripts/app/views/widget/shared_draft.jst.eco:4
#: app/frontend/apps/desktop/components/Form/fields/FieldGroupPermissions/FieldGroupPermissionsInput.vue:44
#: app/frontend/apps/desktop/pages/personal-setting/components/PersonalSettingNewAccessTokenFlyout.vue:119
#: app/frontend/apps/desktop/pages/ticket/views/TicketCreate.vue:436
#: app/frontend/apps/desktop/pages/ticket/views/TicketCreate.vue:437
#: app/frontend/apps/mobile/pages/ticket/views/TicketCreate.vue:487
msgid "Create"
msgstr ""
Expand Down Expand Up @@ -4920,7 +4920,7 @@ msgstr ""
#: app/assets/javascripts/app/controllers/taskbar_widget.coffee:128
#: app/assets/javascripts/app/views/object_manager/index.jst.eco:37
#: app/frontend/apps/desktop/components/CommonConfirmationDialog/CommonConfirmationDialog.vue:47
#: app/frontend/apps/desktop/pages/ticket/views/TicketCreate.vue:421
#: app/frontend/apps/desktop/pages/ticket/views/TicketCreate.vue:422
msgid "Discard Changes"
msgstr ""

Expand Down
2 changes: 2 additions & 0 deletions spec/factories/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
customer { association :customer }
group { Group.first }
owner { association :agent }
tags { [] }
end

trait :dummy_data do
Expand All @@ -26,6 +27,7 @@
'ticket.customer_id' => { value: customer.id, value_completion: "#{customer.firstname} #{customer.lastname} <#{customer.email}>" },
'ticket.group_id' => { value: group.id },
'ticket.owner_id' => { value: owner.id },
'ticket.tags' => { value: tags.join(',') }
}
end
end
Expand Down
65 changes: 65 additions & 0 deletions spec/system/apps/desktop/ticket/create_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/

require 'rails_helper'

RSpec.describe 'Desktop > Ticket > Create', app: :desktop_view, authenticated_as: :agent, type: :system do
let(:agent) { create(:agent, groups: [group]) }
let(:group) { create(:group) }

context 'when creating a ticket from a template', db_strategy: :reset do

# Activate ticket type field.
before do
ObjectManager::Attribute.get(object: 'Ticket', name: 'type').tap do |oa|
oa.active = true
oa.save!
end
ObjectManager::Attribute.migration_execute
end

let(:ticket_type) { create(:ticket_type) }
let(:customer) { create(:customer, :with_org) }
let!(:template) do
create(
:template,
:dummy_data,
title: 'Template Ticket Title',
body: 'Template Ticket Body',
tags: %w[foo bar],
customer:,
group:,
).tap do |template|
template['options']['ticket.type'] = { 'value' => 'Problem' }
template.save!
end
end

it 'applies the template correctly' do

skip 'Pending fix for https://github.com/zammad/coordination-desktop-view/issues/234'

visit '/ticket/create'
wait_for_form_updater
wait_for_form_to_settle('ticket-create')

click_on 'Apply Template'
click_on template.name
expect(page).to have_text(customer.fullname)
wait_for_gql('shared/entities/user/graphql/queries/user.graphql')

click_on 'Create'
wait_for_gql('shared/entities/ticket/graphql/mutations/create.graphql')

expect(page).to have_text('Ticket has been created successfully')

expect(Ticket.last).to have_attributes(
title: 'Template Ticket Title',
customer: customer,
type: 'Problem',
)
expect(Ticket.last.articles.first.body).to include('Template Ticket Body')
expect(Tag.tag_list(object: 'Ticket', o_id: Ticket.last.id)).to eq(%w[foo bar])
end
end

end

0 comments on commit 8080220

Please sign in to comment.