Skip to content

Commit

Permalink
test: fix playwright screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurrahman-ledger committed Oct 8, 2024
1 parent aadad8d commit c73005e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions apps/ledger-live-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
"@types/uuid": "^8.3.4",
"@types/write-file-atomic": "^4.0.0",
"@vitejs/plugin-react": "^3.1.0",
"allure-js-commons": "^3.0.4",
"allure-playwright": "3.0.4",
"axios": "1.7.7",
"chalk": "^4.1.2",
Expand Down
18 changes: 6 additions & 12 deletions apps/ledger-live-desktop/tests/utils/allureUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { allure } from "allure-playwright";
import { tms, attachment } from "allure-js-commons";
import { Page, TestInfo } from "@playwright/test";
import { promisify } from "util";
import fs from "fs";
Expand All @@ -9,28 +9,25 @@ const IS_NOT_MOCK = process.env.MOCK == "0";

export async function addTmsLink(ids: string[]) {
for (const id of ids) {
await allure.tms(id, `https://ledgerhq.atlassian.net/browse/${id}`);
await tms(id, `https://ledgerhq.atlassian.net/browse/${id}`);
}
}

export async function captureArtifacts(page: Page, testInfo: TestInfo) {
const screenshot = await page.screenshot();
await testInfo.attach("Screenshot", { body: screenshot, contentType: "image/png" });
await attachment("Screenshot", screenshot, { contentType: "image/png" });

if (IS_NOT_MOCK) {
const speculosScreenshot = await takeScreenshot();
await testInfo.attach("Speculos Screenshot", {
body: speculosScreenshot,
contentType: "image/png",
});
await attachment("Speculos Screenshot", speculosScreenshot, { contentType: "image/png" });
}

if (page.video()) {
const finalVideoPath = await page.video()?.path();
if (finalVideoPath) {
console.log(`Video for test recorded at: ${finalVideoPath}\n`);
const videoData = await readFileAsync(finalVideoPath);
await testInfo.attach("Test Video", { body: videoData, contentType: "video/webm" });
await attachment("Test Video", videoData, { contentType: "video/webm" });
}
}

Expand All @@ -40,8 +37,5 @@ export async function captureArtifacts(page: Page, testInfo: TestInfo) {
window.saveLogs(filePath);
}, filePath);

await testInfo.attach("Test logs", {
path: filePath,
contentType: "application/json",
});
await attachment("Test logs", filePath, { contentType: "application/json" });
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c73005e

Please sign in to comment.