swarm-ui: keep the issue report's table, errors and repo filter consistent
A failed report dropped its error under the previous repo's rows, the repo list and the report shared one error slot, a remembered repo that the list lacked left the select on all repos, and the report URL did not encode the repo path. Each request now has its own error, a failed report clears the rows, the remembered repo keeps an option, and the path parts are encoded.
This commit is contained in:
parent
e727774dc8
commit
f6acc1e976
3 changed files with 121 additions and 24 deletions
55
frontend/packages/swarm-ui/test/issue-report-repo.test.mjs
Normal file
55
frontend/packages/swarm-ui/test/issue-report-repo.test.mjs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import {
|
||||
ALL_REPOS,
|
||||
reportUrl,
|
||||
repoOptions,
|
||||
} from "../src/pages/issue-report-repo.ts";
|
||||
|
||||
test("reportUrl: no repo means the combined report", () => {
|
||||
assert.equal(reportUrl(ALL_REPOS), "/api/issue-report");
|
||||
});
|
||||
|
||||
test("reportUrl: a filter without a slash is not a repo", () => {
|
||||
assert.equal(reportUrl("nope"), "/api/issue-report");
|
||||
});
|
||||
|
||||
test("reportUrl: org and name become two path segments", () => {
|
||||
assert.equal(
|
||||
reportUrl("hyperhive/hyperhive"),
|
||||
"/api/repos/hyperhive/hyperhive/issue-report",
|
||||
);
|
||||
});
|
||||
|
||||
test("reportUrl: reserved characters in a name are encoded", () => {
|
||||
assert.equal(
|
||||
reportUrl("org/a?b#c%d"),
|
||||
"/api/repos/org/a%3Fb%23c%25d/issue-report",
|
||||
);
|
||||
});
|
||||
|
||||
test("repoOptions: all repos comes first, then the list", () => {
|
||||
assert.deepEqual(repoOptions(["a/x", "b/y"], ALL_REPOS), [
|
||||
{ value: "", label: "all repos" },
|
||||
{ value: "a/x", label: "a/x" },
|
||||
{ value: "b/y", label: "b/y" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("repoOptions: a listed selection adds nothing", () => {
|
||||
assert.equal(repoOptions(["a/x"], "a/x").length, 2);
|
||||
});
|
||||
|
||||
test("repoOptions: a remembered repo keeps an option before the list loads", () => {
|
||||
assert.deepEqual(repoOptions(null, "a/x"), [
|
||||
{ value: "", label: "all repos" },
|
||||
{ value: "a/x", label: "a/x" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("repoOptions: a remembered repo missing from the list says why", () => {
|
||||
assert.deepEqual(repoOptions(["b/y"], "a/x").at(-1), {
|
||||
value: "a/x",
|
||||
label: "a/x (no open issues)",
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue