Improve FileDiff and add tests

Signed-off-by: Alice Liddell <alice@radicle.xyz>
This commit is contained in:
Alice Liddell
2023-09-19 07:49:36 +02:00
committed by Rūdolfs Ošiņš
parent ee9cb2b0d7
commit 1b01216bf8
4 changed files with 23 additions and 4 deletions
+3 -1
View File
@@ -101,7 +101,9 @@
{baseUrl}
{revision}
filePath={file.newPath}
fileDiff={file.diff} />
oldFilePath={file.oldPath}
fileDiff={file.diff}
headerBadgeCaption="moved" />
{:else}
<FileLocationChange
{projectId}
+16 -2
View File
@@ -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">
+4 -1
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.
Binary file not shown.