A platform for community discussion. Free, open, simple.
DEV: Add more granularity to the core features specs shared example
Loïc Guitaut05f533ee0e19
diff --git a/spec/support/shared_examples/core_features.rb b/spec/support/shared_examples/core_features.rbindex d6c634f7d3f..5f3b58b796a 100644--- a/spec/support/shared_examples/core_features.rb+++ b/spec/support/shared_examples/core_features.rb@@ -32,22 +32,24 @@ RSpec.shared_examples_for "having working core features" do |skip_examples: []|if skip_examples.exclude?(:topics)describe "Topics" do- context "with an anonymous user" do- before { visit "/" }+ if skip_examples.exclude?(:"topics:read")+ context "with an anonymous user" do+ before { visit "/" }- it "lists latest topics" do- expect(page).to have_css(".topic-list-item", count: 4)- end+ it "lists latest topics" do+ expect(page).to have_css(".topic-list-item", count: 4)+ end- it "lists topics for a category" do- within("#sidebar-section-content-categories") { click_on("General") }- expect(page).to have_css(".topic-list-item", count: 3)- end+ it "lists topics for a category" do+ within("#sidebar-section-content-categories") { click_on("General") }+ expect(page).to have_css(".topic-list-item", count: 3)+ end- it "displays a specific topic" do- click_on(topics.first.title)- expect(page).to have_content(topics.first.title)- expect(page).to have_content(topics.first.first_post.raw)+ it "displays a specific topic" do+ click_on(topics.first.title)+ expect(page).to have_content(topics.first.title)+ expect(page).to have_content(topics.first.first_post.raw)+ endendend@@ -57,40 +59,46 @@ RSpec.shared_examples_for "having working core features" do |skip_examples: []|visit "/"end- it "lists latest topics" do- expect(page).to have_css(".topic-list-item", count: 4)- end-- it "lists topics for a category" do- within("#sidebar-section-content-categories") { click_on("General") }- expect(page).to have_css(".topic-list-item", count: 3)- end-- it "displays a specific topic" do- click_on(topics.first.title)- expect(page).to have_content(topics.first.title)- expect(page).to have_content(topics.first.first_post.raw)- end-- it "replies in a topic" do- click_on(topics.first.title)- expect(page).to have_content(topics.first.first_post.raw)- within(".actions") { click_button("Reply") }- composer.focus- send_keys("This is a long enough reply.")- expect(page).to have_css(".d-editor-preview p", visible: true)- within(".save-or-cancel") { click_button("Reply") }- expect(page).to have_content("This is a long enough reply.")- end-- it "creates a new topic" do- find("#create-topic", visible: true).click- composer.fill_title("This is a new topic")- composer.fill_content("This is a long enough sentence.")- expect(page).to have_css(".d-editor-preview p", visible: true)- within(".save-or-cancel") { click_button("Create Topic") }- expect(page).to have_content("This is a new topic")- expect(page).to have_content("This is a long enough sentence.")+ if skip_examples.exclude?(:"topics:read")+ it "lists latest topics" do+ expect(page).to have_css(".topic-list-item", count: 4)+ end++ it "lists topics for a category" do+ within("#sidebar-section-content-categories") { click_on("General") }+ expect(page).to have_css(".topic-list-item", count: 3)+ end++ it "displays a specific topic" do+ click_on(topics.first.title)+ expect(page).to have_content(topics.first.title)+ expect(page).to have_content(topics.first.first_post.raw)+ end+ end++ if skip_examples.exclude?(:"topics:reply")+ it "replies in a topic" do+ click_on(topics.first.title)+ expect(page).to have_content(topics.first.first_post.raw)+ within(".actions") { click_button("Reply") }+ composer.focus+ send_keys("This is a long enough reply.")+ expect(page).to have_css(".d-editor-preview p", visible: true)+ within(".save-or-cancel") { click_button("Reply") }+ expect(page).to have_content("This is a long enough reply.")+ end+ end++ if skip_examples.exclude?(:"topics:create")+ it "creates a new topic" do+ find("#create-topic", visible: true).click+ composer.fill_title("This is a new topic")+ composer.fill_content("This is a long enough sentence.")+ expect(page).to have_css(".d-editor-preview p", visible: true)+ within(".save-or-cancel") { click_button("Create Topic") }+ expect(page).to have_content("This is a new topic")+ expect(page).to have_content("This is a long enough sentence.")+ endendendend@@ -158,42 +166,50 @@ RSpec.shared_examples_for "having working core features" do |skip_examples: []|after { SearchIndexer.disable }context "with an anonymous user" do- it "searches using the quick search" do- visit("/")- search_page.click_search_icon- search_page.type_in_search_menu(topics.first.title)- search_page.click_search_menu_link- expect(search_page).to have_topic_title_for_first_search_result(topics.first.title)+ if skip_examples.exclude?(:"search:quick_search")+ it "searches using the quick search" do+ visit("/")+ search_page.click_search_icon+ search_page.type_in_search_menu(topics.first.title)+ search_page.click_search_menu_link+ expect(search_page).to have_topic_title_for_first_search_result(topics.first.title)+ endend- it "searches using the full page search" do- visit("/search")+ if skip_examples.exclude?(:"search:full_page")+ it "searches using the full page search" do+ visit("/search")- search_page.type_in_search(topics.first.title)- search_page.click_search_button+ search_page.type_in_search(topics.first.title)+ search_page.click_search_button- expect(search_page).to have_search_result+ expect(search_page).to have_search_result+ endendendcontext "with a logged in user" dobefore { sign_in(active_user) }- it "searches using the quick search" do- visit("/")- search_page.click_search_icon- search_page.type_in_search_menu(topics.first.title)- search_page.click_search_menu_link- expect(search_page).to have_topic_title_for_first_search_result(topics.first.title)+ if skip_examples.exclude?(:"search:quick_search")+ it "searches using the quick search" do+ visit("/")+ search_page.click_search_icon+ search_page.type_in_search_menu(topics.first.title)+ search_page.click_search_menu_link+ expect(search_page).to have_topic_title_for_first_search_result(topics.first.title)+ endend- it "searches using the full page search" do- visit("/search")+ if skip_examples.exclude?(:"search:full_page")+ it "searches using the full page search" do+ visit("/search")- search_page.type_in_search(topics.first.title)- search_page.click_search_button+ search_page.type_in_search(topics.first.title)+ search_page.click_search_button- expect(search_page).to have_search_result+ expect(search_page).to have_search_result+ endendendenddiff --git a/spec/support/shared_examples_for_stats_cacheable.rb b/spec/support/shared_examples/stats_cacheable.rbsimilarity index 100%rename from spec/support/shared_examples_for_stats_cacheable.rbrename to spec/support/shared_examples/stats_cacheable.rbdiff --git a/spec/system/core_features_spec.rb b/spec/system/core_features_spec.rbnew file mode 100644index 00000000000..6a2dd0d883a--- /dev/null+++ b/spec/system/core_features_spec.rb@@ -0,0 +1,5 @@+# frozen_string_literal: true++RSpec.describe "Core features", type: :system do+ it_behaves_like "having working core features"+end