[28399] Fix embedded table editing

https://community.openproject.com/wp/28399
pull/6827/head
Oliver Günther 6 years ago
parent 20c951f1e0
commit f55e102029
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 5
      app/assets/stylesheets/my_project_page/my_projects_overview.sass
  2. 2
      app/views/my_projects_overviews/_block_textilizable.html.erb
  3. 76
      spec/features/block_editing_spec.rb

@ -40,4 +40,7 @@ div.overview
.textile-form-wrapper .textile-form-wrapper
padding-top: 50px padding-top: 50px
.textile-form
cursor: initial

@ -56,7 +56,7 @@ See doc/COPYRIGHT.md for more details.
<div class="form--field-container" ng-non-bindable> <div class="form--field-container" ng-non-bindable>
<%= styled_text_area_tag "textile_#{block_name}", <%= styled_text_area_tag "textile_#{block_name}",
textile.html_safe, textile,
class: 'wiki-edit', class: 'wiki-edit',
with_text_formatting: true, with_text_formatting: true,
resource: resource %> resource: resource %>

@ -39,7 +39,9 @@ describe 'My project page editing', type: :feature, js: true do
member_in_project: project, member_in_project: project,
member_through_role: role } member_through_role: role }
let(:role) { FactoryBot.create :role, permissions: [:view_project, let(:role) { FactoryBot.create :role, permissions: [:view_project,
:edit_project] } :view_work_packages,
:edit_work_packages,
:edit_project] }
# Add block select # Add block select
let(:select) { find('#block-select') } let(:select) { find('#block-select') }
@ -193,6 +195,78 @@ describe 'My project page editing', type: :feature, js: true do
expect(page).to have_no_selector('#block_a') expect(page).to have_no_selector('#block_a')
end end
describe 'macro elements' do
let!(:work_package) { FactoryBot.create(:work_package, project: project) }
let(:modal) { ::Components::WorkPackages::TableConfigurationModal.new }
let(:filters) { ::Components::WorkPackages::TableConfiguration::Filters.new }
let(:columns) { ::Components::WorkPackages::Columns.new }
it 'should allow to add and edit macros (Regression test #28399)' do
select.find('option[value=custom_element]').select_option
expect(page).to have_selector('.op-ckeditor--wrapper')
expect(page).to have_selector('.ck-content')
editor.in_editor do |_container, editable|
editor.insert_macro 'Embed work package table'
editor.set_markdown 'test'
modal.expect_open
modal.switch_to 'Filters'
filters.expect_filter_count 1
filters.add_filter_by('Type', 'is', work_package.type.name)
modal.switch_to 'Columns'
columns.assume_opened
columns.uncheck_all save_changes: false
columns.add 'ID', save_changes: false
columns.add 'Subject', save_changes: false
columns.add 'Type', save_changes: false
columns.expect_checked 'ID'
columns.expect_checked 'Subject'
columns.expect_checked 'Type'
# Save widget
modal.save
# Find widget, click to show toolbar
expect(editable).to have_selector('.ck-widget.macro.-embedded-table')
end
# Save textile block
find('#a-form-submit').click
save_changes.click
# Revisit page
visit my_projects_overview_path(project)
expect(page).to have_selector('#block_a')
find('.edit-textilizable').click
editor.in_editor do |_container, editable|
# Find widget, click to show toolbar
macro = editable.find('.ck-widget.macro.-embedded-table')
macro.click
# Edit widget again
page.find('.ck-balloon-panel .ck-button', visible: :all, text: 'Edit').click
modal.expect_open
modal.switch_to 'Filters'
filters.expect_filter_count 2
modal.switch_to 'Columns'
columns.assume_opened
columns.expect_checked 'ID'
columns.expect_checked 'Subject'
columns.expect_checked 'Type'
modal.cancel
end
find('#block_a .textile-form .reset-textilizable').click
end
end
context 'as regular user' do context 'as regular user' do
let(:permissions) { %i(view_project) } let(:permissions) { %i(view_project) }
let(:role) { FactoryBot.create :role, permissions: permissions } let(:role) { FactoryBot.create :role, permissions: permissions }

Loading…
Cancel
Save