mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
DEV: adds a has-preloaded-chat-channels body-class (#26394)
This class should help makes tests more reliable by ensuring we are in a known state.
This commit is contained in:
parent
1cc8c72a98
commit
6f694d9d1b
|
@ -0,0 +1,13 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { service } from "@ember/service";
|
||||
import bodyClass from "discourse/helpers/body-class";
|
||||
|
||||
export default class ChatBodyClass extends Component {
|
||||
@service chatStateManager;
|
||||
|
||||
<template>
|
||||
{{#if this.chatStateManager.hasPreloadedChannels}}
|
||||
{{bodyClass "has-preloaded-chat-channels"}}
|
||||
{{/if}}
|
||||
</template>
|
||||
}
|
|
@ -52,9 +52,9 @@ module PageObjects
|
|||
drawer?(expectation: false, channel_id: channel_id, expanded: expanded)
|
||||
end
|
||||
|
||||
def visit_channel(channel, message_id: nil)
|
||||
def visit_channel(channel, message_id: nil, with_preloaded_channels: true)
|
||||
visit(channel.url + (message_id ? "/#{message_id}" : ""))
|
||||
has_finished_loading?
|
||||
has_finished_loading?(with_preloaded_channels: with_preloaded_channels)
|
||||
end
|
||||
|
||||
def visit_user_threads
|
||||
|
@ -102,7 +102,12 @@ module PageObjects
|
|||
visit("/chat/new-message?recipients=#{recipients}")
|
||||
end
|
||||
|
||||
def has_finished_loading?
|
||||
def has_preloaded_channels?
|
||||
has_css?("body.has-preloaded-chat-channels")
|
||||
end
|
||||
|
||||
def has_finished_loading?(with_preloaded_channels: true)
|
||||
has_preloaded_channels? if with_preloaded_channels
|
||||
has_no_css?(".chat-channel--not-loaded-once")
|
||||
has_no_css?(".chat-skeleton")
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ RSpec.describe "Visit channel", type: :system do
|
|||
end
|
||||
|
||||
it "shows a not found page" do
|
||||
chat.visit_channel(category_channel_1)
|
||||
chat.visit_channel(category_channel_1, with_preloaded_channels: false)
|
||||
|
||||
expect(page).to have_content(I18n.t("page_not_found.title"))
|
||||
end
|
||||
|
@ -33,7 +33,7 @@ RSpec.describe "Visit channel", type: :system do
|
|||
context "when chat enabled" do
|
||||
context "when anonymous" do
|
||||
it "redirects to homepage" do
|
||||
chat.visit_channel(category_channel_1)
|
||||
chat.visit_channel(category_channel_1, with_preloaded_channels: false)
|
||||
|
||||
expect(page).to have_current_path("/latest")
|
||||
end
|
||||
|
@ -46,7 +46,7 @@ RSpec.describe "Visit channel", type: :system do
|
|||
before { current_user.user_option.update!(chat_enabled: false) }
|
||||
|
||||
it "redirects to homepage" do
|
||||
chat.visit_channel(category_channel_1)
|
||||
chat.visit_channel(category_channel_1, with_preloaded_channels: false)
|
||||
|
||||
expect(page).to have_current_path("/latest")
|
||||
end
|
||||
|
@ -56,7 +56,7 @@ RSpec.describe "Visit channel", type: :system do
|
|||
before { SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:staff] }
|
||||
|
||||
it "redirects homepage" do
|
||||
chat.visit_channel(category_channel_1)
|
||||
chat.visit_channel(category_channel_1, with_preloaded_channels: false)
|
||||
|
||||
expect(page).to have_current_path("/latest")
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user