DEV: fixes flakey due to unordered array (#22515)

The `message_bus_channels` given to `MessageBus.last_ids(*message_bus_channels)` is not ordered, as a result the expectation of the tests could fail, this test ensures we check the contain of the input instead of content+order.
This commit is contained in:
Joffrey JAFFEUX 2023-07-10 17:26:29 +02:00 committed by GitHub
parent 0ce0bcd8ff
commit d52b0560ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 22 deletions

View File

@ -135,29 +135,32 @@ RSpec.describe Chat::StructuredChannelSerializer do
it "calls MessageBus.last_ids with all the required channels for each public and DM chat chat channel" do
MessageBus
.expects(:last_ids)
.with(
Chat::Publisher::CHANNEL_METADATA_MESSAGE_BUS_CHANNEL,
Chat::Publisher::CHANNEL_EDITS_MESSAGE_BUS_CHANNEL,
Chat::Publisher::CHANNEL_STATUS_MESSAGE_BUS_CHANNEL,
Chat::Publisher::NEW_CHANNEL_MESSAGE_BUS_CHANNEL,
Chat::Publisher::CHANNEL_ARCHIVE_STATUS_MESSAGE_BUS_CHANNEL,
Chat::Publisher.user_tracking_state_message_bus_channel(user1.id),
Chat::Publisher.new_messages_message_bus_channel(channel1.id),
Chat::Publisher.new_mentions_message_bus_channel(channel1.id),
Chat::Publisher.kick_users_message_bus_channel(channel1.id),
Chat::Publisher.root_message_bus_channel(channel1.id),
Chat::Publisher.new_messages_message_bus_channel(channel2.id),
Chat::Publisher.new_mentions_message_bus_channel(channel2.id),
Chat::Publisher.kick_users_message_bus_channel(channel2.id),
Chat::Publisher.root_message_bus_channel(channel2.id),
Chat::Publisher.new_messages_message_bus_channel(channel3.id),
Chat::Publisher.new_mentions_message_bus_channel(channel3.id),
Chat::Publisher.root_message_bus_channel(channel3.id),
Chat::Publisher.new_messages_message_bus_channel(channel4.id),
Chat::Publisher.new_mentions_message_bus_channel(channel4.id),
Chat::Publisher.root_message_bus_channel(channel4.id),
)
.with do |*args|
[
Chat::Publisher::CHANNEL_METADATA_MESSAGE_BUS_CHANNEL,
Chat::Publisher::CHANNEL_EDITS_MESSAGE_BUS_CHANNEL,
Chat::Publisher::CHANNEL_STATUS_MESSAGE_BUS_CHANNEL,
Chat::Publisher::NEW_CHANNEL_MESSAGE_BUS_CHANNEL,
Chat::Publisher::CHANNEL_ARCHIVE_STATUS_MESSAGE_BUS_CHANNEL,
Chat::Publisher.user_tracking_state_message_bus_channel(user1.id),
Chat::Publisher.new_messages_message_bus_channel(channel1.id),
Chat::Publisher.new_mentions_message_bus_channel(channel1.id),
Chat::Publisher.kick_users_message_bus_channel(channel1.id),
Chat::Publisher.root_message_bus_channel(channel1.id),
Chat::Publisher.new_messages_message_bus_channel(channel2.id),
Chat::Publisher.new_mentions_message_bus_channel(channel2.id),
Chat::Publisher.kick_users_message_bus_channel(channel2.id),
Chat::Publisher.root_message_bus_channel(channel2.id),
Chat::Publisher.new_messages_message_bus_channel(channel3.id),
Chat::Publisher.new_mentions_message_bus_channel(channel3.id),
Chat::Publisher.root_message_bus_channel(channel3.id),
Chat::Publisher.new_messages_message_bus_channel(channel4.id),
Chat::Publisher.new_mentions_message_bus_channel(channel4.id),
Chat::Publisher.root_message_bus_channel(channel4.id),
].to_set == args.to_set
end
.returns({})
described_class.new(fetch_data, scope: guardian).as_json
end