swarm-ui: the report, review and classifier-key pages read through useResource
Part of the unification order in the UI sweep issue (step d, the rest). The pull-request and issue reports (the repo list and the report), the review try-out's repo list and classifier cap, and the classifier key move to the shared read hook. A failed report still drops its rows, now by reading 'error ? null : loaded' instead of a handler that cleared them. The reads that seed a draft, post, or are not a plain request stay as they were.
This commit is contained in:
parent
bbdd32c2e0
commit
c5cc961028
2 changed files with 103 additions and 191 deletions
|
|
@ -2,6 +2,7 @@ import { test } from "node:test";
|
|||
import assert from "node:assert/strict";
|
||||
import {
|
||||
ALL_REPOS,
|
||||
reportRows,
|
||||
reportUrl,
|
||||
repoOptions,
|
||||
} from "../src/pages/issue-report-repo.ts";
|
||||
|
|
@ -53,3 +54,10 @@ test("repoOptions: a remembered repo missing from the list says why", () => {
|
|||
label: "a/x (no open issues)",
|
||||
});
|
||||
});
|
||||
|
||||
test("reportRows: a failed report shows no rows, a good one shows them", () => {
|
||||
const rows = [{ n: 1 }];
|
||||
assert.equal(reportRows({ detail: "boom" }, rows), null);
|
||||
assert.equal(reportRows(null, rows), rows);
|
||||
assert.equal(reportRows(null, null), null);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
draftProblem,
|
||||
duplicateName,
|
||||
hasTypedText,
|
||||
maxClassificationsOf,
|
||||
prNumber,
|
||||
repoProblem,
|
||||
rowsProblem,
|
||||
|
|
@ -154,3 +155,10 @@ test("the page's one hint names what disables opening a PR before the PR number"
|
|||
assert.equal(rowsProblem("o/r", [row()]), null);
|
||||
assert.equal(runProblem("o/r", "7", [row()]), null);
|
||||
});
|
||||
|
||||
test("maxClassificationsOf: the settings cap when it is a number, else none", () => {
|
||||
assert.equal(maxClassificationsOf({ max_classifications: 20 }), 20);
|
||||
assert.equal(maxClassificationsOf({}), null);
|
||||
assert.equal(maxClassificationsOf({ max_classifications: "20" }), null);
|
||||
assert.equal(maxClassificationsOf(null), null);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue