Skip to content
Merged
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 @@ -58,7 +58,9 @@ class ConferenceDetailsUpdate : UpdateInit<ConferenceDetailsModel, ConferenceDet
}
is ConferenceDetailsEvent.RecordingClicked -> {
val recording = model.conference.recordings.first { it.recordingId == event.recordingId }
val url = recording.playbackUrl ?: recording.playbackFormats.firstOrNull()?.url.orEmpty()
val url = recording.playbackUrl
?: recording.playbackFormats.find { it.type == "presentation" }?.url
?: recording.playbackFormats.firstOrNull()?.url.orEmpty()
val newModel = model.copy(
launchingRecordings = model.launchingRecordings.plus(recording.recordingId to true)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
package com.instructure.student.test.conferences.conference_details

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.instructure.canvasapi2.models.*
import com.instructure.canvasapi2.models.CanvasContext
import com.instructure.canvasapi2.models.Conference
import com.instructure.canvasapi2.models.ConferenceRecording
import com.instructure.canvasapi2.models.Course
import com.instructure.canvasapi2.models.PlaybackFormat
import com.instructure.canvasapi2.utils.ApiPrefs
import com.instructure.canvasapi2.utils.DataResult
import com.instructure.student.mobius.conferences.conference_details.ConferenceDetailsEffect
Expand All @@ -33,7 +37,6 @@ import com.spotify.mobius.test.UpdateSpec
import com.spotify.mobius.test.UpdateSpec.assertThatNext
import io.mockk.every
import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import org.junit.After
import org.junit.Before
Expand Down Expand Up @@ -225,6 +228,46 @@ class ConferenceDetailsUpdateTest {
)
}

@Test
fun `RecordingClicked prioritizes presentation type over notes when playbackUrl is null`() {
val conferenceWithMultipleFormats = baseConference.copy(
recordings = listOf(
ConferenceRecording(
recordingId = "recording_3",
playbackUrl = null,
playbackFormats = listOf(
PlaybackFormat(
length = null,
type = "notes",
url = "https://some.fake.url/recording_3/notes"
),
PlaybackFormat(
length = "1",
type = "presentation",
url = "https://some.fake.url/recording_3/presentation"
)
)
)
)
)
val inputModel = initModel.copy(conference = conferenceWithMultipleFormats)
val expectedModel = inputModel.copy(launchingRecordings = mapOf("recording_3" to true))
updateSpec
.given(inputModel)
.whenEvent(ConferenceDetailsEvent.RecordingClicked(recordingId = "recording_3"))
.then(
assertThatNext(
NextMatchers.hasModel(expectedModel),
matchesEffects(
ConferenceDetailsEffect.ShowRecording(
"recording_3",
"https://some.fake.url/recording_3/presentation"
)
)
)
)
}

@Test
fun `ShowRecordingFinished event updates the model`() {
val recording = baseConference.recordings[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ data class ConferenceRecording(

@Parcelize
data class PlaybackFormat(
val length: String,
val length: String?,
val type: String,
val url: String
) : Parcelable
Loading