Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,21 @@ class ReaderPostUiStateBuilder @Inject constructor(
// TODO malinjir show overlay when buildFullVideoUrl != null
private fun buildVideoOverlayVisibility(post: ReaderPost) = post.cardType == VIDEO

private fun buildFeaturedImageVisibility(post: ReaderPost) =
(post.cardType == PHOTO || post.cardType == DEFAULT) && post.hasFeaturedImage() ||
post.cardType == VIDEO && post.hasFeaturedVideo()
private fun buildFeaturedImageVisibility(post: ReaderPost): Boolean {
return when (post.cardType) {
GALLERY -> false
VIDEO -> post.hasFeaturedVideo() || post.hasFeaturedImage()
else -> post.hasFeaturedImage()
}
}

private fun buildThumbnailStripUrls(post: ReaderPost) =
post.takeIf { it.cardType == GALLERY }
?.let { retrieveGalleryThumbnailUrls(post) }

private fun buildFeaturedImageUrl(post: ReaderPost, photonWidth: Int, photonHeight: Int): String? {
return post
.takeIf { (it.cardType == PHOTO || it.cardType == DEFAULT) && it.hasFeaturedImage() }
.takeIf { it.cardType != GALLERY && it.hasFeaturedImage() }
?.getFeaturedImageForDisplay(photonWidth, photonHeight)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ class ReaderPostUiStateBuilderTest : BaseUnitTest() {

// region FEATURED IMAGE
@Test
fun `featured image is displayed for photo and default card types`() = test {
fun `featured image is displayed for supported card types`() = test {
// Arrange
val dummyUrl = "12345"
ReaderCardType.values().filter { it == PHOTO || it == DEFAULT }.forEach {
ReaderCardType.values().filter { it != GALLERY }.forEach {
val post = createPost(cardType = it, hasFeaturedImage = true, featuredImageUrlForDisplay = dummyUrl)
// Act
val uiState = mapPostToUiState(post)
Expand All @@ -325,10 +325,10 @@ class ReaderPostUiStateBuilderTest : BaseUnitTest() {
}

@Test
fun `featured image is displayed for photo and default card types for new UI`() = test {
fun `featured image is displayed for supported card types for new UI`() = test {
// Arrange
val dummyUrl = "12345"
ReaderCardType.values().filter { it == PHOTO || it == DEFAULT }.forEach {
ReaderCardType.values().filter { it != GALLERY }.forEach {
val post = createPost(cardType = it, hasFeaturedImage = true, featuredImageUrlForDisplay = dummyUrl)
// Act
val uiState = mapPostToUiState(post)
Expand All @@ -338,27 +338,23 @@ class ReaderPostUiStateBuilderTest : BaseUnitTest() {
}

@Test
fun `featured image is not displayed for other than photo and default card types`() = test {
fun `featured image is not displayed for gallery card type`() = test {
// Arrange
ReaderCardType.values().filter { it != PHOTO && it != DEFAULT }.forEach {
val post = createPost(cardType = it, hasFeaturedImage = true)
// Act
val uiState = mapPostToUiState(post)
// Assert
assertThat(uiState.featuredImageUrl).isNull()
}
val post = createPost(cardType = GALLERY, hasFeaturedImage = true)
// Act
val uiState = mapPostToUiState(post)
// Assert
assertThat(uiState.featuredImageUrl).isNull()
}

@Test
fun `featured image is not displayed for other than photo and default card types for new UI`() = test {
fun `featured image is not displayed for gallery card type for new UI`() = test {
// Arrange
ReaderCardType.values().filter { it != PHOTO && it != DEFAULT }.forEach {
val post = createPost(cardType = it, hasFeaturedImage = true)
// Act
val uiState = mapPostToUiState(post)
// Assert
assertThat(uiState.featuredImageUrl).isNull()
}
val post = createPost(cardType = GALLERY, hasFeaturedImage = true)
// Act
val uiState = mapPostToUiState(post)
// Assert
assertThat(uiState.featuredImageUrl).isNull()
}

@Test
Expand All @@ -380,6 +376,21 @@ class ReaderPostUiStateBuilderTest : BaseUnitTest() {
// Assert
assertThat(uiState.featuredImageUrl).isNull()
}

@Test
fun `video card shows featured media area when only video is available`() = test {
// Arrange
val post = createPost(
cardType = VIDEO,
hasFeaturedVideo = true,
featuredVideoUrl = "video://example",
hasFeaturedImage = false
)
// Act
val uiState = mapPostToUiState(post)
// Assert
assertThat(uiState.featuredImageVisibility).isTrue
}
// endregion

// region TITLE & EXCERPT
Expand Down