Add specs for editor in nested resources

Этот коммит содержится в:
Mattia Roccoberton
2020-09-03 11:32:46 +02:00
родитель 668bd642e5
Коммит 135a56dc03
6 изменённых файлов: 53 добавлений и 4 удалений

Просмотреть файл

@@ -9,7 +9,7 @@ RSpec.describe 'Quill editor', type: :system do
end
after do
post.destroy
Post.destroy_all
author.destroy
end
@@ -18,6 +18,7 @@ RSpec.describe 'Quill editor', type: :system do
visit "/admin/posts/#{post.id}/edit"
expect(page).to have_css('#post_description_input .ql-editor', text: 'Some content...')
find('#post_description_input .ql-editor').click
find('#post_description_input .ql-editor').base.send_keys('more text')
find('[type="submit"]').click
@@ -25,4 +26,21 @@ RSpec.describe 'Quill editor', type: :system do
expect(post.reload.description).to eq '<p>Some content...more text</p>'
end
end
context 'with a Quill editor in a nested resource' do
it 'updates some HTML content of a new nested resource' do
visit "/admin/authors/#{author.id}/edit"
expect(page).to have_css('.posts.has_many_container .ql-editor', text: 'Some content...')
find('.posts.has_many_container .has_many_add').click
expect(page).to have_css('.posts.has_many_container .ql-editor', count: 2)
fill_in('author[posts_attributes][1][title]', with: 'A new post')
find('#author_posts_attributes_1_description_input .ql-editor').base.send_keys('new post text')
find('[type="submit"]').click
expect(page).to have_content('was successfully updated')
expect(author.posts.last.description).to eq '<p>new post text</p>'
end
end
end