Unverified Commit df19878c authored by Lemon-miaow's avatar Lemon-miaow
Browse files

refactor(panel): standardize interface copy in documentation style

parent fa1b8a90
Loading
Loading
Loading
Loading
+4 −4
Changes for panel/src/components/CreateServerDialog.test.tsx: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ describe("CreateServerDialog names", () => {
    ["survival-", "Use 3–32 lowercase letters, digits or hyphens, with no hyphen at either end."],
    ["my_world", "Use 3–32 lowercase letters, digits or hyphens, with no hyphen at either end."],
    ["a".repeat(33), "Use 3–32 lowercase letters, digits or hyphens, with no hyphen at either end."],
    ["lobby", "“lobby” is kept for the platform. Pick another."],
    ["lobby", "“lobby” is reserved by the platform. Use a different name."],
  ])("refuses the name %j before sending, and says why", async (name, why) => {
    const user = await openDialog();
    await fillValid(user);
@@ -176,7 +176,7 @@ describe("CreateServerDialog names", () => {
    await user.type(subdomainBox(), "api");

    expect(create().disabled).toBe(true);
    expect(screen.getByText("“api” is kept for the platform. Pick another.")).toBeTruthy();
    expect(screen.getByText("“api” is reserved by the platform. Use a different name.")).toBeTruthy();
    expect(screen.queryByText(/Will be reachable at/)).toBeNull();
  });

@@ -249,10 +249,10 @@ describe("CreateServerDialog on reopening", () => {

    const alert = await screen.findByRole("alert");
    expect(alert.textContent).toContain(humanizeError(outage));
    expect(screen.getByText("Image list not loaded")).toBeTruthy();
    expect(screen.getByText("Image list unavailable")).toBeTruthy();
    expect(screen.queryByText("No whitelisted images")).toBeNull();

    await user.click(within(alert).getByRole("button", { name: "Try again" }));
    await user.click(within(alert).getByRole("button", { name: "Retry" }));
    expect(calls.listImages).toHaveBeenCalledTimes(2);
    await pick(user, "Image", PAPER);
    expect(screen.queryByRole("alert")).toBeNull();
+2 −2
Changes for panel/src/components/DistributedNodes.test.tsx: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ describe("durable migration", () => {
    await screen.findByText("source node is offline");
    expect(calls.migration).toHaveBeenCalledWith("survival");
    expect(screen.getByText("persisted-op")).toBeTruthy();
    await user.click(screen.getByRole("button", { name: "Try again" }));
    await user.click(screen.getByRole("button", { name: "Retry" }));
    await waitFor(() => expect(calls.retryMigration).toHaveBeenCalledWith("survival", "persisted-op"));
    expect(changed).toHaveBeenCalled();
    expect(calls.migrateServer).not.toHaveBeenCalled();
@@ -36,7 +36,7 @@ describe("durable migration", () => {
    const user = userEvent.setup();
    render(<MigrationDialog name="survival" nodeName="b" stopped={false} onChanged={() => {}} />);
    await user.click(screen.getByRole("button", { name: "Migrate world" }));
    const retry = await screen.findByRole("button", { name: "Try again" });
    const retry = await screen.findByRole("button", { name: "Retry" });
    expect((retry as HTMLButtonElement).disabled).toBe(true);
    await user.click(retry);
    expect(calls.retryMigration).not.toHaveBeenCalled();
+1 −1
Changes for panel/src/components/EditServerDialog.test.tsx: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ describe("EditServerDialog request body", () => {
    for (const bad of ["two", "0", "1.5m", "-1"]) {
      await user.clear(cpuInput());
      await user.type(cpuInput(), bad);
      expect(screen.getByText("Enter cores (1, 1.5) or millicores (500m), above zero."), bad).toBeTruthy();
      expect(screen.getByText("The CPU limit must be greater than zero, expressed as cores (for example, 1 or 1.5) or millicores (for example, 500m)."), bad).toBeTruthy();
      expect(cpuInput().getAttribute("aria-invalid"), bad).toBe("true");
      expect(save().disabled, bad).toBe(true);
    }
+2 −2
Changes for panel/src/components/States.test.tsx: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ describe("NotRunning", () => {
    ] as const) {
      const { unmount } = render(notRunning(phase, desired));
      expect(screen.getByText("Server is starting"), `${phase}/${desired}`).toBeTruthy();
      expect(screen.getByText(/switches over by itself/), `${phase}/${desired}`).toBeTruthy();
      expect(screen.getByText(/updates the startup status automatically/), `${phase}/${desired}`).toBeTruthy();
      expect(screen.queryByRole("button"), `${phase}/${desired}`).toBeNull();
      unmount();
    }
@@ -122,7 +122,7 @@ describe("RefreshError", () => {
    const err = { status: 429, code: "quota_exceeded", message: "raw" };
    render(<RefreshError error={err} />);
    const alert = screen.getByRole("alert");
    expect(alert.textContent).toContain("Couldn't refresh; what you see is the last status read.");
    expect(alert.textContent).toContain("Refresh failed. The last successfully retrieved status is displayed.");
    expect(alert.textContent).toContain(humanizeError(err));
  });
});
+14 −14
Changes for panel/src/components/files/opText.test.ts: 14 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -7,50 +7,50 @@ const e = (code: string, over: Record<string, unknown> = {}) => ({ code, message
describe("opErrorText", () => {
  it("tells an upload that found its file there from an extraction that would replace files", () => {
    expect(opErrorText("upload", e("file_exists"))).toBe(
      "A file with this name is already here, so nothing was replaced. Upload it again and choose Replace.",
      "A file with this name already exists. The upload did not replace it. Select Replace when uploading again.",
    );
    expect(opErrorText("unzip", e("file_exists", { conflicts: ["a", "b"], conflict_count: 250 }))).toBe(
      "It would replace 250 files already here, so nothing was extracted yet.",
      "Extraction would overwrite 250 existing files. The operation has not been performed.",
    );
    // Without the count, the list is counted.
    expect(opErrorText("unzip", e("file_exists", { conflicts: ["a"] }))).toBe(
      "It would replace 1 file already here, so nothing was extracted yet.",
      "Extraction would overwrite 1 existing file. The operation has not been performed.",
    );
  });

  it("names both sizes of a volume too small, and falls back when they are missing", () => {
    expect(opErrorText("unzip", e("volume_full", { need: 3 * 1024 * 1024, avail: 1024 }))).toBe(
      "Not enough room on the world volume: 3.0 MiB needed, 1.0 KiB free. Nothing was changed.",
      "Insufficient world volume space: 3.0 MiB required, 1.0 KiB available. This operation did not modify files.",
    );
    // A full volume: the Job leaves the zero out.
    expect(opErrorText("upload", e("volume_full", { need: 2048 }))).toBe(
      "Not enough room on the world volume: 2.0 KiB needed, 0 B free. Nothing was changed.",
      "Insufficient world volume space: 2.0 KiB required, 0 B available. This operation did not modify files.",
    );
    expect(opErrorText("upload", e("volume_full"))).toBe(humanizeError({ status: 0, code: "volume_full", message: "raw words" }));
  });

  it("names the archive entry at fault", () => {
    expect(opErrorText("unzip", e("archive_invalid"))).toBe("The archive is damaged, or not a zip file. Nothing was changed.");
    expect(opErrorText("unzip", e("archive_invalid"))).toBe("The archive is damaged or is not in ZIP format. This operation did not modify files.");
    expect(opErrorText("unzip", e("archive_invalid", { entry: "world/level.dat" }))).toBe(
      "world/level.dat in the archive is damaged (its size or checksum does not match). Nothing was changed.",
      "The size or checksum of archive entry world/level.dat does not match. This operation did not modify files.",
    );
    expect(opErrorText("unzip", e("archive_unsafe", { entry: "../../etc/passwd" }))).toBe(
      "../../etc/passwd in the archive would land outside this folder, or is a device file. Nothing in the archive was extracted.",
      "Archive entry ../../etc/passwd contains an out-of-directory path or a device file. The entire archive was rejected without extraction.",
    );
    expect(opErrorText("unzip", e("archive_symlink", { entry: "world/link" }))).toBe(
      "world/link in the archive is a symbolic link. Nothing in the archive was extracted.",
      "Archive entry world/link is a symbolic link. The entire archive was rejected without extraction.",
    );
    expect(opErrorText("unzip", e("type_conflict", { entry: "plugins" }))).toBe(
      "plugins is a file on one side and a folder on the other, which replacing cannot resolve. Rename or delete plugins here, then extract again.",
      "Entry plugins conflicts with an existing entry of the same name because one is a file and the other is a folder. Rename or delete the existing plugins before extraction.",
    );
  });

  it("gives a Job that ran out of time its own words", () => {
    expect(opErrorText("unzip", e("job_failed", { message: "job failed: DeadlineExceeded" }))).toBe(
      "The background task did not finish within 2 hours and was stopped. Refresh the list to check, then try again.",
      "The background task exceeded its two-hour execution limit and was terminated. Refresh the file list to verify the result before retrying.",
    );
    expect(opErrorText("upload", e("job_failed", { message: "job failed: BackoffLimitExceeded" }))).toBe(
      "The background task ended without saying why. Refresh the list to check, then try again.",
      "The background task ended without a failure reason. Refresh the file list to verify the result before retrying.",
    );
  });

@@ -58,10 +58,10 @@ describe("opErrorText", () => {
    // The message felis-api words a memory kill with.
    const oom = "the file operation ran out of memory (OOMKilled); an archive of this many files has to be split into smaller ones";
    expect(opErrorText("unzip", e("job_failed", { message: oom }))).toBe(
      "The archive holds more files than the extraction task has memory to list, so the system stopped it. The files on the server were not changed. Split it into several smaller zips and extract each one.",
      "The extraction task terminated because its file list exceeded available memory. Server files were not modified. Split the content into smaller ZIP archives and upload and extract them separately.",
    );
    expect(opErrorText("upload", e("job_failed", { message: oom }))).toBe(
      "The background task ran out of memory and the system stopped it. The files on the server were not changed. Try again.",
      "The background task terminated due to insufficient memory. Server files were not modified. Check task resources before retrying.",
    );
  });

Loading