killbill-payment-test-ui 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85649a8c931c0a7239ea2578a7c85dc67977de2178fb3f258ff41e80ba8758c3
4
- data.tar.gz: 9f9552881160054f9e1631303bb9422fd7ac125a4ff4ffab2a856e6b74f2c501
3
+ metadata.gz: 23ecd0c85e54cae7c993dcd993e6f453ffaf06234d2440418edbc591c8c7b4a2
4
+ data.tar.gz: 4d071a29ae872c2b969c1158e23c7a6b7001244f3af3ab3594819298627da795
5
5
  SHA512:
6
- metadata.gz: 89aec753646bea385406816fdffd5aa8c3b1ba914fd414f8f92f2222f9b1daa94d3458b732aff6bc6fd2cc1459e2929cace51089ead9829ce08090c11e6c0a3f
7
- data.tar.gz: 3185fac465e6649593af1ed5a5fb00bcaf51ca4ecace76524364ca901afecaa71207a78ce859020deb473bc6ed7b03e9d722f93bae5de0e17d7a05350a6594c8
6
+ metadata.gz: 0431d49f16d9db230476749fac3322742ccbc0eae40ba6beedcf9a7b16d31b88abe199ebaf70c85d05410a0af2c8b55a6aaecb09c5b95032b0f8e313f6e7e65f
7
+ data.tar.gz: d7b026ab346e5eed248a5b23e2d44205786589db31aa4d91c2879e9f2b437c2f8f123a6f532fa0c40f245daffb980e517620c010ae620e07392e00f288a3ed5e
@@ -12,28 +12,31 @@ module PaymentTest
12
12
  Rails.logger.warn("Failed to retrieve payment status : #{e}")
13
13
  end
14
14
 
15
+ states = raw_status&.dig('states') || {}
16
+ sleeps = raw_status&.dig('sleeps') || {}
17
+
15
18
  @status = if raw_status.nil?
16
19
  'UNKNOWN'
17
- elsif raw_status.key? :always_return_plugin_status_error.to_s
20
+ elsif states.empty? && sleeps.empty?
21
+ 'CLEAR'
22
+ elsif states.values.include?('ACTION_RETURN_PLUGIN_STATUS_ERROR')
18
23
  'RETURN ERROR'
19
- elsif raw_status.key? :always_return_plugin_status_pending.to_s
24
+ elsif states.values.include?('ACTION_RETURN_PLUGIN_STATUS_PENDING')
20
25
  'RETURN PENDING'
21
- elsif raw_status.key? :always_return_plugin_status_canceled.to_s
26
+ elsif states.values.include?('ACTION_RETURN_PLUGIN_STATUS_CANCELED')
22
27
  'RETURN CANCELED'
23
- elsif raw_status.key? :always_throw.to_s
28
+ elsif states.values.include?('ACTION_THROW_EXCEPTION')
24
29
  'RETURN THROW'
25
- elsif raw_status.key? :always_return_nil.to_s
26
- 'RETURN NULL '
27
- elsif raw_status.key? :sleep_time_sec.to_s
28
- "SLEEP #{sleep_time_sec}"
29
- else
30
- 'CLEAR'
30
+ elsif states.values.include?('RETURN_NIL')
31
+ 'RETURN NULL'
32
+ elsif sleeps.any?
33
+ "SLEEP #{sleeps.values.first}"
31
34
  end
32
35
 
33
- @methods = if raw_status.nil? || !raw_status.key?('methods') || raw_status['methods'].empty?
36
+ @methods = if states.empty?
34
37
  ['*']
35
38
  else
36
- raw_status['methods']
39
+ states.keys
37
40
  end
38
41
  end
39
42
 
@@ -43,20 +46,24 @@ module PaymentTest
43
46
 
44
47
  begin
45
48
  ::Killbill::PaymentTest::PaymentTestClient.send(target_method, nil, options_for_klient)
49
+ flash[:notice] = "Status set to #{new_state}"
46
50
  rescue StandardError => e
47
51
  flash[:error] = "Failed to set state: #{e}"
52
+ Rails.logger.error("Failed to set state: #{e.message}\n#{e.backtrace.join("\n")}")
48
53
  end
49
54
 
50
- redirect_to root_path and return
55
+ redirect_to payment_test_engine.root_path and return
51
56
  end
