-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintenance: Port i-doit browser integration test to capybara.
- Loading branch information
1 parent
43f0c68
commit 7739671
Showing
4 changed files
with
559 additions
and
246 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Ticket Handling with i-doit', integration: true, required_envs: %w[IDOIT_API_TOKEN IDOIT_API_ENDPOINT IDOIT_API_CATEGORY], type: :system, use_vcr: true do | ||
|
||
let(:api_endpoint) { ENV['IDOIT_API_ENDPOINT'] } | ||
let(:api_category) { ENV['IDOIT_API_CATEGORY'] } | ||
|
||
before do | ||
Setting.set('idoit_integration', true) | ||
Setting.set('idoit_config', { api_token: ENV['IDOIT_API_TOKEN'], endpoint: api_endpoint, client_id: '' }) | ||
end | ||
|
||
def open_idoit_sidebar | ||
find('.tabsSidebar svg.icon-printer').click | ||
end | ||
|
||
def select_entry_in_sidebar | ||
find('.sidebar[data-tab="idoit"] .js-headline').click | ||
find('.sidebar[data-tab="idoit"] .dropdown-menu').click | ||
entry_id = nil | ||
|
||
in_modal do | ||
find('form input.js-input').click | ||
find("form li.js-option[title='#{api_category}']").click | ||
entry_id = find('form.js-result tbody tr:first-child input').tap(&:click).value | ||
# submit the i-doit object selections | ||
find('form button.js-submit').click | ||
end | ||
|
||
entry_id | ||
end | ||
|
||
context 'when using the i-doit integration' do | ||
let(:agent) { create(:agent, groups: [Group.find_by(name: 'Users')]) } | ||
|
||
before do | ||
visit 'ticket/create' | ||
find('[name=customer_id_completion]').fill_in with: 'nico' | ||
page.find('li.recipientList-entry.js-object.is-active').click | ||
fill_in 'Title', with: 'subject - i-doit integration' | ||
set_editor_field_value('body', 'body - i-doit integration') | ||
end | ||
|
||
it 'does process i-doit information correctly', authenticated_as: :agent do | ||
|
||
within :active_content do | ||
# Select an item initially. | ||
open_idoit_sidebar | ||
entry_id = select_entry_in_sidebar | ||
item_link = ".sidebar[data-tab='idoit'] a[href='#{api_endpoint}/?objID=#{entry_id}']" | ||
expect(page).to have_css(item_link) | ||
|
||
# Reselect the customer and verify if object is still shown in sidebar. | ||
find('[name=customer_id_completion]').fill_in with: 'admin' | ||
page.find('li.recipientList-entry.js-object.is-active').click | ||
expect(page).to have_css(item_link) | ||
|
||
# Submit the ticket. | ||
find('.newTicket button.js-submit').click | ||
open_idoit_sidebar | ||
expect(page).to have_css(item_link) | ||
|
||
# Check it's still there after reload. | ||
page.refresh | ||
open_idoit_sidebar | ||
expect(page).to have_css(item_link) | ||
|
||
# Delete the item. | ||
find(".sidebar[data-tab='idoit'] .js-delete[data-object-id=\"#{entry_id}\"]").click | ||
expect(find(".sidebar[data-tab='idoit']")).to have_text('none') | ||
|
||
# Check if the item is still gone after reload. | ||
page.refresh | ||
open_idoit_sidebar | ||
expect(find(".sidebar[data-tab='idoit']")).to have_text('none') | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.