Extract custom app config in tests

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-12-16 15:05:57 +01:00
parent d1a1b4c9c0
commit 0b6d9586ee
4 changed files with 27 additions and 63 deletions
+2 -21
View File
@@ -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("/#/");
+2 -21
View File
@@ -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("/");
+2 -21
View File
@@ -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."),
+21
View File
@@ -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",
},
],
},
};
}