Fix not found and loading error screens

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2023-08-16 09:35:44 +02:00
parent 0e33915e9a
commit 5736083d50
15 changed files with 240 additions and 155 deletions
+20 -2
View File
@@ -245,6 +245,24 @@ export function appConfigWithFixture() {
},
projects: {
pinned: [
{
name: "cobs",
id: "rad:z3fpY7nttPPa6MBnAv2DccHzQJnqe",
baseUrl: {
hostname: "127.0.0.1",
port: 8081,
scheme: "http",
},
},
{
name: "markdown",
id: "rad:z2tchH2Ti4LxRKdssPQYs6VHE5rsg",
baseUrl: {
hostname: "127.0.0.1",
port: 8081,
scheme: "http",
},
},
{
name: "source-browsing",
id: "rad:z4BwwjPCFNVP27FwVbDFgwVwkjcir",
@@ -349,11 +367,11 @@ export async function createSourceBrowsingFixture(
await bob.git(["push", "rad"], { cwd: bobProjectPath });
await bob.waitForEvent(
{ type: "refs-synced", remote: palm.nodeId, rid },
{ type: "refsSynced", remote: palm.nodeId, rid },
2000,
);
await bob.waitForEvent(
{ type: "refs-synced", remote: alice.nodeId, rid },
{ type: "refsSynced", remote: alice.nodeId, rid },
2000,
);
await alice.stopNode();
+13 -8
View File
@@ -24,29 +24,34 @@ export type RefsUpdate =
export type NodeEvent =
| {
type: "refs-fetched";
type: "refsFetched";
remote: string;
rid: string;
updated: RefsUpdate[];
}
| {
type: "refs-synced";
type: "refsSynced";
remote: string;
rid: string;
}
| {
type: "seed-discovered";
type: "seedDiscovered";
rid: string;
nid: string;
}
| {
type: "seed-dropped";
type: "seedDropped";
nid: string;
rid: string;
}
| {
type: "peer-connected";
type: "peerConnected";
nid: string;
}
| {
type: "peerDisconnected";
nid: string;
reason: string;
};
export interface RoutingEntry {
@@ -340,7 +345,7 @@ export class RadiclePeer {
});
await this.waitForEvent(
{ type: "seed-discovered", rid, nid: this.nodeId },
{ type: "seedDiscovered", rid, nid: this.nodeId },
6000,
);
}
@@ -356,11 +361,11 @@ export class RadiclePeer {
);
await this.waitForEvent(
{ type: "peer-connected", nid: remote.nodeId },
{ type: "peerConnected", nid: remote.nodeId },
1000,
);
await remote.waitForEvent(
{ type: "peer-connected", nid: this.nodeId },
{ type: "peerConnected", nid: this.nodeId },
1000,
);
}
+22 -1
View File
@@ -4,7 +4,7 @@ test.use({
customAppConfig: true,
});
test("landing page", async ({ page }) => {
test("pinned projects", async ({ page }) => {
await page.addInitScript(() => {
window.initializeTestStubs = () => {
window.e2eTestStubs.FakeTimers.install({
@@ -19,3 +19,24 @@ test("landing page", async ({ page }) => {
await page.goto("/", { waitUntil: "networkidle" });
await expect(page).toHaveScreenshot();
});
test("load error", async ({ page }) => {
await page.addInitScript(() => {
window.initializeTestStubs = () => {
window.e2eTestStubs.FakeTimers.install({
now: new Date("November 24 2022 12:00:00").valueOf(),
shouldClearNativeTimers: true,
shouldAdvanceTime: false,
});
};
});
await page.route(
"**/api/v1/projects/rad:z4BwwjPCFNVP27FwVbDFgwVwkjcir",
route => route.fulfill({ status: 500 }),
);
await page.addInitScript(appConfigWithFixture);
await page.goto("/", { waitUntil: "networkidle" });
await expect(page).toHaveScreenshot();
});
@@ -14,3 +14,10 @@ test("node page", async ({ page }) => {
await page.goto("/nodes/radicle.local", { waitUntil: "networkidle" });
await expect(page).toHaveScreenshot();
});
test("node not found", async ({ page }) => {
await page.goto("/nodes/this.node.does.not.exist.xyz", {
waitUntil: "networkidle",
});
await expect(page).toHaveScreenshot();
});
+8
View File
@@ -0,0 +1,8 @@
import { expect, test } from "@tests/support/fixtures.js";
test("page not found", async ({ page }) => {
await page.goto("/this/page/does/not/exist", {
waitUntil: "networkidle",
});
await expect(page).toHaveScreenshot();
});
+48 -2
View File
@@ -6,12 +6,12 @@ import {
aliceRemote,
} from "@tests/support/fixtures.js";
test("source tree page", async ({ page }) => {
test("source page", async ({ page }) => {
await page.goto(sourceBrowsingUrl, { waitUntil: "networkidle" });
await expect(page).toHaveScreenshot();
});
test("commits page", async ({ page }) => {
test("history page", async ({ page }) => {
await page.addInitScript(() => {
window.initializeTestStubs = () => {
window.e2eTestStubs.FakeTimers.install({
@@ -68,3 +68,49 @@ test("diff selection", async ({ page }) => {
);
await expect(page).toHaveScreenshot({ fullPage: true });
});
test("project load error", async ({ page }) => {
await page.goto(
`${sourceBrowsingUrl}/remotes/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz`,
{ waitUntil: "networkidle" },
);
await expect(page).toHaveScreenshot();
});
test("project not found", async ({ page }) => {
await page.goto(`/nodes/127.0.0.1/rad:z4Vzzzzzzzzzzzzzzzzzzzzzzzzzz`, {
waitUntil: "networkidle",
});
await expect(page).toHaveScreenshot();
});
test("file not found", async ({ page }) => {
await page.goto(`${sourceBrowsingUrl}/tree/this.file.does.not.exist`, {
waitUntil: "networkidle",
});
await expect(page).toHaveScreenshot();
});
test("commit not found", async ({ page }) => {
await page.goto(
`${sourceBrowsingUrl}/commits/0000000000000000000000000000000000000000`,
{ waitUntil: "networkidle" },
);
await expect(page).toHaveScreenshot();
});
test("issue not found", async ({ page }) => {
await page.goto(
`${sourceBrowsingUrl}/issues/0000000000000000000000000000000000000000`,
{ waitUntil: "networkidle" },
);
await expect(page).toHaveScreenshot();
});
test("patch not found", async ({ page }) => {
await page.goto(
`${sourceBrowsingUrl}/patches/0000000000000000000000000000000000000000`,
{ waitUntil: "networkidle" },
);
await expect(page).toHaveScreenshot();
});