diff --git a/Tests/AblyChatTests/DefaultRoomTests.swift b/Tests/AblyChatTests/DefaultRoomTests.swift index 4560596..4014e97 100644 --- a/Tests/AblyChatTests/DefaultRoomTests.swift +++ b/Tests/AblyChatTests/DefaultRoomTests.swift @@ -100,6 +100,30 @@ struct DefaultRoomTests { #expect(Set(channelsGetArguments.map(\.name)) == Set(expectedFetchedChannelNames)) } + // @spec CHA-RC2e + // @spec CHA-RL10 + @Test + func lifecycleContributorOrder() async throws { + // Given: a DefaultRoom, instance, with all room features enabled + let channelsList = [ + MockRealtimeChannel(name: "basketball::$chat::$chatMessages"), + MockRealtimeChannel(name: "basketball::$chat::$reactions"), + MockRealtimeChannel(name: "basketball::$chat::$typingIndicators"), + ] + let channels = MockChannels(channels: channelsList) + let realtime = MockRealtime.create(channels: channels) + let lifecycleManagerFactory = MockRoomLifecycleManagerFactory() + _ = try await DefaultRoom(realtime: realtime, chatAPI: ChatAPI(realtime: realtime), roomID: "basketball", options: .allFeaturesEnabled, logger: TestLogger(), lifecycleManagerFactory: lifecycleManagerFactory) + + // Then: The array of contributors with which it initializes the RoomLifecycleManager are in the same order as the following list: + // + // messages, presence, typing, reactions, occupancy + // + // (note that we do not say that it is the _same_ list, because we combine multiple features into a single contributor) + let lifecycleManagerCreationArguments = try #require(await lifecycleManagerFactory.createManagerArguments.first) + #expect(lifecycleManagerCreationArguments.contributors.map(\.feature) == [.messages, .typing, .reactions]) + } + // @specUntested CHA-RC2b - We chose to implement this failure with an idiomatic fatalError instead of throwing, but we can’t test this. // This is just a basic sense check to make sure the room getters are working as expected, since we don’t have unit tests for some of the features at the moment.