Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(html): support multiple videos in test page #973

Merged
merged 1 commit into from
Sep 23, 2024
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 @@ -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.

Loading