52
57
 
53
58
  def reset
54
59
  begin
55
60
  ::Killbill::PaymentTest::PaymentTestClient.reset(nil, options_for_klient)
61
+ flash[:notice] = 'Status cleared'
56
62
  rescue StandardError => e
57
63
  flash[:error] = "Failed to reset state: #{e}"
64
+ Rails.logger.error("Failed to reset state: #{e.message}\n#{e.backtrace.join("\n")}")
58
65
  end
59
- redirect_to root_path and return
66
+ redirect_to payment_test_engine.root_path and return
60
67
  end
61
68
  end
62
69
  end
@@ -1,8 +1,31 @@
1
1
  <%#
2
- This is a placeholder menu dropdown component for standalone gem usage.
2
+ Menu dropdown component for payment test UI.
3
3
 
4
- This placeholder prevents "missing template" errors when running
5
- the gem independently during development or testing.
4
+ Locals:
5
+ - variant: CSS class for button styling (e.g., "btn-light")
6
+ - label: Button label text
7
+ - dropdown_id: Unique ID for the dropdown
8
+ - html_class: Additional CSS classes
9
+ - menu_items: Array of { label:, url:, method: } hashes
6
10
  %>
7
11
 
8
- <!-- Menu dropdown placeholder for standalone gem -->
12
+ <div class="dropdown d-inline-block <%= local_assigns[:html_class] %>">
13
+ <button class="btn <%= local_assigns[:variant] || 'btn-secondary' %> btn-sm dropdown-toggle"
14
+ type="button"
15
+ id="<%= local_assigns[:dropdown_id] || 'menuDropdown' %>"
16
+ data-bs-toggle="dropdown"
17
+ aria-expanded="false">
18
+ <%= local_assigns[:label] || 'Menu' %>
19
+ </button>
20
+ <ul class="dropdown-menu" aria-labelledby="<%= local_assigns[:dropdown_id] || 'menuDropdown' %>">
21
+ <% (local_assigns[:menu_items] || []).each do |item| %>
22
+ <li>
23
+ <% if item[:method] && item[:method] != :get %>
24
+ <%= link_to item[:label], item[:url], method: item[:method], class: 'dropdown-item' %>
25
+ <% else %>
26
+ <%= link_to item[:label], item[:url], class: 'dropdown-item' %>
27
+ <% end %>
28
+ </li>
29
+ <% end %>
30
+ </ul>
31
+ </div>
@@ -28,21 +28,63 @@
28
28
  <th>Method</th>
29
29
  <th class="d-flex align-items-center">
30
30
  <span>Status </span>
