A platform for community discussion. Free, open, simple.
DEV: Call `MessageBus.stop()` after each system test (#21848)
Alan Guo Xiang Tan4dd053a69c07
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex 79e13579a15..69665d0bbd0 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -442,6 +442,7 @@ RSpec.configure do |config|endend+ page.execute_script("if (typeof MessageBus !== 'undefined') { MessageBus.stop(); }")Capybara.reset_sessions!Capybara.use_default_driverDiscourse.redis.flushdbdiff --git a/spec/system/admin_customize_form_templates_spec.rb b/spec/system/admin_customize_form_templates_spec.rbindex cc17e11c330..09cf3245422 100644--- a/spec/system/admin_customize_form_templates_spec.rb+++ b/spec/system/admin_customize_form_templates_spec.rb@@ -9,10 +9,6 @@ describe "Admin Customize Form Templates", type: :system, js: true dofab!(:category) { Fabricate(:category) }before do- skip(<<~TEXT) if ENV["CI"]- The specs here are extremely flaky on CI for some reason.- TEXT-SiteSetting.experimental_form_templates = truesign_in(admin)end@@ -21,25 +17,29 @@ describe "Admin Customize Form Templates", type: :system, js: true dobefore { category.update!(form_template_ids: [form_template.id]) }it "should show the existing form templates in a table" do- visit("/admin/customize/form-templates")+ form_template_page.visit+expect(form_template_page).to have_form_template_tableexpect(form_template_page).to have_form_template(form_template.name)endit "should show the categories the form template is used in" do- visit("/admin/customize/form-templates")+ form_template_page.visit+expect(form_template_page).to have_form_template_tableexpect(form_template_page).to have_category_in_template_row(category.name)endit "should show the form template structure in a modal" do- visit("/admin/customize/form-templates")+ form_template_page.visit+form_template_page.click_view_form_templateexpect(form_template_page).to have_template_structure("- type: input")endit "should show a preview of the template in a modal when toggling the preview" do- visit("/admin/customize/form-templates")+ form_template_page.visit+form_template_page.click_view_form_templateform_template_page.click_toggle_previewexpect(form_template_page).to have_input_field("input")@@ -55,7 +55,7 @@ describe "Admin Customize Form Templates", type: :system, js: true doenddef quick_insertion_test(field_type, content)- visit("/admin/customize/form-templates/new")+ form_template_page.visit_newform_template_page.type_in_template_name("New Template")form_template_page.click_quick_insert(field_type)expect(ace_editor).to have_text(content)@@ -63,7 +63,7 @@ describe "Admin Customize Form Templates", type: :system, js: true dodescribe "when visiting the page to create a new form template" doit "should allow admin to create a new form template" do- visit("/admin/customize/form-templates/new")+ form_template_page.visit_newsample_name = "My First Template"sample_template = "- type: input"@@ -75,40 +75,41 @@ describe "Admin Customize Form Templates", type: :system, js: true doendit "should disable the save button until form is filled out" do- visit("/admin/customize/form-templates/new")- expect(form_template_page).to have_save_button_with_state(true)+ form_template_page.visit_new+ expect(form_template_page).to have_save_button_with_state(disabled: true)form_template_page.type_in_template_name("New Template")- expect(form_template_page).to have_save_button_with_state(true)+ expect(form_template_page).to have_save_button_with_state(disabled: true)ace_editor.type_input("- type: input")- expect(form_template_page).to have_save_button_with_state(false)+ expect(form_template_page).to have_save_button_with_state(disabled: false)endit "should disable the preview button until form is filled out" do- visit("/admin/customize/form-templates/new")- expect(form_template_page).to have_preview_button_with_state(true)+ form_template_page.visit_new+ expect(form_template_page).to have_preview_button_with_state(disabled: true)form_template_page.type_in_template_name("New Template")- expect(form_template_page).to have_preview_button_with_state(true)+ expect(form_template_page).to have_preview_button_with_state(disabled: true)ace_editor.type_input("- type: input")- expect(form_template_page).to have_preview_button_with_state(false)+ expect(form_template_page).to have_preview_button_with_state(disabled: false)endit "should show validation options in a modal when clicking the validations button" do- visit("/admin/customize/form-templates/new")+ form_template_page.visit_newform_template_page.click_validations_buttonexpect(form_template_page).to have_validations_modalendit "should show a preview of the template in a modal when clicking the preview button" do- visit("/admin/customize/form-templates/new")+ form_template_page.visit_newform_template_page.type_in_template_name("New Template")ace_editor.type_input("- type: input")form_template_page.click_preview_button+expect(form_template_page).to have_preview_modalexpect(form_template_page).to have_input_field("input")endit "should render all the input field types in the preview" do- visit("/admin/customize/form-templates/new")+ form_template_page.visit_newform_template_page.type_in_template_name("New Template")ace_editor.type_input("- type: input\n- type: textarea\n- type: checkbox\n- type: dropdown\n- type: upload\n- type: multi-select",diff --git a/spec/system/page_objects/pages/form_template.rb b/spec/system/page_objects/pages/form_template.rbindex 05e184894a5..67d4f16f26d 100644--- a/spec/system/page_objects/pages/form_template.rb+++ b/spec/system/page_objects/pages/form_template.rb@@ -3,6 +3,16 @@module PageObjectsmodule Pagesclass FormTemplate < PageObjects::Pages::Base+ def visit+ page.visit("/admin/customize/form-templates")+ self+ end++ def visit_new+ page.visit("/admin/customize/form-templates/new")+ self+ end+# Form Template Indexdef has_form_template_table?page.has_selector?("table.form-templates__table")@@ -67,12 +77,12 @@ module PageObjectsfind(".form-templates__form-name-input").value == nameend- def has_save_button_with_state?(state)- find_button("Save", disabled: state)+ def has_save_button_with_state?(disabled:)+ find_button("Save", disabled:)end- def has_preview_button_with_state?(state)- find_button("Preview", disabled: state)+ def has_preview_button_with_state?(disabled:)+ find_button("Preview", disabled:)endendend