Skip to content

Commit

Permalink
Create in report support for webm video in the report output
Browse files Browse the repository at this point in the history
A small PR to add video attachment support (webm) similar to the way image (png) is supported. This is change is primarily to support Playwright's video functionality.

See documentation: https://playwright.dev/docs/videos
  • Loading branch information
MarcTaipala committed Sep 2, 2024
1 parent 2c391d3 commit f4f2d17
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/generate-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,14 @@ function generateReport(options) {
'data:image/png;base64,' + embedding.data,
]);
step.embeddings[embeddingIndex] = {};
} else if (
embedding.mime_type === 'video/webm' ||
(embedding.media && embedding.media.type === 'video/webm')
) {
step.video = (step.video ? step.video : []).concat([
'data:video/webm;base64,' + embedding.data,
]);
step.embeddings[embeddingIndex] = {};
} else {
let embeddingType = 'text/plain';
if (embedding.mime_type) {
Expand Down Expand Up @@ -479,6 +487,7 @@ function generateReport(options) {
(step.hidden &&
!step.text &&
!step.image &&
!step.video &&
_.size(step.attachments) === 0 &&
step.result.status !== RESULT_STATUS.failed)
) {
Expand Down
18 changes: 16 additions & 2 deletions templates/components/scenarios.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<div class="x_content" style="display: none;">
<div class="scenario-step-container"><%= scenario.description %></div>
<% _.each(scenario.steps, function(step, stepIndex) { %>
<% if(!step.hidden || step.image || step.text || step.html || step.attachment) { %>
<% if(!step.hidden || step.image || step.video || step.text || step.html || step.attachment) { %>
<div class="scenario-step-container">

<% if(step.result) { %>
Expand Down Expand Up @@ -156,7 +156,7 @@
<% if (step.json) { %>
<a href="#info<%= scenarioIndex %>-<%= stepIndex %>-json" data-toggle="collapse">+ Show Info</a>
<% } %>

<% if (step.text) { %>
<a href="#info<%= scenarioIndex %>-<%= stepIndex %>-text" data-toggle="collapse">+ Show Info</a>
<% } %>
Expand All @@ -169,6 +169,10 @@
<a href="#info<%= scenarioIndex %>-<%= stepIndex %>-image" data-toggle="collapse">+ Screenshot</a>
<% } %>

<% if (step.video) { %>
<a href="#info<%= scenarioIndex %>-<%= stepIndex %>-video" data-toggle="collapse">+ Video</a>
<% } %>

<% if (!_.isEmpty(step.attachments)) { %>
<span>[</span>
<% _.each(step.attachments, function(attachment, attachmentIndex) { %>
Expand Down Expand Up @@ -215,6 +219,16 @@
</div>
<% } %>

<% if (step.video) { %>
<div id="info<%= scenarioIndex %>-<%= stepIndex %>-video" class="scenario-step-collapse collapse">
<% for( var i = 0; i < step.video.length; i++ ) { %>
<video class="videoCapture" controls>
<source type="video/webm" src="<%= step.video[i] %>"/>
</video>
<% } %>
</div>
<% } %>

<% if (!_.isEmpty(step.attachments)) { %>
<% _.each(step.attachments, function(attachment, attachmentIndex) { %>
<div id="info<%= scenarioIndex %>-<%= stepIndex %>-attachment<%= attachmentIndex %>" class="scenario-step-collapse collapse">
Expand Down
7 changes: 7 additions & 0 deletions templates/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,13 @@ ul.quick-list li i {
max-width: 100%;
}

.videoCapture{
width: 50%;
height: 50%;
max-height: 100%;
max-width: 100%;
}

/* Features / Scenarios */
ul.panel_toolbox li .step {
border-radius: 50%;
Expand Down

0 comments on commit f4f2d17

Please sign in to comment.