From 486100bf53cbe542e5e7f50e7d2f4b982c4ca9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 18 Jan 2019 15:03:19 +0100 Subject: [PATCH] Add specs for custom page cards --- spec/features/admin/widgets/cards_spec.rb | 52 +++++++++++++++++++ .../site_customization/custom_pages_spec.rb | 9 ++++ 2 files changed, 61 insertions(+) diff --git a/spec/features/admin/widgets/cards_spec.rb b/spec/features/admin/widgets/cards_spec.rb index 97571bf32..27f6a4d2b 100644 --- a/spec/features/admin/widgets/cards_spec.rb +++ b/spec/features/admin/widgets/cards_spec.rb @@ -130,6 +130,58 @@ feature 'Cards' do end end + context "Page card" do + let!(:custom_page) { create(:site_customization_page) } + + scenario "Create", :js do + visit admin_site_customization_pages_path + click_link "See Cards" + click_link "Create card" + + fill_in "Title", with: "Card for a custom page" + click_button "Create card" + + expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page) + expect(page).to have_content "Card for a custom page" + end + + scenario "Edit", :js do + create(:widget_card, page: custom_page, title: "Original title") + + visit admin_site_customization_page_cards_path(custom_page) + + expect(page).to have_content("Original title") + + click_link "Edit" + + within(".translatable-fields") do + fill_in "Title", with: "Updated title" + end + + click_button "Save card" + + expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page) + expect(page).to have_content "Updated title" + expect(page).not_to have_content "Original title" + end + + scenario "Destroy", :js do + create(:widget_card, page: custom_page, title: "Card title") + + visit admin_site_customization_page_cards_path(custom_page) + + expect(page).to have_content("Card title") + + accept_confirm do + click_link "Delete" + end + + expect(page).to have_current_path admin_site_customization_page_cards_path(custom_page) + expect(page).not_to have_content "Card title" + end + + end + end pending "add image expectactions" diff --git a/spec/features/site_customization/custom_pages_spec.rb b/spec/features/site_customization/custom_pages_spec.rb index 662388ef2..b3b478698 100644 --- a/spec/features/site_customization/custom_pages_spec.rb +++ b/spec/features/site_customization/custom_pages_spec.rb @@ -135,6 +135,15 @@ feature "Custom Pages" do expect(page).to have_selector("h1", text: "Another custom page") expect(page).to have_content("Subtitle for custom page") end + + scenario "Show widget cards for that page" do + custom_page = create(:site_customization_page, :published) + create(:widget_card, page: custom_page, title: "Card Highlights") + + visit custom_page.url + + expect(page).to have_content "Card Highlights" + end end end end