Konsist: add test to ensure that functions with @PreviewsDayNight contain ElementTheme composable, and fix existing issues.
This commit is contained in:
parent
f283594fbd
commit
577527902f
5 changed files with 22 additions and 9 deletions
|
|
@ -34,6 +34,7 @@ import androidx.compose.ui.text.input.TextFieldValue
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.features.lockscreen.impl.pin.model.PinDigit
|
import io.element.android.features.lockscreen.impl.pin.model.PinDigit
|
||||||
import io.element.android.features.lockscreen.impl.pin.model.PinEntry
|
import io.element.android.features.lockscreen.impl.pin.model.PinEntry
|
||||||
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.pinDigitBg
|
import io.element.android.libraries.designsystem.theme.pinDigitBg
|
||||||
import io.element.android.libraries.theme.ElementTheme
|
import io.element.android.libraries.theme.ElementTheme
|
||||||
|
|
@ -107,7 +108,7 @@ private fun PinDigitView(
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun PinEntryTextFieldPreview() {
|
internal fun PinEntryTextFieldPreview() {
|
||||||
ElementTheme {
|
ElementPreview {
|
||||||
PinEntryTextField(
|
PinEntryTextField(
|
||||||
pinEntry = PinEntry.empty(4).fillWith("12"),
|
pinEntry = PinEntry.empty(4).fillWith("12"),
|
||||||
onValueChange = {},
|
onValueChange = {},
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.features.messages.impl.R
|
import io.element.android.features.messages.impl.R
|
||||||
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||||
import io.element.android.libraries.designsystem.utils.CommonDrawables
|
import io.element.android.libraries.designsystem.utils.CommonDrawables
|
||||||
|
|
@ -61,7 +62,7 @@ fun TimelineEncryptedHistoryBannerView(modifier: Modifier = Modifier) {
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun TimelineEncryptedHistoryBannerViewPreview() {
|
internal fun TimelineEncryptedHistoryBannerViewPreview() {
|
||||||
ElementTheme {
|
ElementPreview {
|
||||||
TimelineEncryptedHistoryBannerView()
|
TimelineEncryptedHistoryBannerView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import io.element.android.libraries.designsystem.components.dialogs.ListDialog
|
import io.element.android.libraries.designsystem.components.dialogs.ListDialog
|
||||||
import io.element.android.libraries.designsystem.components.list.TextFieldListItem
|
import io.element.android.libraries.designsystem.components.list.TextFieldListItem
|
||||||
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.components.ListItem
|
import io.element.android.libraries.designsystem.theme.components.ListItem
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
|
|
@ -200,7 +201,7 @@ private fun EditLinkDialog(
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun TextComposerLinkDialogCreateLinkPreview() {
|
internal fun TextComposerLinkDialogCreateLinkPreview() = ElementPreview {
|
||||||
TextComposerLinkDialog(
|
TextComposerLinkDialog(
|
||||||
onDismissRequest = {},
|
onDismissRequest = {},
|
||||||
linkAction = LinkAction.InsertLink,
|
linkAction = LinkAction.InsertLink,
|
||||||
|
|
@ -212,7 +213,7 @@ internal fun TextComposerLinkDialogCreateLinkPreview() {
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun TextComposerLinkDialogCreateLinkWithoutTextPreview() {
|
internal fun TextComposerLinkDialogCreateLinkWithoutTextPreview() = ElementPreview {
|
||||||
TextComposerLinkDialog(
|
TextComposerLinkDialog(
|
||||||
onDismissRequest = {},
|
onDismissRequest = {},
|
||||||
linkAction = LinkAction.SetLink(null),
|
linkAction = LinkAction.SetLink(null),
|
||||||
|
|
@ -224,7 +225,7 @@ internal fun TextComposerLinkDialogCreateLinkWithoutTextPreview() {
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun TextComposerLinkDialogEditLinkPreview() {
|
internal fun TextComposerLinkDialogEditLinkPreview() = ElementPreview {
|
||||||
TextComposerLinkDialog(
|
TextComposerLinkDialog(
|
||||||
onDismissRequest = {},
|
onDismissRequest = {},
|
||||||
linkAction = LinkAction.SetLink("https://element.io"),
|
linkAction = LinkAction.SetLink("https://element.io"),
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
import io.element.android.libraries.theme.ElementTheme
|
import io.element.android.libraries.theme.ElementTheme
|
||||||
|
|
@ -46,9 +47,7 @@ internal fun RecordingProgress(
|
||||||
shape = MaterialTheme.shapes.medium,
|
shape = MaterialTheme.shapes.medium,
|
||||||
)
|
)
|
||||||
.padding(start = 12.dp, end = 20.dp, top = 8.dp, bottom = 8.dp)
|
.padding(start = 12.dp, end = 20.dp, top = 8.dp, bottom = 8.dp)
|
||||||
.heightIn(26.dp)
|
.heightIn(26.dp),
|
||||||
|
|
||||||
,
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
|
|
@ -69,6 +68,6 @@ internal fun RecordingProgress(
|
||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun RecordingProgressPreview() {
|
internal fun RecordingProgressPreview() = ElementPreview {
|
||||||
RecordingProgress()
|
RecordingProgress()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,15 @@ class KonsistPreviewTest {
|
||||||
it.hasNameEndingWith("DarkPreview").not()
|
it.hasNameEndingWith("DarkPreview").not()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Functions with '@PreviewsDayNight' annotation should contain 'ElementPreview' composable`() {
|
||||||
|
Konsist
|
||||||
|
.scopeFromProject()
|
||||||
|
.functions()
|
||||||
|
.withAllAnnotationsOf(PreviewsDayNight::class)
|
||||||
|
.assertTrue {
|
||||||
|
it.text.contains("ElementPreview")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue