DEV: initial system tests for chat and plugins (#18881)

This is a very basic to ensure it's working and open future possible work
This commit is contained in:
Joffrey JAFFEUX 2022-11-04 15:06:24 +01:00 committed by GitHub
parent 518707c42a
commit 11f3618b80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 12 deletions

View File

@ -41,8 +41,6 @@ jobs:
target: plugins
- build_type: frontend
target: core # Handled by core_frontend_tests job (below)
- build_type: system
target: plugins # Enable once at least 1 plugin has system tests
steps:
- uses: actions/checkout@v3
@ -178,7 +176,7 @@ jobs:
- name: Plugin System Tests
if: 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 screenshots
uses: actions/upload-artifact@v3

View File

@ -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/") }.sort
if files.length > 0
cmd = parallel ? "bin/turbo_rspec" : "bin/rspec"
sh "LOAD_PLUGINS=1 #{cmd} #{files.join(' ')} #{params.join(' ')}"

View File

@ -17,7 +17,11 @@ class CategoryChannel < ChatChannel
category.secure_group_ids.to_a.concat(staff_groups)
end
def title(_)
def title(_ = nil)
name.presence || category.name
end
def slug
title.truncate(100).parameterize
end
end

View File

@ -619,7 +619,7 @@ after_initialize do
get "/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 do
add_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 styles

View File

@ -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