A platform for community discussion. Free, open, simple.
DEV: initial system tests for chat and plugins (#18881)
Joffrey JAFFEUX11f3618b8066
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex f1356bf73bd..f4bab3afdf9 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -41,8 +41,6 @@ jobs:target: plugins- build_type: frontendtarget: core # Handled by core_frontend_tests job (below)- - build_type: system- target: plugins # Enable once at least 1 plugin has system testssteps:- uses: actions/checkout@v3@@ -178,7 +176,7 @@ jobs:- name: Plugin System Testsif: matrix.build_type == 'system' && matrix.target == 'plugins'- run: bin/system_rspec plugins/*/spec/system+ run: LOAD_PLUGINS=1 bin/system_rspec plugins/*/spec/system- name: Upload failed system test screenshotsuses: actions/upload-artifact@v3diff --git a/lib/tasks/plugin.rake b/lib/tasks/plugin.rakeindex e9b6218615d..ddff6524986 100644--- a/lib/tasks/plugin.rake+++ b/lib/tasks/plugin.rake@@ -174,7 +174,9 @@ def spec(plugin, parallel: false)params << "--seed #{ENV['RSPEC_SEED']}" if Integer(ENV['RSPEC_SEED'], exception: false)ruby = `which ruby`.strip- files = Dir.glob("./plugins/#{plugin}/spec/**/*_spec.rb").sort+ # reject system specs as they are slow and need dedicated setup+ files =+ Dir.glob("./plugins/#{plugin}/spec/**/*_spec.rb").reject { |f| f.include?("spec/system/") }.sortif files.length > 0cmd = parallel ? "bin/turbo_rspec" : "bin/rspec"sh "LOAD_PLUGINS=1 #{cmd} #{files.join(' ')} #{params.join(' ')}"diff --git a/plugins/chat/app/models/category_channel.rb b/plugins/chat/app/models/category_channel.rbindex d9561d7f1fc..2a2a32246b4 100644--- a/plugins/chat/app/models/category_channel.rb+++ b/plugins/chat/app/models/category_channel.rb@@ -17,7 +17,11 @@ class CategoryChannel < ChatChannelcategory.secure_group_ids.to_a.concat(staff_groups)end- def title(_)+ def title(_ = nil)name.presence || category.nameend++ def slug+ title.truncate(100).parameterize+ endenddiff --git a/plugins/chat/plugin.rb b/plugins/chat/plugin.rbindex fbda6686e51..e789776d186 100644--- a/plugins/chat/plugin.rb+++ b/plugins/chat/plugin.rb@@ -619,7 +619,7 @@ after_initialize doget "/browse/archived" => "chat#respond"get "/draft-channel" => "chat#respond"get "/channel/:channel_id" => "chat#respond"- get "/channel/:channel_id/:channel_title" => "chat#respond"+ get "/channel/:channel_id/:channel_title" => "chat#respond", :as => "channel"get "/channel/:channel_id/:channel_title/info" => "chat#respond"get "/channel/:channel_id/:channel_title/info/about" => "chat#respond"get "/channel/:channel_id/:channel_title/info/members" => "chat#respond"@@ -697,12 +697,7 @@ after_initialize doadd_api_key_scope(:chat,- {- create_message: {- actions: %w[chat/chat#create_message],- params: %i[chat_channel_id],- },- },+ { create_message: { actions: %w[chat/chat#create_message], params: %i[chat_channel_id] } },)# Dark mode email stylesdiff --git a/plugins/chat/spec/system/navigation_spec.rb b/plugins/chat/spec/system/navigation_spec.rbnew file mode 100644index 00000000000..0fec209f77c--- /dev/null+++ b/plugins/chat/spec/system/navigation_spec.rb@@ -0,0 +1,29 @@+# frozen_string_literal: true++RSpec.describe "Navigation", type: :system, js: true do+ fab!(:user) { Fabricate(:user) }+ fab!(:category_channel) { Fabricate(:category_channel) }+ fab!(:message) { Fabricate(:chat_message, chat_channel: category_channel) }++ before do+ SiteSetting.chat_enabled = true+ SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]+ end++ context "when visiting /chat" do+ before do+ category_channel.add(user)+ sign_in(user)+ end++ it "it opens full page" do+ visit("/chat")++ expect(page).to have_current_path(+ chat.channel_path(category_channel.id, category_channel.slug),+ )+ expect(page).to have_css("html.has-full-page-chat")+ expect(page).to have_css(".chat-message-container[data-id='#{message.id}']")+ end+ end+end