mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
Improve FileDiff and add tests
Signed-off-by: Alice Liddell <alice@radicle.xyz>
This commit is contained in:
@@ -101,7 +101,9 @@
|
||||
{baseUrl}
|
||||
{revision}
|
||||
filePath={file.newPath}
|
||||
fileDiff={file.diff} />
|
||||
oldFilePath={file.oldPath}
|
||||
fileDiff={file.diff}
|
||||
headerBadgeCaption="moved" />
|
||||
{:else}
|
||||
<FileLocationChange
|
||||
{projectId}
|
||||
|
||||
@@ -7,9 +7,15 @@
|
||||
import Link from "@app/components/Link.svelte";
|
||||
|
||||
export let filePath: string;
|
||||
export let oldFilePath: string | undefined = undefined;
|
||||
export let fileDiff: DiffContent;
|
||||
export let revision: string;
|
||||
export let headerBadgeCaption: "added" | "deleted" | undefined = undefined;
|
||||
export let headerBadgeCaption:
|
||||
| "added"
|
||||
| "deleted"
|
||||
| "moved"
|
||||
| "copied"
|
||||
| undefined = undefined;
|
||||
export let baseUrl: BaseUrl;
|
||||
export let projectId: string;
|
||||
|
||||
@@ -324,11 +330,19 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div class="actions">
|
||||
<p class="txt-regular">{filePath}</p>
|
||||
{#if headerBadgeCaption === "moved" || headerBadgeCaption === "copied"}
|
||||
<p class="txt-regular">{oldFilePath} → {filePath}</p>
|
||||
{:else}
|
||||
<p class="txt-regular">{filePath}</p>
|
||||
{/if}
|
||||
{#if headerBadgeCaption === "added"}
|
||||
<Badge variant="positive">added</Badge>
|
||||
{:else if headerBadgeCaption === "deleted"}
|
||||
<Badge variant="negative">deleted</Badge>
|
||||
{:else if headerBadgeCaption === "moved"}
|
||||
<Badge variant="foreground">moved</Badge>
|
||||
{:else if headerBadgeCaption === "copied"}
|
||||
<Badge variant="foreground">copied</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="browse" title="View file">
|
||||
|
||||
@@ -81,11 +81,14 @@ test("deleted file", async ({ page }) => {
|
||||
|
||||
test("moved file", async ({ page }) => {
|
||||
await page.goto(
|
||||
`${sourceBrowsingUrl}/remotes/${aliceRemote}/commits/835d9a52066c46d86cdee88f2863e9a804c7fa50/commits/`,
|
||||
`${sourceBrowsingUrl}/remotes/${aliceRemote}/commits/f48a1056a5bd02277978f6e8a00517a967546340`,
|
||||
);
|
||||
await expect(
|
||||
page.locator("header").filter({ hasText: "moves/111.txt → moves/222.txt" }),
|
||||
).toBeVisible();
|
||||
|
||||
// TODO: Add assertions for diff.
|
||||
await expect(page.getByText("333")).toBeVisible();
|
||||
});
|
||||
|
||||
// TODO: Add copy operation detection spec.
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user