Testing Wysihtml5 Field Integration in rails_admin
This test suite validates the Wysihtml5 rich text editor field integration within Rails Admin. It ensures proper initialization and configuration of the WYSIWYG editor component through integration testing.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
railsadminteam/rails_admin
spec/integration/fields/wysihtml5_spec.rb
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Wysihtml5 field', type: :request do
subject { page }
it 'works without error', js: true do
RailsAdmin.config Draft do
edit do
field :notes, :wysihtml5
end
end
expect { visit new_path(model_name: 'draft') }.not_to raise_error
is_expected.to have_selector('.wysihtml5-toolbar')
end
it 'should include custom wysihtml5 configuration' do
RailsAdmin.config Draft do
edit do
field :notes, :wysihtml5 do
config_options image: false
css_location 'stub_css.css'
js_location 'stub_js.js'
end
end
end
visit new_path(model_name: 'draft')
is_expected.to have_selector('textarea#draft_notes[data-richtext="bootstrap-wysihtml5"][data-options]')
end
end