FIX: re-enables using_session tests (#19564)

This commit is contained in:
Joffrey JAFFEUX 2022-12-22 14:40:36 +01:00 committed by GitHub
parent dc3473fe06
commit daff62e3cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 82 additions and 85 deletions

View File

@ -192,13 +192,11 @@ export default Component.extend({
const trimmedFilter = filter.trim();
const lowerCasedFilter = filter.toLowerCase();
const { activeChannel } = this;
return sortedChannels.filter((channel) => {
if (
opts.excludeActiveChannel &&
activeChannel &&
activeChannel.id === channel.id
this.chat.activeChannel?.id === channel.id
) {
return false;
}

View File

@ -39,6 +39,7 @@ RSpec.describe "Channel - Info - Members page", type: :system, js: true do
98.times { channel_1.add(Fabricate(:user)) }
channel_1.update!(user_count_stale: true)
Jobs.run_immediately!
Jobs::UpdateChannelUserCount.new.execute(chat_channel_id: channel_1.id)
end

View File

@ -58,7 +58,7 @@ RSpec.describe "Channel selector modal", type: :system, js: true do
it "it doesnt include current channel" do
chat_page.visit_channel(channel_1)
find("body").send_keys([KEY_MODIFIER, "k"])
find("#chat-channel-selector-input").fill_in(with: channel_1.title)
find("#chat-channel-selector-input").click
expect(page).to have_no_css(".chat-channel-selection-row[data-id='#{channel_1.id}']")
end

View File

@ -17,10 +17,10 @@ RSpec.describe "Edited message", type: :system, js: true do
end
context "when editing message" do
xit "shows as edited for all users" do
it "shows as edited for all users" do
chat_page.visit_channel(channel_1)
using_session(editing_user.username) do
using_session(:user_1) do
sign_in(editing_user)
chat_page.visit_channel(channel_1)
channel_page.edit_message(message_1, "a different message")

View File

@ -12,12 +12,10 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
end
def create_message(text: "this is fine", channel:, creator: Fabricate(:user))
using_session(creator.username) do
sign_in(creator)
chat_page.visit_channel(channel)
chat_channel_page.send_message(text)
expect(chat_channel_page).to have_message(text: text)
end
sign_in(creator)
chat_page.visit_channel(channel)
chat_channel_page.send_message(text)
expect(chat_channel_page).to have_message(text: text)
end
context "as a user" do
@ -33,9 +31,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
context "when not member of the channel" do
context "when a message is created" do
xit "doesn't show anything" do
it "doesn't show anything" do
visit("/chat")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_no_css(
@ -59,9 +57,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
)
end
xit "doesnt show indicator in header" do
it "doesnt show indicator in header" do
visit("/chat")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_css(".do-not-disturb-background")
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
@ -72,9 +70,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
before { channel_1.membership_for(current_user).update!(muted: true) }
context "when a message is created" do
xit "doesn't show anything" do
it "doesn't show anything" do
visit("/chat")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_no_css(
@ -85,9 +83,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
end
context "when a message is created" do
xit "correctly renders notifications" do
it "correctly renders notifications" do
visit("/chat")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "")
expect(page).to have_css(
@ -98,13 +96,15 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
end
context "when a message with mentions is created" do
xit "correctly renders notifications" do
it "correctly renders notifications" do
visit("/chat")
create_message(
channel: channel_1,
creator: user_1,
text: "hello @#{current_user.username} what's up?",
)
using_session(:user_1) do
create_message(
channel: channel_1,
creator: user_1,
text: "hello @#{current_user.username} what's up?",
)
end
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_css(
@ -125,21 +125,21 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
fab!(:dm_channel_2) { Fabricate(:direct_message_channel, users: [current_user, user_2]) }
context "when a message is created" do
xit "correctly renders notifications" do
it "correctly renders notifications" do
visit("/chat")
create_message(channel: dm_channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "1")
expect(page).to have_css(
".chat-channel-row[data-chat-channel-id=\"#{dm_channel_1.id}\"] .chat-channel-unread-indicator",
)
create_message(channel: dm_channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "2")
end
xit "reorders channels" do
it "reorders channels" do
visit("/chat")
expect(page).to have_css(
@ -148,7 +148,8 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
expect(page).to have_css(
".chat-channel-row:nth-child(2)[data-chat-channel-id=\"#{dm_channel_2.id}\"]",
)
create_message(channel: dm_channel_2, creator: user_2)
using_session(:user_1) { create_message(channel: dm_channel_2, creator: user_2) }
expect(page).to have_css(
".chat-channel-row:nth-child(1)[data-chat-channel-id=\"#{dm_channel_2.id}\"]",
@ -172,16 +173,16 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
end
context "when messages are created" do
xit "correctly renders notifications" do
it "correctly renders notifications" do
visit("/chat")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "")
expect(page).to have_css(
".chat-channel-row[data-chat-channel-id=\"#{channel_1.id}\"] .chat-channel-unread-indicator",
)
create_message(channel: dm_channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }
expect(page).to have_css(
".chat-channel-row[data-chat-channel-id=\"#{dm_channel_1.id}\"] .chat-channel-unread-indicator",

View File

@ -12,12 +12,10 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
end
def create_message(text: "this is fine", channel:, creator: Fabricate(:user))
using_session(creator.username) do
sign_in(creator)
chat_page.visit_channel(channel)
chat_channel_page.send_message(text)
expect(chat_channel_page).to have_message(text: text)
end
sign_in(creator)
chat_page.visit_channel(channel)
chat_channel_page.send_message(text)
expect(chat_channel_page).to have_message(text: text)
end
context "as a user" do
@ -33,9 +31,9 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
context "when not member of the channel" do
context "when a message is created" do
xit "doesn't show anything" do
it "doesn't show anything" do
visit("/")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_no_css(".sidebar-row.channel-#{channel_1.id}")
@ -57,9 +55,9 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
)
end
xit "doesnt show indicator in header" do
it "doesnt show indicator in header" do
visit("/")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_css(".do-not-disturb-background")
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
@ -70,9 +68,9 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
before { channel_1.membership_for(current_user).update!(muted: true) }
context "when a message is created" do
xit "doesn't show anything" do
it "doesn't show anything" do
visit("/")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_no_css(".sidebar-row.channel-#{channel_1.id} .unread")
@ -81,9 +79,9 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
end
context "when a message is created" do
xit "correctly renders notifications" do
it "correctly renders notifications" do
visit("/")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "")
expect(page).to have_css(".sidebar-row.channel-#{channel_1.id} .unread")
@ -91,13 +89,15 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
end
context "when a message with mentions is created" do
xit "correctly renders notifications" do
it "correctly renders notifications" do
visit("/")
create_message(
channel: channel_1,
creator: user_1,
text: "hello @#{current_user.username} what's up?",
)
using_session(:user_1) do
create_message(
channel: channel_1,
creator: user_1,
text: "hello @#{current_user.username} what's up?",
)
end
expect(page).to have_css(
".chat-header-icon .chat-channel-unread-indicator.urgent",
@ -118,19 +118,19 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
fab!(:dm_channel_2) { Fabricate(:direct_message_channel, users: [current_user, user_2]) }
context "when a message is created" do
xit "correctly renders notifications" do
it "correctly renders notifications" do
visit("/")
create_message(channel: dm_channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "1")
expect(page).to have_css(".sidebar-row.channel-#{dm_channel_1.id} .icon.urgent")
create_message(channel: dm_channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "2")
end
xit "reorders channels" do
it "reorders channels" do
visit("/chat")
expect(page).to have_css(
@ -140,7 +140,7 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
"#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(2) .channel-#{dm_channel_2.id}",
)
create_message(channel: dm_channel_2, creator: user_2)
using_session(:user_1) { create_message(channel: dm_channel_2, creator: user_2) }
expect(page).to have_css(
"#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(1) .channel-#{dm_channel_2.id}",
@ -164,14 +164,14 @@ RSpec.describe "Message notifications - with sidebar", type: :system, js: true d
end
context "when messages are created" do
xit "correctly renders notifications" do
it "correctly renders notifications" do
visit("/")
create_message(channel: channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: channel_1, creator: user_1) }
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "")
expect(page).to have_css(".sidebar-row.channel-#{channel_1.id} .unread")
create_message(channel: dm_channel_1, creator: user_1)
using_session(:user_1) { create_message(channel: dm_channel_1, creator: user_1) }
expect(page).to have_css(".sidebar-row.channel-#{dm_channel_1.id} .icon.urgent")
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "1")

View File

@ -16,8 +16,8 @@ RSpec.describe "Replying indicator", type: :system, js: true do
context "when on a channel" do
context "when another user is replying" do
xit "shows the replying indicator" do
using_session(other_user.username) do
it "shows the replying indicator" do
using_session(:user_1) do
sign_in(other_user)
chat.visit_channel(channel_1)
find(".chat-composer-input").fill_in(with: "hello there")

View File

@ -14,23 +14,20 @@ RSpec.describe "Unfollow dm channel", type: :system, js: true do
sign_in(current_user)
end
def create_message(text: "this is fine", channel:, creator: Fabricate(:user))
using_session(creator.username) do
sign_in(creator)
chat_page.visit_channel(channel)
chat_channel_page.send_message(text)
expect(chat_channel_page).to have_message(text: text)
end
end
context "when receiving a message after unfollowing" do
xit "correctly shows the channel" do
it "correctly shows the channel" do
find(".channel-#{dm_channel_1.id}").hover
find(".channel-#{dm_channel_1.id} .sidebar-section-link-hover").click
expect(page).to have_no_css(".channel-#{dm_channel_1.id}")
create_message(channel: dm_channel_1, creator: other_user)
using_session(:user_1) do
text = "this is fine"
sign_in(other_user)
chat_page.visit_channel(dm_channel_1)
chat_channel_page.send_message(text)
expect(chat_channel_page).to have_message(text: text)
end
expect(page).to have_css(".channel-#{dm_channel_1.id} .urgent")
end

View File

@ -163,23 +163,23 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
fab!(:other_user) { Fabricate(:user) }
before do
other_user = Fabricate(:user)
channel_1.add(current_user)
end
it "shows an invitation notification" do
chat.visit_channel(channel_1)
find(".chat-composer-input").fill_in(with: "this is fine @#{other_user.username}")
Sidekiq::Testing.inline! do
find(".send-btn").click
find(".invite-link").click
find(".send-btn").click
find(".chat-composer-input").click # ensures autocomplete is closed and not masking invite link
find(".invite-link", wait: 5).click
using_session(:user_1) do
sign_in(other_user)
find(".header-dropdown-toggle.current-user").click
expect(find("#user-menu-button-chat-notifications")).to have_content(1)
expect(find("#quick-access-all-notifications")).to have_css(".chat-invitation.unread")
end
sign_in(other_user)
find(".header-dropdown-toggle.current-user").click
expect(find("#user-menu-button-chat-notifications")).to have_content(1)
expect(find("#quick-access-all-notifications")).to have_css(".chat-invitation.unread")
end
end
end