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)
|
drawer?(expectation: false, channel_id: channel_id, expanded: expanded)
|
||||||
end
|
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}" : ""))
|
visit(channel.url + (message_id ? "/#{message_id}" : ""))
|
||||||
has_finished_loading?
|
has_finished_loading?(with_preloaded_channels: with_preloaded_channels)
|
||||||
end
|
end
|
||||||
|
|
||||||
def visit_user_threads
|
def visit_user_threads
|
||||||
|
@ -102,7 +102,12 @@ module PageObjects
|
||||||
visit("/chat/new-message?recipients=#{recipients}")
|
visit("/chat/new-message?recipients=#{recipients}")
|
||||||
end
|
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-channel--not-loaded-once")
|
||||||
has_no_css?(".chat-skeleton")
|
has_no_css?(".chat-skeleton")
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ RSpec.describe "Visit channel", type: :system do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows a not found page" do
|
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"))
|
expect(page).to have_content(I18n.t("page_not_found.title"))
|
||||||
end
|
end
|
||||||
|
@ -33,7 +33,7 @@ RSpec.describe "Visit channel", type: :system do
|
||||||
context "when chat enabled" do
|
context "when chat enabled" do
|
||||||
context "when anonymous" do
|
context "when anonymous" do
|
||||||
it "redirects to homepage" 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")
|
expect(page).to have_current_path("/latest")
|
||||||
end
|
end
|
||||||
|
@ -46,7 +46,7 @@ RSpec.describe "Visit channel", type: :system do
|
||||||
before { current_user.user_option.update!(chat_enabled: false) }
|
before { current_user.user_option.update!(chat_enabled: false) }
|
||||||
|
|
||||||
it "redirects to homepage" 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")
|
expect(page).to have_current_path("/latest")
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ RSpec.describe "Visit channel", type: :system do
|
||||||
before { SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:staff] }
|
before { SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:staff] }
|
||||||
|
|
||||||
it "redirects homepage" do
|
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")
|
expect(page).to have_current_path("/latest")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue