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 trimmedFilter = filter.trim();
const lowerCasedFilter = filter.toLowerCase(); const lowerCasedFilter = filter.toLowerCase();
const { activeChannel } = this;
return sortedChannels.filter((channel) => { return sortedChannels.filter((channel) => {
if ( if (
opts.excludeActiveChannel && opts.excludeActiveChannel &&
activeChannel && this.chat.activeChannel?.id === channel.id
activeChannel.id === channel.id
) { ) {
return false; 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)) } 98.times { channel_1.add(Fabricate(:user)) }
channel_1.update!(user_count_stale: true) channel_1.update!(user_count_stale: true)
Jobs.run_immediately!
Jobs::UpdateChannelUserCount.new.execute(chat_channel_id: channel_1.id) Jobs::UpdateChannelUserCount.new.execute(chat_channel_id: channel_1.id)
end end

View File

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

View File

@ -17,10 +17,10 @@ RSpec.describe "Edited message", type: :system, js: true do
end end
context "when editing message" do 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) chat_page.visit_channel(channel_1)
using_session(editing_user.username) do using_session(:user_1) do
sign_in(editing_user) sign_in(editing_user)
chat_page.visit_channel(channel_1) chat_page.visit_channel(channel_1)
channel_page.edit_message(message_1, "a different message") 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 end
def create_message(text: "this is fine", channel:, creator: Fabricate(:user)) def create_message(text: "this is fine", channel:, creator: Fabricate(:user))
using_session(creator.username) do sign_in(creator)
sign_in(creator) chat_page.visit_channel(channel)
chat_page.visit_channel(channel) chat_channel_page.send_message(text)
chat_channel_page.send_message(text) expect(chat_channel_page).to have_message(text: text)
expect(chat_channel_page).to have_message(text: text)
end
end end
context "as a user" do 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 not member of the channel" do
context "when a message is created" do context "when a message is created" do
xit "doesn't show anything" do it "doesn't show anything" do
visit("/chat") 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(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_no_css( expect(page).to have_no_css(
@ -59,9 +57,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
) )
end end
xit "doesnt show indicator in header" do it "doesnt show indicator in header" do
visit("/chat") 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_css(".do-not-disturb-background")
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator") 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) } before { channel_1.membership_for(current_user).update!(muted: true) }
context "when a message is created" do context "when a message is created" do
xit "doesn't show anything" do it "doesn't show anything" do
visit("/chat") 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(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_no_css( expect(page).to have_no_css(
@ -85,9 +83,9 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
end end
context "when a message is created" do context "when a message is created" do
xit "correctly renders notifications" do it "correctly renders notifications" do
visit("/chat") 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-header-icon .chat-channel-unread-indicator", text: "")
expect(page).to have_css( expect(page).to have_css(
@ -98,13 +96,15 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
end end
context "when a message with mentions is created" do context "when a message with mentions is created" do
xit "correctly renders notifications" do it "correctly renders notifications" do
visit("/chat") visit("/chat")
create_message( using_session(:user_1) do
channel: channel_1, create_message(
creator: user_1, channel: channel_1,
text: "hello @#{current_user.username} what's up?", 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(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_css( 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]) } fab!(:dm_channel_2) { Fabricate(:direct_message_channel, users: [current_user, user_2]) }
context "when a message is created" do context "when a message is created" do
xit "correctly renders notifications" do it "correctly renders notifications" do
visit("/chat") 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-header-icon .chat-channel-unread-indicator", text: "1")
expect(page).to have_css( expect(page).to have_css(
".chat-channel-row[data-chat-channel-id=\"#{dm_channel_1.id}\"] .chat-channel-unread-indicator", ".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") expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "2")
end end
xit "reorders channels" do it "reorders channels" do
visit("/chat") visit("/chat")
expect(page).to have_css( expect(page).to have_css(
@ -148,7 +148,8 @@ RSpec.describe "Message notifications - mobile", type: :system, js: true, mobile
expect(page).to have_css( expect(page).to have_css(
".chat-channel-row:nth-child(2)[data-chat-channel-id=\"#{dm_channel_2.id}\"]", ".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( expect(page).to have_css(
".chat-channel-row:nth-child(1)[data-chat-channel-id=\"#{dm_channel_2.id}\"]", ".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 end
context "when messages are created" do context "when messages are created" do
xit "correctly renders notifications" do it "correctly renders notifications" do
visit("/chat") 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-header-icon .chat-channel-unread-indicator", text: "")
expect(page).to have_css( expect(page).to have_css(
".chat-channel-row[data-chat-channel-id=\"#{channel_1.id}\"] .chat-channel-unread-indicator", ".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( expect(page).to have_css(
".chat-channel-row[data-chat-channel-id=\"#{dm_channel_1.id}\"] .chat-channel-unread-indicator", ".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 end
def create_message(text: "this is fine", channel:, creator: Fabricate(:user)) def create_message(text: "this is fine", channel:, creator: Fabricate(:user))
using_session(creator.username) do sign_in(creator)
sign_in(creator) chat_page.visit_channel(channel)
chat_page.visit_channel(channel) chat_channel_page.send_message(text)
chat_channel_page.send_message(text) expect(chat_channel_page).to have_message(text: text)
expect(chat_channel_page).to have_message(text: text)
end
end end
context "as a user" do 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 not member of the channel" do
context "when a message is created" do context "when a message is created" do
xit "doesn't show anything" do it "doesn't show anything" do
visit("/") 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(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_no_css(".sidebar-row.channel-#{channel_1.id}") 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 end
xit "doesnt show indicator in header" do it "doesnt show indicator in header" do
visit("/") 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_css(".do-not-disturb-background")
expect(page).to have_no_css(".chat-header-icon .chat-channel-unread-indicator") 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) } before { channel_1.membership_for(current_user).update!(muted: true) }
context "when a message is created" do context "when a message is created" do
xit "doesn't show anything" do it "doesn't show anything" do
visit("/") 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(".chat-header-icon .chat-channel-unread-indicator")
expect(page).to have_no_css(".sidebar-row.channel-#{channel_1.id} .unread") 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 end
context "when a message is created" do context "when a message is created" do
xit "correctly renders notifications" do it "correctly renders notifications" do
visit("/") 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(".chat-header-icon .chat-channel-unread-indicator", text: "")
expect(page).to have_css(".sidebar-row.channel-#{channel_1.id} .unread") 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 end
context "when a message with mentions is created" do context "when a message with mentions is created" do
xit "correctly renders notifications" do it "correctly renders notifications" do
visit("/") visit("/")
create_message( using_session(:user_1) do
channel: channel_1, create_message(
creator: user_1, channel: channel_1,
text: "hello @#{current_user.username} what's up?", creator: user_1,
) text: "hello @#{current_user.username} what's up?",
)
end
expect(page).to have_css( expect(page).to have_css(
".chat-header-icon .chat-channel-unread-indicator.urgent", ".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]) } fab!(:dm_channel_2) { Fabricate(:direct_message_channel, users: [current_user, user_2]) }
context "when a message is created" do context "when a message is created" do
xit "correctly renders notifications" do it "correctly renders notifications" do
visit("/") 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(".chat-header-icon .chat-channel-unread-indicator", text: "1")
expect(page).to have_css(".sidebar-row.channel-#{dm_channel_1.id} .icon.urgent") 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") expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "2")
end end
xit "reorders channels" do it "reorders channels" do
visit("/chat") visit("/chat")
expect(page).to have_css( 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}", "#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( expect(page).to have_css(
"#sidebar-section-content-chat-dms .sidebar-section-link-wrapper:nth-child(1) .channel-#{dm_channel_2.id}", "#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 end
context "when messages are created" do context "when messages are created" do
xit "correctly renders notifications" do it "correctly renders notifications" do
visit("/") 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(".chat-header-icon .chat-channel-unread-indicator", text: "")
expect(page).to have_css(".sidebar-row.channel-#{channel_1.id} .unread") 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(".sidebar-row.channel-#{dm_channel_1.id} .icon.urgent")
expect(page).to have_css(".chat-header-icon .chat-channel-unread-indicator", text: "1") 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 on a channel" do
context "when another user is replying" do context "when another user is replying" do
xit "shows the replying indicator" do it "shows the replying indicator" do
using_session(other_user.username) do using_session(:user_1) do
sign_in(other_user) sign_in(other_user)
chat.visit_channel(channel_1) chat.visit_channel(channel_1)
find(".chat-composer-input").fill_in(with: "hello there") 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) sign_in(current_user)
end 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 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}").hover
find(".channel-#{dm_channel_1.id} .sidebar-section-link-hover").click find(".channel-#{dm_channel_1.id} .sidebar-section-link-hover").click
expect(page).to have_no_css(".channel-#{dm_channel_1.id}") 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") expect(page).to have_css(".channel-#{dm_channel_1.id} .urgent")
end end

View File

@ -163,23 +163,23 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
fab!(:other_user) { Fabricate(:user) } fab!(:other_user) { Fabricate(:user) }
before do before do
other_user = Fabricate(:user)
channel_1.add(current_user) channel_1.add(current_user)
end end
it "shows an invitation notification" do it "shows an invitation notification" do
chat.visit_channel(channel_1) chat.visit_channel(channel_1)
find(".chat-composer-input").fill_in(with: "this is fine @#{other_user.username}") find(".chat-composer-input").fill_in(with: "this is fine @#{other_user.username}")
Sidekiq::Testing.inline! do find(".send-btn").click
find(".send-btn").click find(".chat-composer-input").click # ensures autocomplete is closed and not masking invite link
find(".invite-link").click 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 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 end
end end