Add Konsist test to check preview function names.
This commit is contained in:
parent
0938935d16
commit
7f38e14066
1 changed files with 77 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ package io.element.android.tests.konsist
|
||||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
||||||
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.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
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
|
|
@ -60,6 +61,82 @@ class KonsistPreviewTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Functions with '@PreviewsDayNight' have correct name`() {
|
||||||
|
Konsist
|
||||||
|
.scopeFromProject()
|
||||||
|
.functions()
|
||||||
|
.withAllAnnotationsOf(PreviewsDayNight::class)
|
||||||
|
.withoutName(
|
||||||
|
"AsyncIndicatorFailurePreview",
|
||||||
|
"AsyncIndicatorLoadingPreview",
|
||||||
|
"BloomInitialsPreview",
|
||||||
|
"BloomPreview",
|
||||||
|
"ColorAliasesPreview",
|
||||||
|
"DefaultRoomListTopBarWithIndicatorPreview",
|
||||||
|
"GradientFloatingActionButtonCircleShapePreview",
|
||||||
|
"IconTitleSubtitleMoleculeWithResIconPreview",
|
||||||
|
"IconsCompoundPreview",
|
||||||
|
"IconsOtherPreview",
|
||||||
|
"MentionSpanPreview",
|
||||||
|
"MessageComposerViewVoicePreview",
|
||||||
|
"MessagesReactionButtonAddPreview",
|
||||||
|
"MessagesReactionButtonExtraPreview",
|
||||||
|
"MessagesViewWithTypingPreview",
|
||||||
|
"PageTitleWithIconFullPreview",
|
||||||
|
"PageTitleWithIconMinimalPreview",
|
||||||
|
"PendingMemberRowWithLongNamePreview",
|
||||||
|
"PinUnlockViewInAppPreview",
|
||||||
|
"PollAnswerViewDisclosedNotSelectedPreview",
|
||||||
|
"PollAnswerViewDisclosedSelectedPreview",
|
||||||
|
"PollAnswerViewEndedSelectedPreview",
|
||||||
|
"PollAnswerViewEndedWinnerNotSelectedPreview",
|
||||||
|
"PollAnswerViewEndedWinnerSelectedPreview",
|
||||||
|
"PollAnswerViewUndisclosedNotSelectedPreview",
|
||||||
|
"PollAnswerViewUndisclosedSelectedPreview",
|
||||||
|
"PollContentViewCreatorEditablePreview",
|
||||||
|
"PollContentViewCreatorEndedPreview",
|
||||||
|
"PollContentViewCreatorPreview",
|
||||||
|
"PollContentViewDisclosedPreview",
|
||||||
|
"PollContentViewEndedPreview",
|
||||||
|
"PollContentViewUndisclosedPreview",
|
||||||
|
"ReadReceiptBottomSheetPreview",
|
||||||
|
"RoomListModalBottomSheetContentForDmPreview",
|
||||||
|
"RoomMemberListViewBannedPreview",
|
||||||
|
"SasEmojisPreview",
|
||||||
|
"SecureBackupSetupViewChangePreview",
|
||||||
|
"SelectedUserCannotRemovePreview",
|
||||||
|
"TextComposerEditPreview",
|
||||||
|
"TextComposerFormattingPreview",
|
||||||
|
"TextComposerLinkDialogCreateLinkPreview",
|
||||||
|
"TextComposerLinkDialogCreateLinkWithoutTextPreview",
|
||||||
|
"TextComposerLinkDialogEditLinkPreview",
|
||||||
|
"TextComposerReplyPreview",
|
||||||
|
"TextComposerSimplePreview",
|
||||||
|
"TextComposerVoicePreview",
|
||||||
|
"TimelineImageWithCaptionRowPreview",
|
||||||
|
"TimelineItemEventRowForDirectRoomPreview",
|
||||||
|
"TimelineItemEventRowTimestampPreview",
|
||||||
|
"TimelineItemEventRowWithManyReactionsPreview",
|
||||||
|
"TimelineItemEventRowWithRRPreview",
|
||||||
|
"TimelineItemEventRowWithReplyPreview",
|
||||||
|
"TimelineItemGroupedEventsRowContentCollapsePreview",
|
||||||
|
"TimelineItemGroupedEventsRowContentExpandedPreview",
|
||||||
|
"TimelineItemVoiceViewUnifiedPreview",
|
||||||
|
"TimelineVideoWithCaptionRowPreview",
|
||||||
|
"UserAvatarColorsPreview",
|
||||||
|
)
|
||||||
|
.assertTrue(
|
||||||
|
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",
|
||||||
|
) {
|
||||||
|
val testedView = it.name.removeSuffix("Preview")
|
||||||
|
it.text.contains("$testedView(") ||
|
||||||
|
it.text.contains("$testedView {") ||
|
||||||
|
it.text.contains("ContentToPreview(")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Ensure that '@PreviewLightDark' is not used`() {
|
fun `Ensure that '@PreviewLightDark' is not used`() {
|
||||||
Konsist
|
Konsist
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue