Skip to content

Commit

Permalink
Maintenance: Port i-doit browser integration test to capybara.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfschmidt committed Apr 19, 2023
1 parent 43f0c68 commit 7739671
Show file tree
Hide file tree
Showing 4 changed files with 559 additions and 246 deletions.
5 changes: 0 additions & 5 deletions .gitlab/ci/browser/integration_minitest_idoit.yml

This file was deleted.

81 changes: 81 additions & 0 deletions spec/system/ticket/idoit_spec.rb
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
Loading

0 comments on commit 7739671

Please sign in to comment.