Add Konsist test on Immutable annotation

This commit is contained in:
Benoit Marty
2025-10-09 15:36:06 +02:00
parent 6991640886
commit f9ba0819f2
3 changed files with 15 additions and 5 deletions

View File

@@ -7,9 +7,6 @@
package io.element.android.features.messages.impl.attachments.preview
import androidx.compose.runtime.Immutable
@Immutable
sealed interface AttachmentsPreviewEvents {
data object SendAttachment : AttachmentsPreviewEvents
data object CancelAndDismiss : AttachmentsPreviewEvents

View File

@@ -8,12 +8,10 @@
package io.element.android.features.messages.impl.messagecomposer
import android.net.Uri
import androidx.compose.runtime.Immutable
import io.element.android.libraries.textcomposer.mentions.ResolvedSuggestion
import io.element.android.libraries.textcomposer.model.MessageComposerMode
import io.element.android.libraries.textcomposer.model.Suggestion
@Immutable
sealed interface MessageComposerEvents {
data object ToggleFullScreenState : MessageComposerEvents
data object SendMessage : MessageComposerEvents
@@ -30,6 +28,7 @@ sealed interface MessageComposerEvents {
data object Location : PickAttachmentSource
data object Poll : PickAttachmentSource
}
data class ToggleTextFormatting(val enabled: Boolean) : MessageComposerEvents
data class Error(val error: Throwable) : MessageComposerEvents
data class TypingNotice(val isTyping: Boolean) : MessageComposerEvents

View File

@@ -7,8 +7,12 @@
package io.element.android.tests.konsist
import androidx.compose.runtime.Immutable
import com.lemonappdev.konsist.api.Konsist
import com.lemonappdev.konsist.api.ext.list.withAnnotationOf
import com.lemonappdev.konsist.api.ext.list.withNameEndingWith
import com.lemonappdev.konsist.api.ext.list.withoutName
import com.lemonappdev.konsist.api.verify.assertEmpty
import com.lemonappdev.konsist.api.verify.assertFalse
import org.junit.Test
@@ -60,4 +64,14 @@ class KonsistImmutableTest {
it.text.contains(".toPersistentMap()")
}
}
@Test
fun `Immutable annotation is not used on sealed interface for Presenter Events`() {
Konsist
.scopeFromProduction()
.interfaces()
.withNameEndingWith("Events")
.withAnnotationOf(Immutable::class)
.assertEmpty()
}
}