Skip to content

Commit

Permalink
test: updated market buy steps to use dummy app
Browse files Browse the repository at this point in the history
  • Loading branch information
ggilchrist-ledger committed Sep 12, 2023
1 parent 533278e commit 7f97b21
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions apps/ledger-live-desktop/tests/specs/market/market.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
});

Expand All @@ -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);
});
});

0 comments on commit 7f97b21

Please sign in to comment.