mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-28 07:50:47 +08:00
libgit2 optimizes around not loading the content, when there's no content callbacks configured. So we aren't able to get a clear answer from radicle-surf if a file in a diff is a binary or not. A simple way without doing additional API requests is to check if the file type is a executable and if there are no hunks (since we don't get any deltas in binaries), this is a strong indicator for a binary. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
136 lines
4.1 KiB
TypeScript
136 lines
4.1 KiB
TypeScript
import {
|
|
test,
|
|
expect,
|
|
sourceBrowsingUrl,
|
|
bobRemote,
|
|
bobHead,
|
|
aliceRemote,
|
|
} from "@tests/support/fixtures.js";
|
|
|
|
const commitUrl = `${sourceBrowsingUrl}/commits/${bobHead}`;
|
|
|
|
test("navigation from commit list", async ({ page }) => {
|
|
await page.goto(sourceBrowsingUrl);
|
|
await page.getByTitle("Change peer").click();
|
|
await page.getByText(bobRemote).click();
|
|
await page.getByRole("link", { name: "7 commits" }).click();
|
|
|
|
await page.getByText("Update readme").click();
|
|
await expect(page).toHaveURL(commitUrl);
|
|
});
|
|
|
|
test("relative timestamps", async ({ page }) => {
|
|
await page.addInitScript(() => {
|
|
window.initializeTestStubs = () => {
|
|
window.e2eTestStubs.FakeTimers.install({
|
|
now: new Date("December 21 2022 12:00:00").valueOf(),
|
|
shouldClearNativeTimers: true,
|
|
shouldAdvanceTime: false,
|
|
});
|
|
};
|
|
});
|
|
await page.goto(commitUrl);
|
|
await expect(
|
|
page.locator(`.commit .header >> text=${"Bob Belcher committed now"}`),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("modified file", async ({ page }) => {
|
|
await page.goto(commitUrl);
|
|
|
|
// Commit header.
|
|
{
|
|
const header = page.locator(".commit .header");
|
|
await expect(header.getByText("Update readme")).toBeVisible();
|
|
await expect(header.getByText(bobHead)).toBeVisible();
|
|
}
|
|
|
|
// Diff header.
|
|
await expect(
|
|
page.getByText("1 file changed with 1 insertion and 4 deletions"),
|
|
).toBeVisible();
|
|
|
|
// Diff.
|
|
await expect(page.getByText("- # Git test repository")).toBeVisible();
|
|
await expect(page.getByText("+ Updated readme")).toBeVisible();
|
|
});
|
|
|
|
test("created file", async ({ page }) => {
|
|
await page.goto(
|
|
`${sourceBrowsingUrl}/remotes/${aliceRemote.substring(
|
|
8,
|
|
)}/commits/d87e27e38e244fb3346cb9e4df064c080d97647a`,
|
|
);
|
|
await expect(
|
|
page.getByText("1 file added with 1 insertion and 0 deletions"),
|
|
).toBeVisible();
|
|
await expect(page.getByText(".hidden added")).toBeVisible();
|
|
});
|
|
|
|
test("deleted file", async ({ page }) => {
|
|
await page.goto(
|
|
`${sourceBrowsingUrl}/remotes/${aliceRemote.substring(
|
|
8,
|
|
)}/commits/0e2db54dfd47d87202809917e2342655d9e76296`,
|
|
);
|
|
await expect(
|
|
page.getByText("1 file deleted with 0 insertions and 1 deletion"),
|
|
).toBeVisible();
|
|
await expect(page.getByText(".hidden deleted")).toBeVisible();
|
|
});
|
|
|
|
test("moved file", async ({ page }) => {
|
|
await page.goto(
|
|
`${sourceBrowsingUrl}/remotes/${aliceRemote}/commits/f48a1056a5bd02277978f6e8a00517a967546340`,
|
|
);
|
|
await expect(
|
|
page.locator("header").filter({ hasText: "moves/111.txt → moves/222.txt" }),
|
|
).toBeVisible();
|
|
|
|
await expect(page.getByText("moved", { exact: true })).toBeVisible();
|
|
await expect(page.getByText("333")).toBeVisible();
|
|
});
|
|
|
|
test("copied file", async ({ page }) => {
|
|
await page.goto(
|
|
`${sourceBrowsingUrl}/remotes/${aliceRemote}/commits/f48a1056a5bd02277978f6e8a00517a967546340`,
|
|
);
|
|
await expect(
|
|
page
|
|
.locator("header")
|
|
.filter({ hasText: "copies/aaa.txt → copies/aaa_copy.txt" }),
|
|
).toBeVisible();
|
|
await expect(page.getByText("copied", { exact: true })).toBeVisible();
|
|
});
|
|
|
|
test("binary file detection in diffs", async ({ page }) => {
|
|
await page.goto(
|
|
`${sourceBrowsingUrl}/commits/335dd6dc89b535a4a31e9422c803199bb6b0a09a`,
|
|
);
|
|
await expect(page.getByText("Binary file")).toBeVisible();
|
|
});
|
|
|
|
test("navigation to source tree at specific revision", async ({ page }) => {
|
|
await page.goto(
|
|
`${sourceBrowsingUrl}/commits/0801aceeab500033f8d608778218657bd626ef73`,
|
|
);
|
|
|
|
// Go to source tree at this revision.
|
|
await page.getByTitle("View file").click();
|
|
await expect(
|
|
page.getByText("Add a deeply nested directory tree"),
|
|
).toBeVisible();
|
|
await expect(page).toHaveURL(
|
|
`${sourceBrowsingUrl}/tree/0801aceeab500033f8d608778218657bd626ef73/deep/directory/hierarchy/is/entirely/possible/in/git/repositories/.gitkeep`,
|
|
);
|
|
await expect(page.getByTitle("Current branch")).toContainText(
|
|
"0801aceeab500033f8d608778218657bd626ef73",
|
|
);
|
|
await expect(page.locator(".source-tree >> text=.gitkeep")).toBeVisible();
|
|
await expect(
|
|
page.locator(
|
|
"text=deep/directory/hierarchy/is/entirely/possible/in/git/repositories/",
|
|
),
|
|
).toBeVisible();
|
|
});
|