Files
radicle-explorer/tests/e2e/hashRouter.spec.ts
T
Sebastian Martinez 4c3bd7ee04 Fix statically replaced HASH_ROUTING env variables
Also moves the HASH_ROUTING env variable from being modified inside the
hashRouter.spec.ts into the webserver config in the
playwright.config.ipfs.ts

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-04-03 11:50:24 +02:00

112 lines
3.5 KiB
TypeScript

import {
aliceMainHead,
aliceRemote,
appConfigWithFixture,
expect,
projectFixtureUrl,
test,
} 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(appConfigWithFixture);
await page.goto("/#/");
await expect(page).toHaveURL("/#/");
await page.locator("text=source-browsing").click();
await expect(page).toHaveURL(`/#${projectFixtureUrl}`);
await expectBackAndForwardNavigationWorks("/#/", page);
await expectUrlPersistsReload(page);
});
test("navigation between seed and project pages", async ({ page }) => {
await page.goto("/#/seeds/radicle.local");
const project = page.locator(".project");
await project.click();
await expect(page).toHaveURL(`/#${projectFixtureUrl}`);
await expectBackAndForwardNavigationWorks("/#/seeds/radicle.local", page);
await expectUrlPersistsReload(page);
await page.locator('role=button[name="Seed"]').click();
await expect(page).toHaveURL("/#/seeds/0.0.0.0");
});
test.describe("project page navigation", () => {
test("navigation between commit history and single commit", async ({
page,
}) => {
const projectHistoryURL = `/#${projectFixtureUrl}/history/${aliceMainHead}`;
await page.goto(projectHistoryURL);
await page.locator("text=Add Markdown cheat sheet").click();
await expect(page).toHaveURL(
`/#${projectFixtureUrl}/commits/f0b8db68847b01f0964380507a9db6800e5b5342`,
);
await expectBackAndForwardNavigationWorks(projectHistoryURL, page);
await expectUrlPersistsReload(page);
});
test("navigate between tree and commit history", async ({ page }) => {
const projectTreeURL = `/#${projectFixtureUrl}`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
await page.locator('role=button[name="Commit count"]').click();
await expect(page).toHaveURL(`/#${projectFixtureUrl}/history/main`);
await expectBackAndForwardNavigationWorks(projectTreeURL, page);
await expectUrlPersistsReload(page);
});
test("navigate project paths", async ({ page }) => {
const projectTreeURL = `/#${projectFixtureUrl}`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
await page.locator("text=.hidden").click();
await expect(page).toHaveURL(`${projectTreeURL}/tree/main/.hidden`);
await page.locator("text=bin/").click();
await page.locator("text=true").click();
await expect(page).toHaveURL(`${projectTreeURL}/tree/main/bin/true`);
await expectBackAndForwardNavigationWorks(
`${projectTreeURL}/tree/main/.hidden`,
page,
);
await expectUrlPersistsReload(page);
});
test("navigate project paths with a selected peer", async ({ page }) => {
const projectTreeURL = `/#${projectFixtureUrl}/remotes/${aliceRemote.substring(
8,
)}`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
await page.locator("text=.hidden").click();
await expect(page).toHaveURL(`${projectTreeURL}/tree/main/.hidden`);
await page.locator("text=bin/").click();
await page.locator("text=true").click();
await expect(page).toHaveURL(`${projectTreeURL}/tree/main/bin/true`);
await expectBackAndForwardNavigationWorks(
`${projectTreeURL}/tree/main/.hidden`,
page,
);
await expectUrlPersistsReload(page);
});
});