summaryrefslogtreecommitdiff
path: root/spec/features/admin/admin_hook_logs_spec.rb
blob: 34208cca1130ac01c1f67d04606f00c1b21f7218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Admin::HookLogs', feature_category: :integrations do
  let_it_be(:system_hook) { create(:system_hook) }
  let_it_be(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: 'some error') }
  let_it_be(:admin) { create(:admin) }

  before do
    sign_in(admin)
    gitlab_enable_admin_mode_sign_in(admin)
  end

  it 'show list of hook logs' do
    hook_log
    visit edit_admin_hook_path(system_hook)

    expect(page).to have_content('Recent events')
    expect(page).to have_link('View details', href: admin_hook_hook_log_path(system_hook, hook_log))
  end

  it 'show hook log details' do
    hook_log
    visit edit_admin_hook_path(system_hook)
    click_link 'View details'

    expect(page).to have_content("POST #{hook_log.url}")
    expect(page).to have_content(hook_log.internal_error_message)
    expect(page).to have_content('Resend Request')
  end

  it 'retry hook log' do
    WebMock.stub_request(:post, system_hook.url)

    hook_log
    visit edit_admin_hook_path(system_hook)
    click_link 'View details'
    click_link 'Resend Request'

    expect(page).to have_current_path(edit_admin_hook_path(system_hook), ignore_query: true)
  end

  context 'response data is too large' do
    let(:hook_log) { create(:web_hook_log, web_hook: system_hook, request_data: WebHookLog::OVERSIZE_REQUEST_DATA) }

    it 'shows request data as too large and disables retry function' do
      visit(admin_hook_hook_log_path(system_hook, hook_log))

      expect(page).to have_content('Request data is too large')
      expect(page).not_to have_button(
        _('Resent request'),
        disabled: true, class: 'has-tooltip', title: _("Request data is too large")
      )
    end
  end
end