31
- <% menu_items = [
32
- { label: 'Clear all status', url: reset_path, method: :post },
33
- { label: 'Configure ERROR', url: set_failed_state_path(:state => :ERROR), method: :post },
34
- { label: 'Configure PENDING', url: set_failed_state_path(:state => :PENDING), method: :post },
35
- { label: 'Configure CANCELED', url: set_failed_state_path(:state => :CANCELED), method: :post },
36
- { label: 'Configure THROW', url: set_failed_state_path(:state => :THROW), method: :post }
37
- ] %>
31
+ <div class="dropdown dropdown-menu-end position-relative ms-2" id="statusDropdown_wrapper">
32
+ <button type="button" class="btn kaui-dropdown custom-hover btn-light select-status" id="statusDropdown_button" aria-expanded="false">
33
+ Set status
34
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" style="margin-left: 4px;">
35
+ <path d="M4 6L8 10L12 6" stroke="#495057" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
36
+ </svg>
37
+ </button>
38
+ <ul class="dropdown-menu header-menu shadow border-0 rounded-3" id="statusDropdown_menu" style="min-width: 12rem; display: none; position: absolute; z-index: 1000;">
39
+ <li>
40
+ <%= button_to reset_path, method: :post, class: 'dropdown-item d-flex align-items-center gap-2 py-2 px-3', style: 'background: none; border: none; width: 100%; text-align: left; font-size: 0.875rem; cursor: pointer;', form_class: 'mb-0 w-100' do %>
41
+ <span style="font-weight: 500; font-size: 0.875rem; color: #344054;">Clear all status</span>
42
+ <% end %>
43
+ </li>
44
+ <li>
45
+ <%= button_to set_failed_state_path(state: :ERROR), method: :post, class: 'dropdown-item d-flex align-items-center gap-2 py-2 px-3', style: 'background: none; border: none; width: 100%; text-align: left; font-size: 0.875rem; cursor: pointer;', form_class: 'mb-0 w-100' do %>
46
+ <span style="font-weight: 500; font-size: 0.875rem; color: #344054;">Configure ERROR</span>
47
+ <% end %>
48
+ </li>
49
+ <li>
50
+ <%= button_to set_failed_state_path(state: :PENDING), method: :post, class: 'dropdown-item d-flex align-items-center gap-2 py-2 px-3', style: 'background: none; border: none; width: 100%; text-align: left; font-size: 0.875rem; cursor: pointer;', form_class: 'mb-0 w-100' do %>
51
+ <span style="font-weight: 500; font-size: 0.875rem; color: #344054;">Configure PENDING</span>
52
+ <% end %>
53
+ </li>
54
+ <li>
55
+ <%= button_to set_failed_state_path(state: :CANCELED), method: :post, class: 'dropdown-item d-flex align-items-center gap-2 py-2 px-3', style: 'background: none; border: none; width: 100%; text-align: left; font-size: 0.875rem; cursor: pointer;', form_class: 'mb-0 w-100' do %>
56
+ <span style="font-weight: 500; font-size: 0.875rem; color: #344054;">Configure CANCELED</span>
57
+ <% end %>
58
+ </li>
59
+ <li>
60
+ <%= button_to set_failed_state_path(state: :THROW), method: :post, class: 'dropdown-item d-flex align-items-center gap-2 py-2 px-3', style: 'background: none; border: none; width: 100%; text-align: left; font-size: 0.875rem; cursor: pointer;', form_class: 'mb-0 w-100' do %>
61
+ <span style="font-weight: 500; font-size: 0.875rem; color: #344054;">Configure THROW</span>
62
+ <% end %>
63
+ </li>
64
+ </ul>
65
+ </div>
66
+ <%= javascript_tag do %>
67
+ document.addEventListener('DOMContentLoaded', function () {
68
+ const button = document.getElementById('statusDropdown_button');
69
+ const menu = document.getElementById('statusDropdown_menu');
70
+ const wrapper = document.getElementById('statusDropdown_wrapper');
38
71
 
39
- <%= render partial: "kaui/components/menu_dropdown/menu_dropdown", locals: {
40
- variant: "btn-light",
41
- label: raw("Set status&nbsp;"),
42
- dropdown_id: "statusDropdown",
43
- html_class: "select-status",
44
- menu_items: menu_items
45
- } %>
72
+ button.addEventListener('click', function (e) {
73
+ e.stopPropagation();
74
+ const isShown = menu.style.display === 'block';
75
+ document.querySelectorAll('.dropdown-menu').forEach(function (m) {
76
+ if (m !== menu) { m.style.display = 'none'; }
77
+ });
78
+ menu.style.display = isShown ? 'none' : 'block';
79
+ });
80
+
81
+ document.addEventListener('click', function (e) {
82
+ if (!wrapper.contains(e.target)) {
83
+ menu.style.display = 'none';
84
+ }
85
+ });
86
+ });
87
+ <% end %>
46
88
  </th>
47
89
  </tr>
48
90
  </thead>
@@ -61,4 +103,4 @@
61
103
  </div>
62
104
  </div>
63
105
  </div>
64
- </div>
106
+ </div>
@@ -49,9 +49,9 @@ module Killbill
49
49
  'CONFIGURE_ACTION' => action
50
50
  }
51
51
 
52
- body['SLEEP_TIME_SEC'] = arg if action == 'ACTION_CLEAR'
52
+ body['SLEEP_TIME_SEC'] = arg if action == 'ACTION_SLEEP' && arg.present?
53
53
 
54
- body['METHODS'] = methods&.join(',')
54
+ body['METHODS'] = methods.join(',') if methods.present?
55
55
 
56
56
  KillBillClient::API.post "#{KILLBILL_PAYMENT_TEST_PREFIX}/configure",
57
57
  body.to_json,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaymentTest
4
- VERSION = '4.0.1'
4
+ VERSION = '4.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-payment-test-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-11 00:00:00.000000000 Z
11
+ date: 2026-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: killbill-assets-ui