Skip to content

Commit

Permalink
Adding TMS link + screenshots on failure to allure (#7029)
Browse files Browse the repository at this point in the history
  • Loading branch information
valber-ledger committed Jun 7, 2024
1 parent a1d1f1e commit f0b0ae5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions apps/ledger-live-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"test:jest": "jest src --maxWorkers=50%",
"test:jest:coverage": "pnpm test:jest --ci --coverage",
"test:playwright:setup": "playwright install chromium",
"test:playwright": "playwright test --config=tests/playwright.config.ts --reporter=allure-playwright --project=mocked_tests",
"test:playwright:speculos": "playwright test --config=tests/playwright.config.ts --reporter=allure-playwright --project=speculos_tests",
"test:playwright": "playwright test --config=tests/playwright.config.ts --project=mocked_tests",
"test:playwright:speculos": "playwright test --config=tests/playwright.config.ts --project=speculos_tests",
"test:playwright:smoke": "pnpm test:playwright --grep @smoke",
"test:playwright:update-snapshots": "pnpm test:playwright --update-snapshots",
"test:playwright:recorder": "playwright test tests/specs/recorder.spec.ts",
Expand Down
15 changes: 15 additions & 0 deletions apps/ledger-live-desktop/tests/fixtures/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { getEnv, setEnv } from "@ledgerhq/live-env";
import { startSpeculos, stopSpeculos } from "../utils/speculos";
import { Spec } from "../utils/speculos";

import { allure } from "allure-playwright";

export function generateUUID(): string {
return crypto.randomBytes(16).toString("hex");
}
Expand Down Expand Up @@ -239,4 +241,17 @@ export const test = base.extend<TestFixtures>({
],
});

test.afterEach(async ({ page }, testInfo) => {
if (testInfo.status !== testInfo.expectedStatus) {
const screenshot = await page.screenshot();
await allure.attachment("Screenshot on Failure", screenshot, "image/png");
}
});

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

export default test;
4 changes: 2 additions & 2 deletions apps/ledger-live-desktop/tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const config: PlaywrightTestConfig = {
globalTeardown: require.resolve("./utils/global-teardown"),
use: {
ignoreHTTPSErrors: true,
screenshot: process.env.CI ? "on" : "off",
screenshot: process.env.CI ? "only-on-failure" : "off",
},
forbidOnly: !!process.env.CI,
preserveOutput: process.env.CI ? "failures-only" : "always",
Expand All @@ -48,7 +48,7 @@ const config: PlaywrightTestConfig = {
["line"],
["allure-playwright"],
]
: "allure-playwright",
: [["allure-playwright"]],
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import test from "../../fixtures/common";
import { specs } from "../../utils/speculos";
import { Currency } from "../../enum/Currency";
import { Application } from "tests/page";
import { addTmsLink } from "tests/fixtures/common";

const currencies: Currency[] = [
Currency.BTC,
Expand All @@ -27,13 +28,9 @@ for (const [i, currency] of currencies.entries()) {
});
let firstAccountName = "NO ACCOUNT NAME YET";

//@TmsLink("B2CQA-101")
//@TmsLink("B2CQA-102")
//@TmsLink("B2CQA-314")
//@TmsLink("B2CQA-330")
//@TmsLink("B2CQA-929")

test(`[${currency.uiName}] Add account`, async ({ page }) => {
addTmsLink(["B2CQA-101", "B2CQA-102", "B2CQA-314", "B2CQA-330", "B2CQA-929"]);

const app = new Application(page);

await app.portfolio.openAddAccountModal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import test from "../../fixtures/common";
import { specs } from "../../utils/speculos";
import { Account } from "../../enum/Account";
import { Application } from "tests/page";
import { addTmsLink } from "tests/fixtures/common";

const accounts: Account[] = [
Account.BTC_1,
Expand All @@ -27,9 +28,9 @@ for (const [i, account] of accounts.entries()) {
speculosOffset: i,
});

//@TmsLink("B2CQA-320")

test(`[${account.currency.uiName}] Delete Account`, async ({ page }) => {
addTmsLink(["B2CQA-320"]);

const app = new Application(page);

await app.layout.goToAccounts();
Expand Down
5 changes: 3 additions & 2 deletions apps/ledger-live-desktop/tests/specs/speculos/erc20.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import test from "../../fixtures/common";
import { specs } from "../../utils/speculos";
import { Application } from "tests/page";
import { addTmsLink } from "tests/fixtures/common";

test.use({
userdata: "speculos-tests-app",
Expand All @@ -11,9 +12,9 @@ test.use({
const token = "Tether USD";

test.describe.parallel("ERC20 token", () => {
//@TmsLink("B2CQA-1079")

test(`Check ERC20 token`, async ({ page }) => {
addTmsLink(["B2CQA-1079"]);

const app = new Application(page);

await app.layout.goToPortfolio();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import test from "../../fixtures/common";
import { Account } from "../../enum/Account";
import { specs } from "../../utils/speculos";
import { Application } from "tests/page";
import { addTmsLink } from "tests/fixtures/common";

const accounts: Account[] = [
// Derivation path is updated when account receive money
Expand All @@ -26,9 +27,9 @@ for (const [i, account] of accounts.entries()) {
speculosOffset: i,
});

//@TmsLink("B2CQA-249")

test(`[${account.currency.uiName}] Receive`, async ({ page }) => {
addTmsLink(["B2CQA-249"]);

const app = new Application(page);

await app.layout.goToAccounts();
Expand Down

0 comments on commit f0b0ae5

Please sign in to comment.