Improve Konsist test.
This commit is contained in:
parent
ea94ec32b4
commit
5541ca7427
1 changed files with 105 additions and 84 deletions
|
|
@ -8,8 +8,10 @@
|
||||||
package io.element.android.tests.konsist
|
package io.element.android.tests.konsist
|
||||||
|
|
||||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import com.lemonappdev.konsist.api.Konsist
|
import com.lemonappdev.konsist.api.Konsist
|
||||||
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
|
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
|
||||||
|
import com.lemonappdev.konsist.api.ext.list.withName
|
||||||
import com.lemonappdev.konsist.api.ext.list.withoutName
|
import com.lemonappdev.konsist.api.ext.list.withoutName
|
||||||
import com.lemonappdev.konsist.api.verify.assertEmpty
|
import com.lemonappdev.konsist.api.verify.assertEmpty
|
||||||
import com.lemonappdev.konsist.api.verify.assertTrue
|
import com.lemonappdev.konsist.api.verify.assertTrue
|
||||||
|
|
@ -52,13 +54,7 @@ class KonsistPreviewTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
private val previewNameExceptions = listOf(
|
||||||
fun `Functions with '@PreviewsDayNight' have correct name`() {
|
|
||||||
Konsist
|
|
||||||
.scopeFromProject()
|
|
||||||
.functions()
|
|
||||||
.withAllAnnotationsOf(PreviewsDayNight::class)
|
|
||||||
.withoutName(
|
|
||||||
"AsyncIndicatorFailurePreview",
|
"AsyncIndicatorFailurePreview",
|
||||||
"AsyncIndicatorLoadingPreview",
|
"AsyncIndicatorLoadingPreview",
|
||||||
"BackgroundVerticalGradientDisabledPreview",
|
"BackgroundVerticalGradientDisabledPreview",
|
||||||
|
|
@ -73,16 +69,14 @@ class KonsistPreviewTest {
|
||||||
"IconsCompoundPreview",
|
"IconsCompoundPreview",
|
||||||
"IconsOtherPreview",
|
"IconsOtherPreview",
|
||||||
"MarkdownTextComposerEditPreview",
|
"MarkdownTextComposerEditPreview",
|
||||||
"MatrixBadgeAtomPositivePreview",
|
|
||||||
"MatrixBadgeAtomNeutralPreview",
|
|
||||||
"MatrixBadgeAtomNegativePreview",
|
|
||||||
"MatrixBadgeAtomInfoPreview",
|
"MatrixBadgeAtomInfoPreview",
|
||||||
"MentionSpanPreview",
|
"MatrixBadgeAtomNegativePreview",
|
||||||
|
"MatrixBadgeAtomNeutralPreview",
|
||||||
|
"MatrixBadgeAtomPositivePreview",
|
||||||
"MessageComposerViewVoicePreview",
|
"MessageComposerViewVoicePreview",
|
||||||
"MessagesReactionButtonAddPreview",
|
"MessagesReactionButtonAddPreview",
|
||||||
"MessagesReactionButtonExtraPreview",
|
"MessagesReactionButtonExtraPreview",
|
||||||
"MessagesViewWithIdentityChangePreview",
|
"MessagesViewWithIdentityChangePreview",
|
||||||
"MessagesViewWithTypingPreview",
|
|
||||||
"PageTitleWithIconFullPreview",
|
"PageTitleWithIconFullPreview",
|
||||||
"PageTitleWithIconMinimalPreview",
|
"PageTitleWithIconMinimalPreview",
|
||||||
"PendingMemberRowWithLongNamePreview",
|
"PendingMemberRowWithLongNamePreview",
|
||||||
|
|
@ -107,21 +101,19 @@ class KonsistPreviewTest {
|
||||||
"SelectedUserCannotRemovePreview",
|
"SelectedUserCannotRemovePreview",
|
||||||
"TextComposerAddCaptionPreview",
|
"TextComposerAddCaptionPreview",
|
||||||
"TextComposerCaptionPreview",
|
"TextComposerCaptionPreview",
|
||||||
"TextComposerEditPreview",
|
|
||||||
"TextComposerEditNotEncryptedPreview",
|
|
||||||
"TextComposerEditCaptionPreview",
|
"TextComposerEditCaptionPreview",
|
||||||
"TextComposerFormattingPreview",
|
"TextComposerEditNotEncryptedPreview",
|
||||||
|
"TextComposerEditPreview",
|
||||||
"TextComposerFormattingNotEncryptedPreview",
|
"TextComposerFormattingNotEncryptedPreview",
|
||||||
|
"TextComposerFormattingPreview",
|
||||||
"TextComposerLinkDialogCreateLinkPreview",
|
"TextComposerLinkDialogCreateLinkPreview",
|
||||||
"TextComposerLinkDialogCreateLinkWithoutTextPreview",
|
"TextComposerLinkDialogCreateLinkWithoutTextPreview",
|
||||||
"TextComposerLinkDialogEditLinkPreview",
|
"TextComposerLinkDialogEditLinkPreview",
|
||||||
"TextComposerReplyPreview",
|
"TextComposerReplyPreview",
|
||||||
"TextComposerReplyNotEncryptedPreview",
|
|
||||||
"TextComposerSimplePreview",
|
|
||||||
"TextComposerSimpleNotEncryptedPreview",
|
"TextComposerSimpleNotEncryptedPreview",
|
||||||
"TextComposerVoicePreview",
|
"TextComposerSimplePreview",
|
||||||
"TextComposerVoiceNotEncryptedPreview",
|
"TextComposerVoiceNotEncryptedPreview",
|
||||||
"TextFieldDialogWithBorderPreview",
|
"TextComposerVoicePreview",
|
||||||
"TextFieldDialogWithErrorPreview",
|
"TextFieldDialogWithErrorPreview",
|
||||||
"TimelineImageWithCaptionRowPreview",
|
"TimelineImageWithCaptionRowPreview",
|
||||||
"TimelineItemEventRowForDirectRoomPreview",
|
"TimelineItemEventRowForDirectRoomPreview",
|
||||||
|
|
@ -142,6 +134,35 @@ class KonsistPreviewTest {
|
||||||
"UserProfileHeaderSectionWithVerificationViolationPreview",
|
"UserProfileHeaderSectionWithVerificationViolationPreview",
|
||||||
"VoiceItemViewPlayPreview",
|
"VoiceItemViewPlayPreview",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `previewNameExceptions is sorted alphabetically`() {
|
||||||
|
assertThat(previewNameExceptions.sorted()).isEqualTo(previewNameExceptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `previewNameExceptions only contains existing functions`() {
|
||||||
|
val names = previewNameExceptions.toMutableSet()
|
||||||
|
Konsist
|
||||||
|
.scopeFromProject()
|
||||||
|
.functions()
|
||||||
|
.withAllAnnotationsOf(PreviewsDayNight::class)
|
||||||
|
.withName(previewNameExceptions)
|
||||||
|
.let {
|
||||||
|
it.forEach { function ->
|
||||||
|
names.remove(function.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertThat(names).isEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Functions with '@PreviewsDayNight' have correct name`() {
|
||||||
|
Konsist
|
||||||
|
.scopeFromProject()
|
||||||
|
.functions()
|
||||||
|
.withAllAnnotationsOf(PreviewsDayNight::class)
|
||||||
|
.withoutName(previewNameExceptions)
|
||||||
.assertTrue(
|
.assertTrue(
|
||||||
additionalMessage = "Functions for Preview should be named like this: <ViewUnderPreview>Preview. " +
|
additionalMessage = "Functions for Preview should be named like this: <ViewUnderPreview>Preview. " +
|
||||||
"Exception can be added to the test, for multiple Previews of the same view",
|
"Exception can be added to the test, for multiple Previews of the same view",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue