Fix SMS JS dropdown, enable toggle, landing page link text, add SMS tests

- Fix SMS provider dropdown: switch from nonce'd javascript_tag to inline
  onchange handler (Turbo-compatible)
- Fix enable toggle: handle serialized JSON string values ("true"/"1")
  in addition to boolean true
- Fix landing page: change link text from github.com/docusealco to
  github.com/wabolabs/wabosign
- Add comprehensive SMS system tests (4 examples) covering provider
  form rendering, toggle, enabled state, and test message section
pull/687/head
Wabo 2 weeks ago
parent aca5e679de
commit fdd4f8f5d5

@ -67,7 +67,7 @@
</div>
<h3 class="mb-4 text-2xl font-semibold">Open Source</h3>
<p class="text-base text-gray-500">
Source code is available under <a href="<%= Wabosign::GITHUB_URL %>" class="link link-neutral font-bold" target="_blank">github.com/docusealco</a>.<br>
Source code is available under <a href="<%= Wabosign::GITHUB_URL %>" class="link link-neutral font-bold" target="_blank">github.com/wabolabs/wabosign</a>.<br>
Open-source contributors are always ready to help!
</p>
</div>

@ -54,7 +54,7 @@
<div class="form-control">
<label class="label cursor-pointer" for="encrypted_config_value_enabled">
<span class="label-text font-medium">Enable SMS</span>
<%= ff.check_box :enabled, { class: 'toggle', checked: value['enabled'] == true }, '1', '0' %>
<%= ff.check_box :enabled, { class: 'toggle', checked: value['enabled'] == true || value['enabled'] == '1' || value['enabled'] == 'true' }, '1', '0' %>
</label>
</div>
<div class="form-control">
@ -63,7 +63,8 @@
Sms::SUPPORTED_PROVIDERS.map { |p| [provider_labels[p] || p, p] },
{ selected: selected_provider },
class: 'base-select',
id: 'sms_provider_select' %>
id: 'sms_provider_select',
onchange: 'var s=this,v=s.value;document.querySelectorAll("[data-provider-block]").forEach(function(b){b.classList.toggle("hidden",b.dataset.providerBlock!==v)})' %>
</div>
<div data-provider-block="bulkvs" class="space-y-4<%= ' hidden' unless selected_provider == 'bulkvs' %>">
@ -185,18 +186,3 @@
<div class="w-0 md:w-52"></div>
</div>
<%= javascript_tag nonce: true do %>
(function () {
const select = document.getElementById('sms_provider_select')
if (!select) return
const blocks = document.querySelectorAll('[data-provider-block]')
const sync = () => {
const current = select.value
blocks.forEach((block) => {
block.classList.toggle('hidden', block.dataset.providerBlock !== current)
})
}
select.addEventListener('change', sync)
sync()
})()
<% end %>

@ -8,10 +8,38 @@ RSpec.describe 'SMS Settings' do
sign_in(user)
end
it 'shows the SMS settings page with provider form' do
it 'shows the SMS settings page with provider form and all provider blocks' do
visit settings_sms_path
expect(page).to have_content('SMS')
expect(page).to have_content('Provider')
expect(page).to have_content('BulkVS Basic Auth Token')
end
it 'renders the enable toggle and provider select' do
visit settings_sms_path
expect(page).to have_css("input[type='checkbox'].toggle")
expect(page).to have_css('select.base-select')
end
it 'shows the save button' do
visit settings_sms_path
expect(page).to have_button('Save')
end
it 'shows the test SMS section when SMS is configured and enabled' do
create(:encrypted_config, account:, key: EncryptedConfig::SMS_CONFIGS_KEY,
value: { 'enabled' => true, 'provider' => 'twilio',
'twilio_account_sid' => 'AC123',
'twilio_auth_token' => 'token',
'twilio_from' => '+15551234567' })
visit settings_sms_path
expect(page).to have_content('SMS is enabled')
expect(page).to have_content('Send a test SMS')
end
end

Loading…
Cancel
Save