Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Improve FileDiff and add tests
Alice Liddell committed 2 years ago
commit 1b01216bf812b9a892f4b1bf4dfc2dda5001b1f9
parent ee9cb2b0d7cc6b3cdac481d852d2aa6f8a2d7d61
4 files changed +23 -4
modified src/views/projects/Changeset.svelte
@@ -101,7 +101,9 @@
        {baseUrl}
        {revision}
        filePath={file.newPath}
-
        fileDiff={file.diff} />
+
        oldFilePath={file.oldPath}
+
        fileDiff={file.diff}
+
        headerBadgeCaption="moved" />
    {:else}
      <FileLocationChange
        {projectId}
modified src/views/projects/Changeset/FileDiff.svelte
@@ -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">
modified tests/e2e/project/commit.spec.ts
@@ -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.
modified tests/fixtures/repos/source-browsing.tar.bz2