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