-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
43 deletions.
There are no files selected for viewing
59 changes: 32 additions & 27 deletions
59
snapshots/snapshots/src/main/kotlin/com/emergetools/snapshots/SnapshotImageMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,51 @@ | ||
package com.emergetools.snapshots | ||
|
||
import com.emergetools.snapshots.shared.ComposePreviewSnapshotConfig | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.JsonClassDiscriminator | ||
|
||
enum class SnapshotType { | ||
COMPOSABLE, | ||
VIEW, | ||
ACTIVITY, | ||
} | ||
|
||
@OptIn(ExperimentalSerializationApi::class) | ||
@Serializable | ||
@JsonClassDiscriminator("metadataType") | ||
sealed class SnapshotMetadata { | ||
abstract val name: String | ||
abstract val displayName: String? | ||
abstract val fqn: String | ||
abstract val type: SnapshotType | ||
abstract val composePreviewSnapshotConfig: ComposePreviewSnapshotConfig? | ||
} | ||
|
||
@Serializable | ||
internal data class SnapshotImageMetadata( | ||
// Used as the primary key | ||
override val name: String, | ||
// User defined name, or set to defaults by our backend | ||
override val displayName: String?, | ||
// Filename of the outputted image | ||
val filename: String, | ||
// FQN of the test class | ||
override val fqn: String, | ||
override val type: SnapshotType, | ||
// Compose-specific metadata, only set if type == COMPOSABLE | ||
override val composePreviewSnapshotConfig: ComposePreviewSnapshotConfig? = null, | ||
) : SnapshotMetadata() | ||
@Serializable | ||
internal class SuccessMetadata( | ||
// Used as the primary key | ||
override val name: String, | ||
// User defined name, or set to defaults by our backend | ||
override val displayName: String?, | ||
// Filename of the outputted image | ||
val filename: String, | ||
// FQN of the test class | ||
override val fqn: String, | ||
override val type: SnapshotType, | ||
// Compose-specific metadata, only set if type == COMPOSABLE | ||
override val composePreviewSnapshotConfig: ComposePreviewSnapshotConfig? = null, | ||
) : SnapshotMetadata() | ||
|
||
@Serializable | ||
internal data class SnapshotErrorMetadata( | ||
// Used as the primary key | ||
override val name: String, | ||
// User defined name, or set to defaults by our backend | ||
override val displayName: String?, | ||
// FQN of the test class | ||
override val fqn: String, | ||
override val type: SnapshotType, | ||
// Compose-specific metadata, only set if type == COMPOSABLE | ||
override val composePreviewSnapshotConfig: ComposePreviewSnapshotConfig? = null, | ||
) : SnapshotMetadata() | ||
@Serializable | ||
internal class ErrorMetadata( | ||
// Used as the primary key | ||
override val name: String, | ||
// User defined name, or set to defaults by our backend | ||
override val displayName: String?, | ||
// FQN of the test class | ||
override val fqn: String, | ||
override val type: SnapshotType, | ||
// Compose-specific metadata, only set if type == COMPOSABLE | ||
override val composePreviewSnapshotConfig: ComposePreviewSnapshotConfig? = null, | ||
) : SnapshotMetadata() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters