Extract fixture specific variables

Co-authored-by: xphoniex <dj.2dixx@gmail.com>
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-12-28 12:23:28 +01:00
co-authored by xphoniex
parent 1a5430aced
commit 26f96990a4
12 changed files with 160 additions and 131 deletions
+17 -22
View File
@@ -1,8 +1,12 @@
import type { Page } from "@playwright/test";
import { test, expect } from "@tests/support/fixtures.js";
const sourceBrowsingFixture =
"/seeds/0.0.0.0/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy";
import {
expect,
projectFixtureUrl,
rid,
ridPrefix,
seedRemote,
test,
} from "@tests/support/fixtures.js";
async function expectClipboard(content: string, page: Page) {
const clipboardContent = await page.evaluate<string>(
@@ -22,7 +26,7 @@ test("copy to clipboard", async ({ page, browserName, context }) => {
}
context.grantPermissions(["clipboard-read", "clipboard-write"]);
await page.goto(sourceBrowsingFixture);
await page.goto(projectFixtureUrl);
// Reset system clipboard to a known state.
await page.evaluate<string>("navigator.clipboard.writeText('')");
@@ -33,39 +37,33 @@ test("copy to clipboard", async ({ page, browserName, context }) => {
const clipboardContent = await page.evaluate<string>(
"navigator.clipboard.readText()",
);
expect(clipboardContent).toBe(
"rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy",
);
expect(clipboardContent).toBe(`${ridPrefix}${rid}`);
}
// `rad clone` URL.
{
await page.getByText("Clone").click();
await page.locator("text=rad clone rad://0.0.0.0/hnrkdi").hover();
await page
.locator(`text=rad clone rad://0.0.0.0/${rid.substring(0, 6)}`)
.hover();
await page
.locator(".clone-url-wrapper > span")
.first()
.locator(".clipboard")
.click();
await expectClipboard(
"rad clone rad://0.0.0.0/hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy",
page,
);
await expectClipboard(`rad clone rad://0.0.0.0/${rid}`, page);
}
// `git clone` URL.
{
await page.getByText("Clone").click();
await page.locator("text=https://0.0.0.0/hnrkdi").hover();
await page.locator(`text=https://0.0.0.0/${rid.substring(0, 6)}`).hover();
await page
.locator(".clone-url-wrapper > span")
.last()
.locator(".clipboard")
.click();
await expectClipboard(
"https://0.0.0.0/hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy.git",
page,
);
await expectClipboard(`https://0.0.0.0/${rid}.git`, page);
}
await page.goto("/seeds/radicle.local");
@@ -75,10 +73,7 @@ test("copy to clipboard", async ({ page, browserName, context }) => {
await expectClipboard("0.0.0.0", page);
await page.locator(".clipboard").last().click();
await expectClipboard(
"hybuytx44z9cfsm5739wecia9j4b7expgc15qkazph59szp57m4d3o",
page,
);
await expectClipboard(seedRemote, page);
}
// Clear the system clipboard contents so developers don't wonder why there's
+11 -13
View File
@@ -1,8 +1,10 @@
import {
test,
expect,
aliceMainHead,
aliceRemote,
appConfigWithFixture,
expect,
projectFixtureUrl,
test,
} from "@tests/support/fixtures.js";
import {
expectBackAndForwardNavigationWorks,
@@ -22,9 +24,7 @@ test("navigate between landing and project page", async ({ page }) => {
await expect(page).toHaveURL("/#/");
await page.locator("text=source-browsing").click();
await expect(page).toHaveURL(
`/#${projectFixtureUrl}/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842`,
);
await expect(page).toHaveURL(`/#${projectFixtureUrl}/tree/${aliceMainHead}`);
await expectBackAndForwardNavigationWorks("/#/", page);
await expectUrlPersistsReload(page);
@@ -35,9 +35,7 @@ test("navigation between seed and project pages", async ({ page }) => {
const project = page.locator(".project");
await project.click();
await expect(page).toHaveURL(
`/#${projectFixtureUrl}/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842`,
);
await expect(page).toHaveURL(`/#${projectFixtureUrl}/tree/${aliceMainHead}`);
await expectBackAndForwardNavigationWorks("/#/seeds/radicle.local", page);
await expectUrlPersistsReload(page);
@@ -50,7 +48,7 @@ test.describe("project page navigation", () => {
test("navigation between commit history and single commit", async ({
page,
}) => {
const projectHistoryURL = `/#${projectFixtureUrl}/history/f0b8db68847b01f0964380507a9db6800e5b5342`;
const projectHistoryURL = `/#${projectFixtureUrl}/history/${aliceMainHead}`;
await page.goto(projectHistoryURL);
await page.locator("text=Add Markdown cheat sheet").click();
@@ -63,14 +61,14 @@ test.describe("project page navigation", () => {
});
test("navigate between tree and commit history", async ({ page }) => {
const projectTreeURL = `/#${projectFixtureUrl}/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842`;
const projectTreeURL = `/#${projectFixtureUrl}/tree/${aliceMainHead}`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
await page.locator('role=button[name="Commit count"]').click();
await expect(page).toHaveURL(
`/#${projectFixtureUrl}/history/fcc929424b82984b7cbff9c01d2e20d9b1249842`,
`/#${projectFixtureUrl}/history/${aliceMainHead}`,
);
await expectBackAndForwardNavigationWorks(projectTreeURL, page);
@@ -78,7 +76,7 @@ test.describe("project page navigation", () => {
});
test("navigate project paths", async ({ page }) => {
const projectTreeURL = `/#${projectFixtureUrl}/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842`;
const projectTreeURL = `/#${projectFixtureUrl}/tree/${aliceMainHead}`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
@@ -98,7 +96,7 @@ test.describe("project page navigation", () => {
});
test("navigate project paths with a selected peer", async ({ page }) => {
const projectTreeURL = `/#${projectFixtureUrl}/remotes/hybg18bc4cu8z9xtj44skxperfdpxpp1wp8zygyzti5kfiggdizfxy/tree`;
const projectTreeURL = `/#${projectFixtureUrl}/remotes/${aliceRemote}/tree`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
+11 -13
View File
@@ -1,8 +1,10 @@
import {
test,
expect,
aliceMainHead,
aliceRemote,
appConfigWithFixture,
expect,
projectFixtureUrl,
test,
} from "@tests/support/fixtures.js";
import {
expectBackAndForwardNavigationWorks,
@@ -16,9 +18,7 @@ test("navigate between landing and project page", async ({ page }) => {
await expect(page).toHaveURL("/");
await page.locator("text=source-browsing").click();
await expect(page).toHaveURL(
`${projectFixtureUrl}/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842`,
);
await expect(page).toHaveURL(`${projectFixtureUrl}/tree/${aliceMainHead}`);
await expectBackAndForwardNavigationWorks("/", page);
await expectUrlPersistsReload(page);
@@ -29,9 +29,7 @@ test("navigation between seed and project pages", async ({ page }) => {
const project = page.locator(".project");
await project.click();
await expect(page).toHaveURL(
`${projectFixtureUrl}/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842`,
);
await expect(page).toHaveURL(`${projectFixtureUrl}/tree/${aliceMainHead}`);
await expectBackAndForwardNavigationWorks("/seeds/radicle.local", page);
await expectUrlPersistsReload(page);
@@ -44,7 +42,7 @@ test.describe("project page navigation", () => {
test("navigation between commit history and single commit", async ({
page,
}) => {
const projectHistoryURL = `${projectFixtureUrl}/history/fcc929424b82984b7cbff9c01d2e20d9b1249842`;
const projectHistoryURL = `${projectFixtureUrl}/history/${aliceMainHead}`;
await page.goto(projectHistoryURL);
await page.locator("text=Add Markdown cheat sheet").click();
@@ -57,14 +55,14 @@ test.describe("project page navigation", () => {
});
test("navigate between tree and commit history", async ({ page }) => {
const projectTreeURL = `${projectFixtureUrl}/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842`;
const projectTreeURL = `${projectFixtureUrl}/tree/${aliceMainHead}`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
await page.locator('role=button[name="Commit count"]').click();
await expect(page).toHaveURL(
`${projectFixtureUrl}/history/fcc929424b82984b7cbff9c01d2e20d9b1249842`,
`${projectFixtureUrl}/history/${aliceMainHead}`,
);
await expectBackAndForwardNavigationWorks(projectTreeURL, page);
@@ -72,7 +70,7 @@ test.describe("project page navigation", () => {
});
test("navigate project paths", async ({ page }) => {
const projectTreeURL = `${projectFixtureUrl}/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842`;
const projectTreeURL = `${projectFixtureUrl}/tree/${aliceMainHead}`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
@@ -92,7 +90,7 @@ test.describe("project page navigation", () => {
});
test("navigate project paths with a selected peer", async ({ page }) => {
const projectTreeURL = `${projectFixtureUrl}/remotes/hybg18bc4cu8z9xtj44skxperfdpxpp1wp8zygyzti5kfiggdizfxy/tree`;
const projectTreeURL = `${projectFixtureUrl}/remotes/${aliceRemote}/tree`;
await page.goto(projectTreeURL);
await expect(page).toHaveURL(projectTreeURL);
+9 -2
View File
@@ -1,4 +1,9 @@
import { test, expect, appConfigWithFixture } from "@tests/support/fixtures.js";
import {
aliceMainHead,
appConfigWithFixture,
expect,
test,
} from "@tests/support/fixtures.js";
test.use({
customAppConfig: true,
@@ -20,5 +25,7 @@ test("show pinned projects", async ({ page }) => {
).toBeVisible();
// Shows latest commit.
await expect(page.locator("text=fcc9294")).toBeVisible();
await expect(
page.locator(`text=${aliceMainHead.substring(0, 7)}`),
).toBeVisible();
});
+37 -34
View File
@@ -1,5 +1,13 @@
import type { Page } from "@playwright/test";
import { test, expect, projectFixtureUrl } from "@tests/support/fixtures.js";
import {
aliceMainHead,
aliceRemote,
expect,
projectFixtureUrl,
rid,
ridPrefix,
test,
} from "@tests/support/fixtures.js";
import { expectUrlPersistsReload } from "@tests/support/router";
async function expectCounts(
@@ -20,9 +28,7 @@ test("navigate to project", async ({ page }) => {
// Header.
{
const name = page.locator("text=source-browsing");
const id = page.locator(
"text=rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy",
);
const id = page.locator(`text=${ridPrefix}${rid}`);
const description = page.locator(
"text=Git repository for source browsing tests",
);
@@ -35,7 +41,7 @@ test("navigate to project", async ({ page }) => {
// Project menu shows default selected branch and commit and contributor counts.
{
await expect(page.getByTitle("Current branch")).toContainText(
"main fcc9294",
`main ${aliceMainHead.substring(0, 7)}`,
);
await expectCounts({ commits: 8, contributors: 1 }, page);
}
@@ -85,7 +91,7 @@ test("navigate line numbers", async ({ page }) => {
await page.locator('[href="#L5"]').click();
await expect(page.locator("#L5")).toHaveClass("line highlight");
await expect(page).toHaveURL(
"/seeds/0.0.0.0/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/tree/main/markdown/cheatsheet.md#L5",
`${projectFixtureUrl}/tree/main/markdown/cheatsheet.md#L5`,
);
await expectUrlPersistsReload(page);
@@ -95,13 +101,11 @@ test("navigate line numbers", async ({ page }) => {
await expect(page.locator("#L5")).not.toHaveClass("line highlight");
await expect(page.locator("#L30")).toHaveClass("line highlight");
await expect(page).toHaveURL(
"/seeds/0.0.0.0/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/tree/main/markdown/cheatsheet.md#L30",
`${projectFixtureUrl}/tree/main/markdown/cheatsheet.md#L30`,
);
await page.getByText(".hidden").click();
await expect(page).toHaveURL(
"/seeds/0.0.0.0/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/tree/main/.hidden",
);
await expect(page).toHaveURL(`${projectFixtureUrl}/tree/main/.hidden`);
});
test("navigate deep file hierarchies", async ({ page }) => {
@@ -231,11 +235,21 @@ test("markdown files", async ({ page }) => {
{
await page.getByRole("link", { name: "YouTube Videos" }).click();
await expect(page).toHaveURL(
"/seeds/0.0.0.0/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/tree/main/markdown/cheatsheet.md#videos",
`${projectFixtureUrl}/tree/main/markdown/cheatsheet.md#videos`,
);
}
});
test("clone modal", async ({ page }) => {
await page.goto(projectFixtureUrl);
await page.getByText("Clone").click();
await expect(
page.locator(`text=rad clone rad://0.0.0.0/${rid}`),
).toBeVisible();
await expect(page.locator(`text=https://0.0.0.0/${rid}.git`)).toBeVisible();
});
test("peer and branch switching", async ({ page }) => {
await page.goto(projectFixtureUrl);
@@ -245,7 +259,12 @@ test("peer and branch switching", async ({ page }) => {
await page.locator("text=alice").click();
await expect(page.getByTitle("Change peer")).toHaveText("alice delegate");
await expect(
page.locator("text=source-browsing / hybg18…dizfxy"),
page.locator(
`text=source-browsing / ${aliceRemote.substring(
0,
6,
)}…${aliceRemote.slice(-6)}`,
),
).toBeVisible();
// Default `main` branch.
@@ -315,27 +334,11 @@ test("peer and branch switching", async ({ page }) => {
}
});
test("clone modal", async ({ page }) => {
await page.goto(projectFixtureUrl);
await page.getByText("Clone").click();
await expect(
page.locator(
"text=rad clone rad://0.0.0.0/hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy",
),
).toBeVisible();
await expect(
page.locator(
"text=https://0.0.0.0/hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy.git",
),
).toBeVisible();
});
test("only one modal can be open at a time", async ({ page }) => {
await page.goto(projectFixtureUrl);
await page.getByTitle("Change peer").click();
await page.locator("text=alice hybg18").click();
await page.locator(`text=alice ${aliceRemote.substring(0, 6)}`).click();
await page.getByText("Clone").click();
await expect(page.locator("text=Code font")).not.toBeVisible();
@@ -365,7 +368,7 @@ test("only one modal can be open at a time", async ({ page }) => {
test.describe("browser error handling", () => {
test("error appears when folder can't be loaded", async ({ page }) => {
await page.route(
"**/v1/projects/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/tree/fcc929424b82984b7cbff9c01d2e20d9b1249842/markdown/",
`**/v1/projects/${ridPrefix}${rid}/tree/${aliceMainHead}/markdown/`,
route => route.fulfill({ status: 500 }),
);
@@ -380,7 +383,7 @@ test.describe("browser error handling", () => {
});
test("error appears when file can't be loaded", async ({ page }) => {
await page.route(
"**/v1/projects/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/blob/fcc929424b82984b7cbff9c01d2e20d9b1249842/.hidden",
`**/v1/projects/${ridPrefix}${rid}/blob/${aliceMainHead}/.hidden`,
route => route.fulfill({ status: 500 }),
);
@@ -391,7 +394,7 @@ test.describe("browser error handling", () => {
});
test("error appears when README can't be loaded", async ({ page }) => {
await page.route(
"**/v1/projects/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/readme/fcc929424b82984b7cbff9c01d2e20d9b1249842",
`**/v1/projects/${ridPrefix}${rid}/readme/${aliceMainHead}`,
route => route.fulfill({ status: 500 }),
);
@@ -402,7 +405,7 @@ test.describe("browser error handling", () => {
});
test("error appears when navigating to missing file", async ({ page }) => {
await page.route(
"**/v1/projects/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/blob/fcc929424b82984b7cbff9c01d2e20d9b1249842/.hidden",
`**/v1/projects/${ridPrefix}${rid}/blob/${aliceMainHead}/.hidden`,
route => route.fulfill({ status: 500 }),
);
@@ -414,7 +417,7 @@ test.describe("browser error handling", () => {
page,
}) => {
await page.route(
"**/v1/projects/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/blob/fcc929424b82984b7cbff9c01d2e20d9b1249842/src/black-square.png",
`**/v1/projects/${ridPrefix}${rid}/blob/${aliceMainHead}/src/black-square.png`,
route => route.fulfill({ status: 404 }),
);
+9 -4
View File
@@ -1,6 +1,11 @@
import { test, expect, projectFixtureUrl } from "@tests/support/fixtures.js";
import {
test,
expect,
projectFixtureUrl,
bobRemote,
} from "@tests/support/fixtures.js";
const modifiedFileFixture = `${projectFixtureUrl}/remotes/hyyzz9w4ffg16zftjki3enajm4mkqkayb5ch1p6ns3f83np1hqkrp6/commits/2b32f6fe50090ebdb4cd7441e943330da3e6ff04`;
const modifiedFileFixture = `${projectFixtureUrl}/remotes/${bobRemote}/commits/2b32f6fe50090ebdb4cd7441e943330da3e6ff04`;
test("navigation from commit list", async ({ page }) => {
await page.goto(projectFixtureUrl);
@@ -53,7 +58,7 @@ test("modified file", async ({ page }) => {
test("created file", async ({ page }) => {
await page.goto(
`${projectFixtureUrl}/remotes/hybg18bc4cu8z9xtj44skxperfdpxpp1wp8zygyzti5kfiggdizfxy/commits/d6318f7f3d9c15b8ac6dd52267c53220d00f0982`,
`${projectFixtureUrl}/remotes/${bobRemote}/commits/d6318f7f3d9c15b8ac6dd52267c53220d00f0982`,
);
await expect(
page.locator("text=1 file(s) created with 9 addition(s) and 0 deletion(s)"),
@@ -63,7 +68,7 @@ test("created file", async ({ page }) => {
test("deleted file", async ({ page }) => {
await page.goto(
`${projectFixtureUrl}/remotes/hybg18bc4cu8z9xtj44skxperfdpxpp1wp8zygyzti5kfiggdizfxy/commits/cd13c2d9a8a930d64a82b6134b44d1b872e33662`,
`${projectFixtureUrl}/remotes/${bobRemote}/commits/cd13c2d9a8a930d64a82b6134b44d1b872e33662`,
);
await expect(
page.locator("text=1 file(s) deleted with 0 addition(s) and 1 deletion(s)"),
+7 -6
View File
@@ -1,4 +1,9 @@
import { test, expect, projectFixtureUrl } from "@tests/support/fixtures.js";
import {
test,
expect,
projectFixtureUrl,
bobRemote,
} from "@tests/support/fixtures.js";
test("peer and branch switching", async ({ page }) => {
await page.goto(projectFixtureUrl);
@@ -92,11 +97,7 @@ test("verified badge", async ({ page }) => {
"text=This commit was signed with the committer's radicle key.",
),
).toBeVisible();
await expect(
page.locator(
"text=bob committed hyyzz9w4ffg16zftjki3enajm4mkqkayb5ch1p6ns3f83np1hqkrp6",
),
).toBeVisible();
await expect(page.locator(`text=bob committed ${bobRemote}`)).toBeVisible();
});
test("relative timestamps", async ({ page }) => {
+14 -12
View File
@@ -1,31 +1,33 @@
import { test, expect } from "@tests/support/fixtures.js";
import {
test,
expect,
rid,
ridPrefix,
projectFixtureUrl,
} from "@tests/support/fixtures.js";
test("navigate to existing project", async ({ page }) => {
await page.goto("/");
const searchInput = page.getByPlaceholder("Search a name or address…");
await searchInput.click();
await searchInput.fill("rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy");
await searchInput.fill(`${ridPrefix}${rid}`);
await searchInput.press("Enter");
await expect(page).toHaveURL(
"/seeds/0.0.0.0/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy/tree",
);
await expect(searchInput).not.toHaveValue(
"rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy",
);
await expect(page).toHaveURL(`${projectFixtureUrl}/tree`);
await expect(searchInput).not.toHaveValue(`${ridPrefix}${rid}`);
});
test("navigate to a project that does not exist", async ({ page }) => {
await page.goto("/");
const searchInput = page.getByPlaceholder("Search a name or address…");
await searchInput.click();
await searchInput.fill("rad:git:hnrkn1ah5im83fwt4u3jfs5ndwpt9hrnm9wby");
const nonExistantId = `${ridPrefix}:zt${rid.substring(2)}`;
await searchInput.fill(nonExistantId);
await searchInput.press("Enter");
await page.waitForSelector(".search-bar.shaking");
await expect(page).toHaveURL("/");
await expect(searchInput).toHaveValue(
"rad:git:hnrkn1ah5im83fwt4u3jfs5ndwpt9hrnm9wby",
);
await expect(searchInput).toHaveValue(nonExistantId);
});
+18 -13
View File
@@ -1,4 +1,13 @@
import { test, expect } from "@tests/support/fixtures.js";
import {
aliceMainHead,
expect,
rid,
ridPrefix,
seedPort,
seedRemote,
seedVersion,
test,
} from "@tests/support/fixtures.js";
test("seed metadata", async ({ page }) => {
await page.goto("/seeds/radicle.local");
@@ -13,9 +22,11 @@ test("seed metadata", async ({ page }) => {
"alt",
"🚀",
);
await expect(page.locator("text=hybuyt…7m4d3o")).toBeVisible();
await expect(page.locator("text=8777")).toBeVisible();
await expect(page.locator("text=0.2.0")).toBeVisible();
await expect(
page.locator(`text=${seedRemote.substring(0, 6)}…${seedRemote.slice(-6)}`),
).toBeVisible();
await expect(page.locator(`text=${seedPort}`)).toBeVisible();
await expect(page.locator(`text=${seedVersion}`)).toBeVisible();
});
test("seed projects", async ({ page }) => {
@@ -28,19 +39,13 @@ test("seed projects", async ({ page }) => {
await expect(
project.locator("text=Git repository for source browsing tests"),
).toBeVisible();
await expect(
project.locator("text=fcc929424b82984b7cbff9c01d2e20d9b1249842"),
).toBeVisible();
await expect(project.locator(`text=${aliceMainHead}`)).toBeVisible();
}
// Show project ID on hover.
{
await expect(
project.locator("text=rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy"),
).not.toBeVisible();
await expect(project.locator(`text=${ridPrefix}${rid}`)).not.toBeVisible();
await project.hover();
await expect(
project.locator("text=rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy"),
).toBeVisible();
await expect(project.locator(`text=${ridPrefix}${rid}`)).toBeVisible();
}
});
+12 -1
View File
@@ -181,4 +181,15 @@ export function appConfigWithFixture() {
};
}
export const projectFixtureUrl = `/seeds/0.0.0.0/rad:git:hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy`;
export const aliceMainHead = "fcc929424b82984b7cbff9c01d2e20d9b1249842";
export const aliceRemote =
"hybg18bc4cu8z9xtj44skxperfdpxpp1wp8zygyzti5kfiggdizfxy";
export const bobRemote =
"hyyzz9w4ffg16zftjki3enajm4mkqkayb5ch1p6ns3f83np1hqkrp6";
export const rid = "hnrkdi8be7n4hhqoz9rpzrgd68u9dr3zsxgmy";
export const ridPrefix = "rad:git:";
export const projectFixtureUrl = `/seeds/0.0.0.0/${ridPrefix}${rid}`;
export const seedPort = 8777;
export const seedVersion = "0.2.0";
export const seedRemote =
"hybuytx44z9cfsm5739wecia9j4b7expgc15qkazph59szp57m4d3o";
+5 -5
View File
@@ -1,5 +1,7 @@
import type { FullConfig } from "@playwright/test";
import { seedPort, seedRemote } from "@tests/support/fixtures.js";
export default async function globalSetup(_config: FullConfig): Promise<void> {
assertHttpApiRunning();
}
@@ -7,8 +9,7 @@ export default async function globalSetup(_config: FullConfig): Promise<void> {
// Assert that the test http-api is running. If it is not running, throw an
// error that explains how to run it.
async function assertHttpApiRunning(): Promise<void> {
const palmTestFixtureSeedId =
"hybuytx44z9cfsm5739wecia9j4b7expgc15qkazph59szp57m4d3o";
const palmTestFixtureSeedId = seedRemote;
const notRunningMessage =
"The http-api server with test fixtures needs to be running.\n" +
@@ -17,7 +18,7 @@ async function assertHttpApiRunning(): Promise<void> {
let peerId: string | undefined = undefined;
try {
const response = await fetch("http://0.0.0.0:8777");
const response = await fetch(`http://0.0.0.0:${seedPort}`);
const data = await response.json();
peerId = data.peer.id;
} catch (err) {
@@ -26,8 +27,7 @@ async function assertHttpApiRunning(): Promise<void> {
}
if (peerId !== palmTestFixtureSeedId) {
const wrongSeedMessage =
"The server on port 8777 doesn't have the right fixtures.\n";
const wrongSeedMessage = `The server on port ${seedPort} doesn't have the right fixtures.\n`;
throw new Error(wrongSeedMessage + notRunningMessage);
}
}
+10 -6
View File
@@ -1,4 +1,9 @@
import { test, expect, projectFixtureUrl } from "@tests/support/fixtures.js";
import {
test,
expect,
projectFixtureUrl,
aliceRemote,
} from "@tests/support/fixtures.js";
test("source tree page", async ({ page }) => {
await page.goto(projectFixtureUrl, { waitUntil: "networkidle" });
@@ -16,10 +21,9 @@ test("commits page", async ({ page }) => {
};
});
await page.goto(
`${projectFixtureUrl}/remotes/hybg18bc4cu8z9xtj44skxperfdpxpp1wp8zygyzti5kfiggdizfxy/history`,
{ waitUntil: "networkidle" },
);
await page.goto(`${projectFixtureUrl}/remotes/${aliceRemote}/history`, {
waitUntil: "networkidle",
});
await expect(page).toHaveScreenshot({ fullPage: true });
});
@@ -36,7 +40,7 @@ test("commit page", async ({ page }) => {
});
await page.goto(
`${projectFixtureUrl}/remotes/hybg18bc4cu8z9xtj44skxperfdpxpp1wp8zygyzti5kfiggdizfxy/commits/d6318f7f3d9c15b8ac6dd52267c53220d00f0982`,
`${projectFixtureUrl}/remotes/${aliceRemote}/commits/d6318f7f3d9c15b8ac6dd52267c53220d00f0982`,
);
await expect(page).toHaveScreenshot({ fullPage: true });
});