Don't check enterprise previews in KonsistPreviewTest (#7297)

Don't check enterprise previews in `KonsistPreviewTest`
This commit is contained in:
Jorge Martin Espinosa
2026-07-30 10:29:43 +02:00
committed by GitHub
parent bac77b7645
commit 9ab679566d
@@ -11,6 +11,7 @@ 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.google.common.truth.Truth.assertThat
import com.lemonappdev.konsist.api.Konsist import com.lemonappdev.konsist.api.Konsist
import com.lemonappdev.konsist.api.declaration.KoFunctionDeclaration
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.withName
import com.lemonappdev.konsist.api.ext.list.withNameEndingWith import com.lemonappdev.konsist.api.ext.list.withNameEndingWith
@@ -61,6 +62,8 @@ class KonsistPreviewTest {
.scopeFromProject() .scopeFromProject()
.functions() .functions()
.withAllAnnotationsOf(PreviewsDayNight::class) .withAllAnnotationsOf(PreviewsDayNight::class)
// We can't check Enterprise previews because they are in a different repo, and they aren't present for FOSS
.withoutEnterpriseFunctions()
.assertTrue { .assertTrue {
it.text.contains("ElementPreview") || it.text.contains("ElementPreview") ||
it.text.contains("ElementTimelineItemPreview") it.text.contains("ElementTimelineItemPreview")
@@ -88,8 +91,6 @@ class KonsistPreviewTest {
"BackgroundVerticalGradientPreview", "BackgroundVerticalGradientPreview",
"ColorAliasesPreview", "ColorAliasesPreview",
"EmojiItemWithPopupPreview", "EmojiItemWithPopupPreview",
"EnterpriseExtraDeveloperOptionsRendererBottomSheetPreview",
"EnterpriseExtraDeveloperOptionsRendererListItemPreview",
"FocusedEventPreview", "FocusedEventPreview",
"GradientFloatingActionButtonCircleShapePreview", "GradientFloatingActionButtonCircleShapePreview",
"HeaderFooterPageScrollablePreview", "HeaderFooterPageScrollablePreview",
@@ -189,7 +190,8 @@ class KonsistPreviewTest {
@Test @Test
fun `previewNameExceptions only contains existing functions`() { fun `previewNameExceptions only contains existing functions`() {
val names = previewNameExceptions.toMutableSet() val names = previewNameExceptions
.toMutableSet()
Konsist Konsist
.scopeFromProject() .scopeFromProject()
.functions() .functions()
@@ -210,6 +212,8 @@ class KonsistPreviewTest {
.functions() .functions()
.withAllAnnotationsOf(PreviewsDayNight::class) .withAllAnnotationsOf(PreviewsDayNight::class)
.withoutName(previewNameExceptions) .withoutName(previewNameExceptions)
// We can't check Enterprise previews because they are in a different repo, and they aren't present for FOSS
.withoutEnterpriseFunctions()
.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",
@@ -237,3 +241,7 @@ class KonsistPreviewTest {
) )
} }
} }
private fun List<KoFunctionDeclaration>.withoutEnterpriseFunctions() = filter { function ->
function.packagee?.hasNameStartingWith("io.element.android.enterprise") != true
}