diff --git a/apps/ledger-live-desktop/tests/specs/market/market.spec.ts b/apps/ledger-live-desktop/tests/specs/market/market.spec.ts index 22f5f338e89b..8f53e7f81684 100644 --- a/apps/ledger-live-desktop/tests/specs/market/market.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/market/market.spec.ts @@ -4,15 +4,44 @@ import { MarketPage } from "../../models/MarketPage"; import { Layout } from "../../models/Layout"; import { MarketCoinPage } from "../../models/MarketCoinPage"; import { getProvidersMock } from "../services/services-api-mocks/getProviders.mock"; +import { LiveAppWebview } from "../../models/LiveAppWebview"; -test.use({ - userdata: "skip-onboarding", +test.use({ userdata: "skip-onboarding" }); + +let testServerIsRunning = false; + +test.beforeAll(async () => { + // Check that dummy app in libs/test-utils/dummy-ptx-app has been started successfully + testServerIsRunning = await LiveAppWebview.startLiveApp("dummy-ptx-app/public", { + name: "Buy App", + id: "multibuy-v2", + permissions: [ + { + method: "account.request", + params: { + currencies: ["ethereum", "bitcoin", "algorand"], + }, + }, + ], + }); + + if (!testServerIsRunning) { + console.warn("Stopping Buy/Sell test setup"); + return; + } +}); + +test.afterAll(async () => { + if (testServerIsRunning) { + await LiveAppWebview.stopLiveApp(); + } }); test("Market", async ({ page }) => { const marketPage = new MarketPage(page); const marketCoinPage = new MarketCoinPage(page); const layout = new Layout(page); + const liveAppWebview = new LiveAppWebview(page); await page.route("https://swap.ledger.com/v4/providers**", async (route: Route) => { const mockProvidersResponse = getProvidersMock(); @@ -60,7 +89,14 @@ test("Market", async ({ page }) => { await test.step("buy bitcoin from market page", async () => { await marketPage.openBuyPage("btc"); - await expect.soft(page).toHaveScreenshot("market-btc-buy-page.png"); + await expect + .soft(page) + .toHaveScreenshot("market-btc-buy-page.png", { mask: [page.locator("webview")] }); + await expect(await liveAppWebview.waitForCorrectTextInWebview("theme: dark")).toBe(true); + await expect(await liveAppWebview.waitForCorrectTextInWebview("currency: bitcoin")).toBe(true); + await expect(await liveAppWebview.waitForCorrectTextInWebview("mode: buy")).toBe(true); + await expect(await liveAppWebview.waitForCorrectTextInWebview("lang: en")).toBe(true); + await layout.goToMarket(); }); @@ -71,6 +107,12 @@ test("Market", async ({ page }) => { await test.step("buy bitcoin from coin page", async () => { await marketCoinPage.openBuyPage(); - await expect.soft(page).toHaveScreenshot("market-btc-buy-page.png"); + await expect + .soft(page) + .toHaveScreenshot("market-btc-buy-page.png", { mask: [page.locator("webview")] }); + await expect(await liveAppWebview.waitForCorrectTextInWebview("theme: dark")).toBe(true); + await expect(await liveAppWebview.waitForCorrectTextInWebview("currency: bitcoin")).toBe(true); + await expect(await liveAppWebview.waitForCorrectTextInWebview("mode: buy")).toBe(true); + await expect(await liveAppWebview.waitForCorrectTextInWebview("lang: en")).toBe(true); }); });