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,96 +54,115 @@ class KonsistPreviewTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val previewNameExceptions = listOf(
|
||||||
|
"AsyncIndicatorFailurePreview",
|
||||||
|
"AsyncIndicatorLoadingPreview",
|
||||||
|
"BackgroundVerticalGradientDisabledPreview",
|
||||||
|
"BackgroundVerticalGradientEnterprisePreview",
|
||||||
|
"BackgroundVerticalGradientPreview",
|
||||||
|
"CallScreenPipViewPreview",
|
||||||
|
"ColorAliasesPreview",
|
||||||
|
"DefaultRoomListTopBarWithIndicatorPreview",
|
||||||
|
"FocusedEventPreview",
|
||||||
|
"GradientFloatingActionButtonCircleShapePreview",
|
||||||
|
"HeaderFooterPageScrollablePreview",
|
||||||
|
"IconsCompoundPreview",
|
||||||
|
"IconsOtherPreview",
|
||||||
|
"MarkdownTextComposerEditPreview",
|
||||||
|
"MatrixBadgeAtomInfoPreview",
|
||||||
|
"MatrixBadgeAtomNegativePreview",
|
||||||
|
"MatrixBadgeAtomNeutralPreview",
|
||||||
|
"MatrixBadgeAtomPositivePreview",
|
||||||
|
"MessageComposerViewVoicePreview",
|
||||||
|
"MessagesReactionButtonAddPreview",
|
||||||
|
"MessagesReactionButtonExtraPreview",
|
||||||
|
"MessagesViewWithIdentityChangePreview",
|
||||||
|
"PageTitleWithIconFullPreview",
|
||||||
|
"PageTitleWithIconMinimalPreview",
|
||||||
|
"PendingMemberRowWithLongNamePreview",
|
||||||
|
"PinUnlockViewInAppPreview",
|
||||||
|
"PollAnswerViewDisclosedNotSelectedPreview",
|
||||||
|
"PollAnswerViewDisclosedSelectedPreview",
|
||||||
|
"PollAnswerViewEndedSelectedPreview",
|
||||||
|
"PollAnswerViewEndedWinnerNotSelectedPreview",
|
||||||
|
"PollAnswerViewEndedWinnerSelectedPreview",
|
||||||
|
"PollAnswerViewUndisclosedNotSelectedPreview",
|
||||||
|
"PollAnswerViewUndisclosedSelectedPreview",
|
||||||
|
"PollContentViewCreatorEditablePreview",
|
||||||
|
"PollContentViewCreatorEndedPreview",
|
||||||
|
"PollContentViewCreatorPreview",
|
||||||
|
"PollContentViewDisclosedPreview",
|
||||||
|
"PollContentViewEndedPreview",
|
||||||
|
"PollContentViewUndisclosedPreview",
|
||||||
|
"ReadReceiptBottomSheetPreview",
|
||||||
|
"RoomMemberListViewBannedPreview",
|
||||||
|
"SasEmojisPreview",
|
||||||
|
"SecureBackupSetupViewChangePreview",
|
||||||
|
"SelectedUserCannotRemovePreview",
|
||||||
|
"TextComposerAddCaptionPreview",
|
||||||
|
"TextComposerCaptionPreview",
|
||||||
|
"TextComposerEditCaptionPreview",
|
||||||
|
"TextComposerEditNotEncryptedPreview",
|
||||||
|
"TextComposerEditPreview",
|
||||||
|
"TextComposerFormattingNotEncryptedPreview",
|
||||||
|
"TextComposerFormattingPreview",
|
||||||
|
"TextComposerLinkDialogCreateLinkPreview",
|
||||||
|
"TextComposerLinkDialogCreateLinkWithoutTextPreview",
|
||||||
|
"TextComposerLinkDialogEditLinkPreview",
|
||||||
|
"TextComposerReplyPreview",
|
||||||
|
"TextComposerSimpleNotEncryptedPreview",
|
||||||
|
"TextComposerSimplePreview",
|
||||||
|
"TextComposerVoiceNotEncryptedPreview",
|
||||||
|
"TextComposerVoicePreview",
|
||||||
|
"TextFieldDialogWithErrorPreview",
|
||||||
|
"TimelineImageWithCaptionRowPreview",
|
||||||
|
"TimelineItemEventRowForDirectRoomPreview",
|
||||||
|
"TimelineItemEventRowShieldPreview",
|
||||||
|
"TimelineItemEventRowTimestampPreview",
|
||||||
|
"TimelineItemEventRowUtdPreview",
|
||||||
|
"TimelineItemEventRowWithManyReactionsPreview",
|
||||||
|
"TimelineItemEventRowWithRRPreview",
|
||||||
|
"TimelineItemEventRowWithReplyPreview",
|
||||||
|
"TimelineItemGroupedEventsRowContentCollapsePreview",
|
||||||
|
"TimelineItemGroupedEventsRowContentExpandedPreview",
|
||||||
|
"TimelineItemImageViewHideMediaContentPreview",
|
||||||
|
"TimelineItemVideoViewHideMediaContentPreview",
|
||||||
|
"TimelineItemVoiceViewUnifiedPreview",
|
||||||
|
"TimelineVideoWithCaptionRowPreview",
|
||||||
|
"TimelineViewMessageShieldPreview",
|
||||||
|
"UserAvatarColorsPreview",
|
||||||
|
"UserProfileHeaderSectionWithVerificationViolationPreview",
|
||||||
|
"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
|
@Test
|
||||||
fun `Functions with '@PreviewsDayNight' have correct name`() {
|
fun `Functions with '@PreviewsDayNight' have correct name`() {
|
||||||
Konsist
|
Konsist
|
||||||
.scopeFromProject()
|
.scopeFromProject()
|
||||||
.functions()
|
.functions()
|
||||||
.withAllAnnotationsOf(PreviewsDayNight::class)
|
.withAllAnnotationsOf(PreviewsDayNight::class)
|
||||||
.withoutName(
|
.withoutName(previewNameExceptions)
|
||||||
"AsyncIndicatorFailurePreview",
|
|
||||||
"AsyncIndicatorLoadingPreview",
|
|
||||||
"BackgroundVerticalGradientDisabledPreview",
|
|
||||||
"BackgroundVerticalGradientEnterprisePreview",
|
|
||||||
"BackgroundVerticalGradientPreview",
|
|
||||||
"CallScreenPipViewPreview",
|
|
||||||
"ColorAliasesPreview",
|
|
||||||
"DefaultRoomListTopBarWithIndicatorPreview",
|
|
||||||
"FocusedEventPreview",
|
|
||||||
"GradientFloatingActionButtonCircleShapePreview",
|
|
||||||
"HeaderFooterPageScrollablePreview",
|
|
||||||
"IconsCompoundPreview",
|
|
||||||
"IconsOtherPreview",
|
|
||||||
"MarkdownTextComposerEditPreview",
|
|
||||||
"MatrixBadgeAtomPositivePreview",
|
|
||||||
"MatrixBadgeAtomNeutralPreview",
|
|
||||||
"MatrixBadgeAtomNegativePreview",
|
|
||||||
"MatrixBadgeAtomInfoPreview",
|
|
||||||
"MentionSpanPreview",
|
|
||||||
"MessageComposerViewVoicePreview",
|
|
||||||
"MessagesReactionButtonAddPreview",
|
|
||||||
"MessagesReactionButtonExtraPreview",
|
|
||||||
"MessagesViewWithIdentityChangePreview",
|
|
||||||
"MessagesViewWithTypingPreview",
|
|
||||||
"PageTitleWithIconFullPreview",
|
|
||||||
"PageTitleWithIconMinimalPreview",
|
|
||||||
"PendingMemberRowWithLongNamePreview",
|
|
||||||
"PinUnlockViewInAppPreview",
|
|
||||||
"PollAnswerViewDisclosedNotSelectedPreview",
|
|
||||||
"PollAnswerViewDisclosedSelectedPreview",
|
|
||||||
"PollAnswerViewEndedSelectedPreview",
|
|
||||||
"PollAnswerViewEndedWinnerNotSelectedPreview",
|
|
||||||
"PollAnswerViewEndedWinnerSelectedPreview",
|
|
||||||
"PollAnswerViewUndisclosedNotSelectedPreview",
|
|
||||||
"PollAnswerViewUndisclosedSelectedPreview",
|
|
||||||
"PollContentViewCreatorEditablePreview",
|
|
||||||
"PollContentViewCreatorEndedPreview",
|
|
||||||
"PollContentViewCreatorPreview",
|
|
||||||
"PollContentViewDisclosedPreview",
|
|
||||||
"PollContentViewEndedPreview",
|
|
||||||
"PollContentViewUndisclosedPreview",
|
|
||||||
"ReadReceiptBottomSheetPreview",
|
|
||||||
"RoomMemberListViewBannedPreview",
|
|
||||||
"SasEmojisPreview",
|
|
||||||
"SecureBackupSetupViewChangePreview",
|
|
||||||
"SelectedUserCannotRemovePreview",
|
|
||||||
"TextComposerAddCaptionPreview",
|
|
||||||
"TextComposerCaptionPreview",
|
|
||||||
"TextComposerEditPreview",
|
|
||||||
"TextComposerEditNotEncryptedPreview",
|
|
||||||
"TextComposerEditCaptionPreview",
|
|
||||||
"TextComposerFormattingPreview",
|
|
||||||
"TextComposerFormattingNotEncryptedPreview",
|
|
||||||
"TextComposerLinkDialogCreateLinkPreview",
|
|
||||||
"TextComposerLinkDialogCreateLinkWithoutTextPreview",
|
|
||||||
"TextComposerLinkDialogEditLinkPreview",
|
|
||||||
"TextComposerReplyPreview",
|
|
||||||
"TextComposerReplyNotEncryptedPreview",
|
|
||||||
"TextComposerSimplePreview",
|
|
||||||
"TextComposerSimpleNotEncryptedPreview",
|
|
||||||
"TextComposerVoicePreview",
|
|
||||||
"TextComposerVoiceNotEncryptedPreview",
|
|
||||||
"TextFieldDialogWithBorderPreview",
|
|
||||||
"TextFieldDialogWithErrorPreview",
|
|
||||||
"TimelineImageWithCaptionRowPreview",
|
|
||||||
"TimelineItemEventRowForDirectRoomPreview",
|
|
||||||
"TimelineItemEventRowShieldPreview",
|
|
||||||
"TimelineItemEventRowTimestampPreview",
|
|
||||||
"TimelineItemEventRowUtdPreview",
|
|
||||||
"TimelineItemEventRowWithManyReactionsPreview",
|
|
||||||
"TimelineItemEventRowWithRRPreview",
|
|
||||||
"TimelineItemEventRowWithReplyPreview",
|
|
||||||
"TimelineItemGroupedEventsRowContentCollapsePreview",
|
|
||||||
"TimelineItemGroupedEventsRowContentExpandedPreview",
|
|
||||||
"TimelineItemImageViewHideMediaContentPreview",
|
|
||||||
"TimelineItemVideoViewHideMediaContentPreview",
|
|
||||||
"TimelineItemVoiceViewUnifiedPreview",
|
|
||||||
"TimelineVideoWithCaptionRowPreview",
|
|
||||||
"TimelineViewMessageShieldPreview",
|
|
||||||
"UserAvatarColorsPreview",
|
|
||||||
"UserProfileHeaderSectionWithVerificationViolationPreview",
|
|
||||||
"VoiceItemViewPlayPreview",
|
|
||||||
)
|
|
||||||
.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