Skip to content

Commit

Permalink
fix(html): support multiple videos in test page (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malinskiy authored Sep 23, 2024
1 parent 9befce5 commit 4e765c7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.malinskiy.marathon.config.Configuration
import com.malinskiy.marathon.device.DeviceFeature
import com.malinskiy.marathon.device.DeviceInfo
import com.malinskiy.marathon.device.DevicePoolId
import com.malinskiy.marathon.execution.AttachmentType
import com.malinskiy.marathon.execution.TestResult
import com.malinskiy.marathon.execution.TestStatus
import com.malinskiy.marathon.extension.escape
Expand Down Expand Up @@ -175,14 +176,10 @@ class HtmlSummaryReporter(
}
}

private fun TestResult.receiveVideoPath(poolId: String, batchId: String): String {
val videoRelativePath =
fileManager.createFile(FileType.VIDEO, DevicePoolId(poolId), device, test, batchId).relativePathTo(rootOutput)
val videoFullPath = File(rootOutput, videoRelativePath)
return when (device.deviceFeatures.contains(DeviceFeature.VIDEO) && videoFullPath.exists()) {
true -> "../../../../${videoRelativePath.replace("#", "%23")}"
false -> ""
}
private fun TestResult.receiveVideoPaths(poolId: String, batchId: String): List<String> {
if (!device.deviceFeatures.contains(DeviceFeature.VIDEO)) return emptyList()
return attachments.filter { it.type == AttachmentType.VIDEO && it.file.exists() }.map { it.file.relativePathTo(rootOutput) }
.map { "../../../../${it.replace("#","%23")}" }
}

private fun TestResult.receiveLogPath(poolId: String, batchId: String): String {
Expand All @@ -209,7 +206,7 @@ class HtmlSummaryReporter(
diagnosticScreenshots = device.deviceFeatures.contains(DeviceFeature.SCREENSHOT),
stacktrace = stacktrace,
screenshot = receiveScreenshotPath(poolId, batchId),
video = receiveVideoPath(poolId, batchId),
videos = receiveVideoPaths(poolId, batchId),
logFile = receiveLogPath(poolId, batchId)
)

Expand Down
9 changes: 6 additions & 3 deletions html-report/src/components/TestItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ export default class TestItem extends Component {
</div>
</div>

{!!data.video && <div className='card row full'>
<ReactPlayer url={data.video} controls={true} playsinline={true}/>
</div>}
<div className="container-expanded list">
{data.videos.map((video, i) => {
return (<div className='card row full'><ReactPlayer url={video} controls={true} playsinline={true}/></div>)
})
}
</div>

{!!data.screenshot && <div className='card row full'>
<img src={data.screenshot}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ data class HtmlFullTest(
@SerializedName("diagnostic_video") val diagnosticVideo: Boolean,
@SerializedName("diagnostic_screenshots") val diagnosticScreenshots: Boolean,
@SerializedName("screenshot") val screenshot: String,
@SerializedName("video") val video: String,
@SerializedName("videos") val videos: List<String>,
@SerializedName("log_file") val logFile: String,
)

Large diffs are not rendered by default.

0 comments on commit 4e765c7

Please sign in to comment.