Skip to content

Commit 4e765c7

Browse files
authored
fix(html): support multiple videos in test page (#973)
1 parent 9befce5 commit 4e765c7

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

Diff for: core/src/main/kotlin/com/malinskiy/marathon/report/html/HtmlSummaryReporter.kt

+6-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.malinskiy.marathon.config.Configuration
88
import com.malinskiy.marathon.device.DeviceFeature
99
import com.malinskiy.marathon.device.DeviceInfo
1010
import com.malinskiy.marathon.device.DevicePoolId
11+
import com.malinskiy.marathon.execution.AttachmentType
1112
import com.malinskiy.marathon.execution.TestResult
1213
import com.malinskiy.marathon.execution.TestStatus
1314
import com.malinskiy.marathon.extension.escape
@@ -175,14 +176,10 @@ class HtmlSummaryReporter(
175176
}
176177
}
177178

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

188185
private fun TestResult.receiveLogPath(poolId: String, batchId: String): String {
@@ -209,7 +206,7 @@ class HtmlSummaryReporter(
209206
diagnosticScreenshots = device.deviceFeatures.contains(DeviceFeature.SCREENSHOT),
210207
stacktrace = stacktrace,
211208
screenshot = receiveScreenshotPath(poolId, batchId),
212-
video = receiveVideoPath(poolId, batchId),
209+
videos = receiveVideoPaths(poolId, batchId),
213210
logFile = receiveLogPath(poolId, batchId)
214211
)
215212

Diff for: html-report/src/components/TestItem.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ export default class TestItem extends Component {
3838
</div>
3939
</div>
4040

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

4548
{!!data.screenshot && <div className='card row full'>
4649
<img src={data.screenshot}/>

Diff for: report/html-report/src/main/kotlin/com/malinskiy/marathon/report/HtmlFullTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ data class HtmlFullTest(
1616
@SerializedName("diagnostic_video") val diagnosticVideo: Boolean,
1717
@SerializedName("diagnostic_screenshots") val diagnosticScreenshots: Boolean,
1818
@SerializedName("screenshot") val screenshot: String,
19-
@SerializedName("video") val video: String,
19+
@SerializedName("videos") val videos: List<String>,
2020
@SerializedName("log_file") val logFile: String,
2121
)

Diff for: report/html-report/src/main/resources/html-report/app.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)