Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Extract custom app config in tests
Rūdolfs Ošiņš committed 3 years ago
commit 0b6d9586ee0d1b85b3a690d78a77eda4b296ab6a
parent d1a1b4c9c04b49360195e611ac241cb6af0465a4
4 files changed +27 -63
modified tests/e2e/hashRouter.spec.ts
@@ -1,4 +1,4 @@
-
import { test, expect } from "@tests/support/fixtures.js";
+
import { test, expect, appConfigWithFixture } from "@tests/support/fixtures.js";
import {
  expectBackAndForwardNavigationWorks,
  expectUrlPersistsReload,
@@ -11,26 +11,7 @@ test.beforeEach(async ({ page }) => {
});

test("navigate between landing and project page", async ({ page }) => {
-
  await page.addInitScript(() => {
-
    window.APP_CONFIG = {
-
      walletConnect: {
-
        bridge: "https://radicle.bridge.walletconnect.org",
-
      },
-
      reactions: [],
-
      seeds: {
-
        pinned: [{ host: "0.0.0.0", emoji: "🚀" }],
-
      },
-
      projects: {
-
        pinned: [
-
          {
-
            name: "source-browsing",
-
            urn: "rad:git:hnrkgd7sjt79k4j59ddh11ooxg18rk7soej8o",
-
            seed: "0.0.0.0",
-
          },
-
        ],
-
      },
-
    };
-
  });
+
  await page.addInitScript(appConfigWithFixture);

  await page.goto("/#/");
  await expect(page).toHaveURL("/#/");
modified tests/e2e/historyRouter.spec.ts
@@ -1,30 +1,11 @@
-
import { test, expect } from "@tests/support/fixtures.js";
+
import { test, expect, appConfigWithFixture } from "@tests/support/fixtures.js";
import {
  expectBackAndForwardNavigationWorks,
  expectUrlPersistsReload,
} from "@tests/support/router.js";

test("navigate between landing and project page", async ({ page }) => {
-
  await page.addInitScript(() => {
-
    window.APP_CONFIG = {
-
      walletConnect: {
-
        bridge: "https://radicle.bridge.walletconnect.org",
-
      },
-
      reactions: [],
-
      seeds: {
-
        pinned: [{ host: "0.0.0.0", emoji: "🚀" }],
-
      },
-
      projects: {
-
        pinned: [
-
          {
-
            name: "source-browsing",
-
            urn: "rad:git:hnrkgd7sjt79k4j59ddh11ooxg18rk7soej8o",
-
            seed: "0.0.0.0",
-
          },
-
        ],
-
      },
-
    };
-
  });
+
  await page.addInitScript(appConfigWithFixture);

  await page.goto("/");
  await expect(page).toHaveURL("/");
modified tests/e2e/landingPage.spec.ts
@@ -1,30 +1,11 @@
-
import { test, expect } from "@tests/support/fixtures.js";
+
import { test, expect, appConfigWithFixture } from "@tests/support/fixtures.js";

test.use({
  customAppConfig: true,
});

test("show pinned projects", async ({ page }) => {
-
  await page.addInitScript(() => {
-
    window.APP_CONFIG = {
-
      walletConnect: {
-
        bridge: "https://radicle.bridge.walletconnect.org",
-
      },
-
      reactions: [],
-
      seeds: {
-
        pinned: [{ host: "0.0.0.0", emoji: "🚀" }],
-
      },
-
      projects: {
-
        pinned: [
-
          {
-
            name: "source-browsing",
-
            urn: "rad:git:hnrkgd7sjt79k4j59ddh11ooxg18rk7soej8o",
-
            seed: "0.0.0.0",
-
          },
-
        ],
-
      },
-
    };
-
  });
+
  await page.addInitScript(appConfigWithFixture);
  await page.goto("/");
  await expect(
    page.locator("text=Explore projects on the Radicle network."),
modified tests/support/fixtures.ts
@@ -156,3 +156,24 @@ function log(text: string, label: string, outputLog: Stream.Writable) {
    console.log(output);
  }
}
+

+
export function appConfigWithFixture() {
+
  window.APP_CONFIG = {
+
    walletConnect: {
+
      bridge: "https://radicle.bridge.walletconnect.org",
+
    },
+
    reactions: [],
+
    seeds: {
+
      pinned: [{ host: "0.0.0.0", emoji: "🚀" }],
+
    },
+
    projects: {
+
      pinned: [
+
        {
+
          name: "source-browsing",
+
          urn: "rad:git:hnrkgd7sjt79k4j59ddh11ooxg18rk7soej8o",
+
          seed: "0.0.0.0",
+
        },
+
      ],
+
    },
+
  };
+
}