diff --git a/tests/e2e/hashRouter.spec.ts b/tests/e2e/hashRouter.spec.ts index 9fb88eb19..65c64e95e 100644 --- a/tests/e2e/hashRouter.spec.ts +++ b/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("/#/"); diff --git a/tests/e2e/historyRouter.spec.ts b/tests/e2e/historyRouter.spec.ts index 03db33675..c0599f612 100644 --- a/tests/e2e/historyRouter.spec.ts +++ b/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("/"); diff --git a/tests/e2e/landingPage.spec.ts b/tests/e2e/landingPage.spec.ts index d4d2782f0..6dcce6f48 100644 --- a/tests/e2e/landingPage.spec.ts +++ b/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."), diff --git a/tests/support/fixtures.ts b/tests/support/fixtures.ts index 8327f7449..f6a5f1a8c 100644 --- a/tests/support/fixtures.ts +++ b/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", + }, + ], + }, + }; +}