From c73005e3a21ddc349897b24db5e484f5cf96ac01 Mon Sep 17 00:00:00 2001 From: Abdurrahman SASTIM Date: Tue, 8 Oct 2024 10:23:34 +0200 Subject: [PATCH] test: fix playwright screenshot --- apps/ledger-live-desktop/package.json | 1 + .../tests/utils/allureUtils.ts | 18 ++++++------------ pnpm-lock.yaml | 3 +++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/ledger-live-desktop/package.json b/apps/ledger-live-desktop/package.json index ebee6b30afd9..d9c570e35f4a 100644 --- a/apps/ledger-live-desktop/package.json +++ b/apps/ledger-live-desktop/package.json @@ -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", diff --git a/apps/ledger-live-desktop/tests/utils/allureUtils.ts b/apps/ledger-live-desktop/tests/utils/allureUtils.ts index 9efe66919c44..a3215eb99c87 100644 --- a/apps/ledger-live-desktop/tests/utils/allureUtils.ts +++ b/apps/ledger-live-desktop/tests/utils/allureUtils.ts @@ -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"; @@ -9,20 +9,17 @@ 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()) { @@ -30,7 +27,7 @@ export async function captureArtifacts(page: Page, testInfo: TestInfo) { 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" }); } } @@ -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" }); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43f1afad2dcf..dc767295aa96 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -707,6 +707,9 @@ importers: '@vitejs/plugin-react': specifier: ^3.1.0 version: 3.1.0(vite@4.5.3) + allure-js-commons: + specifier: ^3.0.4 + version: 3.0.4(allure-playwright@3.0.4(@playwright/test@1.47.2)) allure-playwright: specifier: 3.0.4 version: 3.0.4(@playwright/test@1.47.2)