diff --git a/test/fixtures/active_storage/blobs.yml b/test/fixtures/active_storage/blobs.yml index 34408e956..f23095067 100644 --- a/test/fixtures/active_storage/blobs.yml +++ b/test/fixtures/active_storage/blobs.yml @@ -1,9 +1,9 @@ default: key: 123abc - filename: default.jpg + filename: image.jpg content_type: image/jpg - byte_size: 12345 - checksum: 123abc + byte_size: 6400 + checksum: 028ad8393792078a9d3fd93343a3387b fragment: key: 456def diff --git a/test/fixtures/comfy/cms/files.yml b/test/fixtures/comfy/cms/files.yml index 2b361ff2e..218692ac8 100644 --- a/test/fixtures/comfy/cms/files.yml +++ b/test/fixtures/comfy/cms/files.yml @@ -2,4 +2,4 @@ default: site: default label: default file description: default description - position: 0 \ No newline at end of file + position: 0 diff --git a/test/fixtures/comfy/cms/layouts.yml b/test/fixtures/comfy/cms/layouts.yml index 85c44c66e..1b96c195a 100644 --- a/test/fixtures/comfy/cms/layouts.yml +++ b/test/fixtures/comfy/cms/layouts.yml @@ -33,10 +33,21 @@ child: js: child_js position: 0 -with_attachments: +text_content: site: default - label: Default Layout with Attachments - identifier: with_attachments + label: Default Layout with text content + identifier: text_content + parent: + content: |- + {{cms:text content}} + css: default_css + js: default_js + position: 0 + +text_content_with_attachments: + site: default + label: Default Layout with with text content and attachments + identifier: text_content_with_attachments parent: content: |- {{cms:text content}} diff --git a/test/fixtures/comfy/cms/pages.yml b/test/fixtures/comfy/cms/pages.yml index dde17cc2b..797c12c26 100644 --- a/test/fixtures/comfy/cms/pages.yml +++ b/test/fixtures/comfy/cms/pages.yml @@ -23,15 +23,29 @@ child: position: 0 is_published: true -with_attachments: +text_content: site: default parent: target_page: - layout: with_attachments - label: Default Page with Attachments - slug: 'with-attachments' - full_path: '/with-attachments' + layout: text_content + label: Default Page with text content + slug: 'text-content' + full_path: '/text-content' children_count: 0 position: 1 is_published: true content_cache: + + +text_content_with_attachments: + site: default + parent: + target_page: + layout: text_content_with_attachments + label: Default Page with text content and attachments + slug: 'text-content-with-attachments' + full_path: '/text-content-with-attachments' + children_count: 0 + position: 2 + is_published: true + content_cache: diff --git a/test/system/files_frontend_test.rb b/test/system/files_frontend_test.rb index 04bea022d..f440bd23a 100644 --- a/test/system/files_frontend_test.rb +++ b/test/system/files_frontend_test.rb @@ -9,14 +9,26 @@ class FilesFrontendTest < ApplicationSystemTestCase end def test_site_file_drag_and_drop - skip "TODO: Write this test" + file = comfy_cms_files(:default) + file.attachment = ActiveStorage::Blob.create_after_upload!( + io: file_fixture("image.jpg").open, filename: "image.jpg", content_type: "image/jpg") + file.save! + + visit_p edit_comfy_admin_cms_site_page_path(site_id: @site, id: comfy_cms_pages(:text_content)) + click_link title: "Open library" + + skip "Drag'n'drop from iframe to parent has issues: +https://github.com/SeleniumHQ/selenium/issues/810" + drop_target = content_field + within_frame(:css, ".cms-files-modal iframe") do + find_link(file.label).drag_to(drop_target) + end + assert_equal "{{ cms:file_link #{file.id} }}", content_field.value end def test_page_file_drag_and_drop - page = comfy_cms_pages(:with_attachments) - - # Upload a file. - visit_p edit_comfy_admin_cms_site_page_path(site_id: @site, id: page) + # Upload a page file. + visit_p edit_comfy_admin_cms_site_page_path(site_id: @site, id: comfy_cms_pages(:text_content_with_attachments)) attach_file Rails.root.join("test/fixtures/files/image.jpg"), name: "page[fragments_attributes][1][files][]", multiple: true click_button I18n.t("comfy.admin.cms.pages.form.update") @@ -24,9 +36,14 @@ def test_page_file_drag_and_drop # Dragging the link should generate CMS markup. skip "Drag'n'drop does not work for some reason" - content_field = find_field(name: "page[fragments_attributes][0][content]") find_link("image.jpg").drag_to(content_field) assert_equal '{{ cms:page_file_link attachments, filename: "image.jpg", as: image }}', content_field.value end +private + + def content_field + find_field(name: "page[fragments_attributes][0][content]") + end + end