-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrerecord.js
65 lines (57 loc) · 1.33 KB
/
rerecord.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function assert(condition, message) {
if (!condition) {
throw new Error(message ?? "Assertion failed");
}
}
async function rerecordIssue(options) {
const {
client,
apiKey,
serverURL,
recordingId,
revision,
} = options;
await client.initialize();
const sessionRv = await client.sendCommand({
method: "Recording.createSession",
params: { recordingId }
});
const { sessionId } = sessionRv;
assert(sessionId);
const rv = await client.sendCommand({
method: "Session.experimentalCommand",
params: {
name: "rerecordCompare",
params: {
rerecordServerURL: serverURL,
apiKey,
},
},
sessionId,
});
console.log("rerecordCompare finished", JSON.stringify(rv));
const {
result,
rerecordedRecordingId,
originalScreenshotURL,
rerecordedScreenshotURL,
} = rv.rval;
assert(result === "Success");
assert(rerecordedRecordingId);
assert(originalScreenshotURL);
assert(rerecordedScreenshotURL);
return `
Rerecording for ${revision}: https://app.replay.io/recording/${rerecordedRecordingId}
<table>
<tr>
<td>Before</td>
<td>After</td>
</tr>
<tr>
<td><img alt="Before" src="${originalScreenshotURL}"></td>
<td><img alt="After" src="${rerecordedScreenshotURL}"></td>
</tr>
</table>
`;
}
module.exports = rerecordIssue;