paperlint 18.5.0 → 18.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +2 -2
- package/dist/adapters/hotcrp/portal.io.d.ts.map +1 -1
- package/dist/adapters/hotcrp/portal.io.js +1 -0
- package/dist/adapters/hotcrp/portal.io.js.map +1 -1
- package/dist/adapters/hotcrp/response.d.ts.map +1 -1
- package/dist/adapters/hotcrp/response.js +15 -0
- package/dist/adapters/hotcrp/response.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -3
- package/dist/cli.js.map +1 -1
- package/dist/domain/submission.d.ts +4 -0
- package/dist/domain/submission.d.ts.map +1 -1
- package/dist/domain/submission.js.map +1 -1
- package/dist/submission.d.ts +19 -2
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +121 -17
- package/dist/submission.js.map +1 -1
- package/docs/submission.md +19 -4
- package/package.json +1 -1
- package/src/adapters/hotcrp/portal.io.ts +1 -0
- package/src/adapters/hotcrp/portal.test.ts +43 -2
- package/src/adapters/hotcrp/response.ts +21 -0
- package/src/cli.ts +5 -3
- package/src/domain/submission.ts +4 -0
- package/src/submission-fields-run.test.ts +1 -0
- package/src/submission-prior-reviews.test.ts +9 -1
- package/src/submission-show.test.ts +81 -0
- package/src/submission-update.test.ts +164 -6
- package/src/submission.ts +208 -24
|
@@ -12,6 +12,7 @@ import { z } from "zod";
|
|
|
12
12
|
import { err, ok, type Result } from "../../domain/result.ts";
|
|
13
13
|
import { parseSha256, type Sha256 } from "../../domain/sha256.ts";
|
|
14
14
|
import type {
|
|
15
|
+
Author,
|
|
15
16
|
CreateOutcome,
|
|
16
17
|
PortalDocument,
|
|
17
18
|
PortalFailure,
|
|
@@ -42,6 +43,16 @@ const Paper = z.object({
|
|
|
42
43
|
abstract: z.string().optional(),
|
|
43
44
|
paper_type: z.unknown().optional(),
|
|
44
45
|
topics: z.array(z.string()).optional(),
|
|
46
|
+
authors: z
|
|
47
|
+
.array(
|
|
48
|
+
z.object({
|
|
49
|
+
email: z.string().optional(),
|
|
50
|
+
given_name: z.string().optional(),
|
|
51
|
+
family_name: z.string().optional(),
|
|
52
|
+
affiliation: z.string().optional(),
|
|
53
|
+
}),
|
|
54
|
+
)
|
|
55
|
+
.optional(),
|
|
45
56
|
submission: Document.nullable().optional(),
|
|
46
57
|
submitted_at: z.number().optional(),
|
|
47
58
|
modified_at: z.number().optional(),
|
|
@@ -115,6 +126,15 @@ const typeText = (v: unknown): string | null =>
|
|
|
115
126
|
? v
|
|
116
127
|
: JSON.stringify(v);
|
|
117
128
|
|
|
129
|
+
/** An author as HotCRP sends one — the name in two parts — in the paper's terms. */
|
|
130
|
+
const authorOf = (
|
|
131
|
+
a: Readonly<NonNullable<z.infer<typeof Paper>["authors"]>[number]>,
|
|
132
|
+
): Author => ({
|
|
133
|
+
name: `${a.given_name ?? ""} ${a.family_name ?? ""}`.trim(),
|
|
134
|
+
email: a.email ?? "",
|
|
135
|
+
affiliation: a.affiliation ?? null,
|
|
136
|
+
});
|
|
137
|
+
|
|
118
138
|
function viewOf(b: Readonly<z.infer<typeof ShowBody>>): SubmissionView {
|
|
119
139
|
const p = b.paper;
|
|
120
140
|
return {
|
|
@@ -124,6 +144,7 @@ function viewOf(b: Readonly<z.infer<typeof ShowBody>>): SubmissionView {
|
|
|
124
144
|
paperType: typeText(p.paper_type),
|
|
125
145
|
topics: p.topics ?? [],
|
|
126
146
|
abstract: p.abstract ?? null,
|
|
147
|
+
authors: p.authors === undefined ? null : p.authors.map(authorOf),
|
|
127
148
|
pdf: documentOf(p.submission),
|
|
128
149
|
submittedAt: p.submitted_at ?? null,
|
|
129
150
|
modifiedAt: p.modified_at ?? null,
|
package/src/cli.ts
CHANGED
|
@@ -308,10 +308,12 @@ const USAGE = `paperlint — machine-checkable gates for a paper kept in git
|
|
|
308
308
|
npx paperlint submission show [paper]
|
|
309
309
|
the paper's submission on the venue's portal: status, title,
|
|
310
310
|
type, topics, abstract length, the PDF the portal holds, and
|
|
311
|
-
whether it is the local paper.pdf (sha256)
|
|
311
|
+
whether it is the local paper.pdf (sha256); flags a title,
|
|
312
|
+
abstract or authors that are not the paper's
|
|
312
313
|
npx paperlint submission update [paper] [--pdf <file>] [--abstract <file>] [--submit] [--save]
|
|
313
|
-
send the PDF (default: the paper's own),
|
|
314
|
-
|
|
314
|
+
send the PDF (default: the paper's own), the paper's title
|
|
315
|
+
and abstract each when the portal holds another (--abstract:
|
|
316
|
+
that file's text instead), or "submitted". A DRY RUN unless --save: the portal checks the
|
|
315
317
|
change and keeps nothing. First prints what the venue rules find
|
|
316
318
|
in that exact PDF, as lint does; --save refuses a PDF the last
|
|
317
319
|
build did not measure (exit 2)
|
package/src/domain/submission.ts
CHANGED
|
@@ -86,6 +86,8 @@ export interface SubmissionView {
|
|
|
86
86
|
readonly paperType: string | null;
|
|
87
87
|
readonly topics: readonly string[];
|
|
88
88
|
readonly abstract: string | null;
|
|
89
|
+
/** The authors the portal records, in its order; null when it does not say. */
|
|
90
|
+
readonly authors: readonly Author[] | null;
|
|
89
91
|
/** The PDF the portal holds; null when none is uploaded. */
|
|
90
92
|
readonly pdf: PortalDocument | null;
|
|
91
93
|
/** Unix seconds; null when not submitted or not said. */
|
|
@@ -98,6 +100,8 @@ export interface SubmissionView {
|
|
|
98
100
|
/** A change to send. Every absent part is left as the portal has it. */
|
|
99
101
|
export interface SubmissionChange {
|
|
100
102
|
readonly pdf: { readonly name: string; readonly bytes: Uint8Array } | null;
|
|
103
|
+
/** The paper's title, sent when it differs from the portal's; null leaves the portal's. */
|
|
104
|
+
readonly title: string | null;
|
|
101
105
|
readonly abstract: string | null;
|
|
102
106
|
/** Mark the submission submitted (ready for review). */
|
|
103
107
|
readonly submit: boolean;
|
|
@@ -91,7 +91,15 @@ test("the dry run prints the same lines and goes on: the author reads them befor
|
|
|
91
91
|
{ sub: "update" },
|
|
92
92
|
{ files: paper([REVIEWED, SENT], UNANSWERED) },
|
|
93
93
|
);
|
|
94
|
-
|
|
94
|
+
// The paper has a \title, so `update` reads the portal's before it sends (#619).
|
|
95
|
+
expect([r.code, r.errs, r.seen[0]?.calls]).toStrictEqual([
|
|
96
|
+
0,
|
|
97
|
+
[],
|
|
98
|
+
[
|
|
99
|
+
["show", 7],
|
|
100
|
+
["update", 7, expect.anything(), { save: false }],
|
|
101
|
+
],
|
|
102
|
+
]);
|
|
95
103
|
expect(r.out.slice(2, 4)).toStrictEqual([HEADING, UNANSWERED_LINE]);
|
|
96
104
|
});
|
|
97
105
|
|
|
@@ -20,6 +20,10 @@ import {
|
|
|
20
20
|
fakePortal,
|
|
21
21
|
run,
|
|
22
22
|
STEPS,
|
|
23
|
+
files,
|
|
24
|
+
DEFAULT_TEX,
|
|
25
|
+
AUTHORS,
|
|
26
|
+
WANT,
|
|
23
27
|
} from "../test/submission-fixtures.ts";
|
|
24
28
|
import { frozenText } from "../test/frozen-presets.ts";
|
|
25
29
|
|
|
@@ -217,3 +221,80 @@ test("show, in the flat form: the deadlines in force are the preset's readings a
|
|
|
217
221
|
});
|
|
218
222
|
|
|
219
223
|
// ── new ───────────────────────────────────────────────────────────────────────────────
|
|
224
|
+
|
|
225
|
+
/** The made-up paper with its source and its authors, against `view` on the portal. */
|
|
226
|
+
const against = (view: Partial<SubmissionView>, paper: object = {}) =>
|
|
227
|
+
run(
|
|
228
|
+
{},
|
|
229
|
+
{
|
|
230
|
+
files: files({
|
|
231
|
+
paper: {
|
|
232
|
+
extends: "../../venue.jsonc",
|
|
233
|
+
submission: { id: 7 },
|
|
234
|
+
authors: AUTHORS,
|
|
235
|
+
...paper,
|
|
236
|
+
},
|
|
237
|
+
extra: { [`${PAPER}/paper.tex`]: DEFAULT_TEX },
|
|
238
|
+
}),
|
|
239
|
+
portal: fakePortal({ show: ok({ ...VIEW, ...view }) }),
|
|
240
|
+
},
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
test("🔴 show: a portal title, abstract or authors that are not the paper's are flagged, with what changes each", async () => {
|
|
244
|
+
const r = await against({
|
|
245
|
+
authors: [
|
|
246
|
+
{
|
|
247
|
+
name: "A. Author",
|
|
248
|
+
email: "author@example.org",
|
|
249
|
+
affiliation: "Example University",
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
});
|
|
253
|
+
expect(r.code).toBe(0);
|
|
254
|
+
expect(r.out.slice(2, 9)).toStrictEqual([
|
|
255
|
+
"title A Fake Title",
|
|
256
|
+
"paper title Agents That Lie — NOT the portal's; `paperlint submission update` sends it",
|
|
257
|
+
"paper type Regular",
|
|
258
|
+
"topics A; B",
|
|
259
|
+
"abstract 4 words",
|
|
260
|
+
"paper abstract 17 words — NOT the portal's; `paperlint submission update` sends it",
|
|
261
|
+
"paper authors Ada Lovelace <ada@example.org>, Analytical; Bob Bobson <bob@example.org> — NOT the portal's (A. Author <author@example.org>, Example University); `paperlint submission update` does not change the authors: change them on the site",
|
|
262
|
+
]);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("show: what matches the paper adds no line — spacing, the case of an email, an affiliation left out on both", async () => {
|
|
266
|
+
const r = await against({
|
|
267
|
+
title: "Agents That Lie",
|
|
268
|
+
abstract: ` ${WANT.abstract}`,
|
|
269
|
+
authors: [
|
|
270
|
+
{
|
|
271
|
+
name: "Ada Lovelace",
|
|
272
|
+
email: "ADA@example.org",
|
|
273
|
+
affiliation: "Analytical",
|
|
274
|
+
},
|
|
275
|
+
{ name: "Bob Bobson", email: "bob@example.org", affiliation: null },
|
|
276
|
+
],
|
|
277
|
+
});
|
|
278
|
+
expect(r.out.slice(2, 7)).toStrictEqual([
|
|
279
|
+
"title Agents That Lie",
|
|
280
|
+
"paper type Regular",
|
|
281
|
+
"topics A; B",
|
|
282
|
+
"abstract 17 words",
|
|
283
|
+
`portal PDF sha2-${HEX}, ${String(PDF.length)} bytes, uploaded 1970-01-01T00:00:00.000Z`,
|
|
284
|
+
]);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test("show: authors compared only when both sides name them, and an author missing on one side is a difference", async () => {
|
|
288
|
+
const same = { title: "Agents That Lie", abstract: WANT.abstract };
|
|
289
|
+
const quiet = [
|
|
290
|
+
await against({ ...same, authors: null }),
|
|
291
|
+
await against({ ...same, authors: WANT.authors }, { authors: undefined }),
|
|
292
|
+
];
|
|
293
|
+
expect(
|
|
294
|
+
quiet.map((r) => r.out.some((l) => l.startsWith("paper authors"))),
|
|
295
|
+
).toStrictEqual([false, false]);
|
|
296
|
+
const fewer = await against({ ...same, authors: WANT.authors.slice(0, 1) });
|
|
297
|
+
expect(fewer.out[6]).toBe(
|
|
298
|
+
"paper authors Ada Lovelace <ada@example.org>, Analytical; Bob Bobson <bob@example.org> — NOT the portal's (Ada Lovelace <ada@example.org>, Analytical); `paperlint submission update` does not change the authors: change them on the site",
|
|
299
|
+
);
|
|
300
|
+
});
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
import { expect, test } from "vitest";
|
|
3
3
|
import { memoryFiles } from "./adapters/memory/index.ts";
|
|
4
4
|
import { err, ok } from "./domain/result.ts";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type PortalFailure,
|
|
7
|
+
type SubmissionView,
|
|
8
|
+
type UpdateOutcome,
|
|
9
|
+
} from "./domain/submission.ts";
|
|
6
10
|
import {
|
|
7
11
|
PAPER,
|
|
8
12
|
SITE,
|
|
@@ -14,6 +18,10 @@ import {
|
|
|
14
18
|
run,
|
|
15
19
|
NO_ERRORS,
|
|
16
20
|
facts,
|
|
21
|
+
DEFAULT_TEX,
|
|
22
|
+
ABSTRACT_TEX,
|
|
23
|
+
VIEW,
|
|
24
|
+
WANT,
|
|
17
25
|
} from "../test/submission-fixtures.ts";
|
|
18
26
|
|
|
19
27
|
test("update: a dry run by default — the paper's PDF sent, nothing saved, exit 0", async () => {
|
|
@@ -25,6 +33,7 @@ test("update: a dry run by default — the paper's PDF sent, nothing saved, exit
|
|
|
25
33
|
7,
|
|
26
34
|
{
|
|
27
35
|
pdf: { name: "paper.pdf", bytes: PDF },
|
|
36
|
+
title: null,
|
|
28
37
|
abstract: null,
|
|
29
38
|
submit: false,
|
|
30
39
|
fields: {},
|
|
@@ -35,6 +44,8 @@ test("update: a dry run by default — the paper's PDF sent, nothing saved, exit
|
|
|
35
44
|
expect(r.out).toStrictEqual([
|
|
36
45
|
CHECK("papers/p/paper.pdf", "the call for papers, https://example.org/cfp"),
|
|
37
46
|
NO_ERRORS,
|
|
47
|
+
NOT_CHECKED,
|
|
48
|
+
NO_ABSTRACT,
|
|
38
49
|
"dry run — the portal checked the change and kept nothing; --save sends it for real",
|
|
39
50
|
"HTTP 200",
|
|
40
51
|
"valid yes",
|
|
@@ -64,6 +75,7 @@ test("update --save --submit --abstract --pdf: all of it sent, and said to be sa
|
|
|
64
75
|
7,
|
|
65
76
|
{
|
|
66
77
|
pdf: { name: "other.pdf", bytes: PDF },
|
|
78
|
+
title: null,
|
|
67
79
|
abstract: "The abstract.",
|
|
68
80
|
submit: true,
|
|
69
81
|
fields: {},
|
|
@@ -72,9 +84,11 @@ test("update --save --submit --abstract --pdf: all of it sent, and said to be sa
|
|
|
72
84
|
],
|
|
73
85
|
]);
|
|
74
86
|
// Guards: the PDF that is sent is the one named, and --save is told to check it too.
|
|
75
|
-
expect(r.out.slice(0,
|
|
87
|
+
expect(r.out.slice(0, 5)).toStrictEqual([
|
|
76
88
|
CHECK("other.pdf", "the call for papers, https://example.org/cfp"),
|
|
77
89
|
NO_ERRORS,
|
|
90
|
+
NOT_CHECKED,
|
|
91
|
+
"abstract sends abs.txt (2 words), from --abstract",
|
|
78
92
|
"saved",
|
|
79
93
|
]);
|
|
80
94
|
});
|
|
@@ -113,7 +127,7 @@ test("update: valid:false, or a non-2xx status, exits 1 with the portal's messag
|
|
|
113
127
|
{ portal: fakePortal({ update: invalid }) },
|
|
114
128
|
);
|
|
115
129
|
expect(r1.code).toBe(1);
|
|
116
|
-
expect(r1.out.slice(
|
|
130
|
+
expect(r1.out.slice(6)).toStrictEqual([
|
|
117
131
|
"valid NO",
|
|
118
132
|
"changes —",
|
|
119
133
|
`local PDF papers/p/paper.pdf sha2-${HEX}`,
|
|
@@ -154,7 +168,7 @@ test("update --save that the portal withheld says so", async () => {
|
|
|
154
168
|
{ sub: "update", save: true },
|
|
155
169
|
{ portal: fakePortal({ update: withheld }) },
|
|
156
170
|
);
|
|
157
|
-
expect(r.out[
|
|
171
|
+
expect(r.out[4]).toBe("SAVE WITHHELD by the portal — nothing changed");
|
|
158
172
|
});
|
|
159
173
|
|
|
160
174
|
test("update: no PDF to send, or no abstract file, is refused before the portal is asked", async () => {
|
|
@@ -169,6 +183,14 @@ test("update: no PDF to send, or no abstract file, is refused before the portal
|
|
|
169
183
|
expect(r2.errs).toStrictEqual(["--abstract: no file at nope.txt"]);
|
|
170
184
|
});
|
|
171
185
|
|
|
186
|
+
/** `update`'s title line for the made-up paper, which has no paper.tex and no PDF Title. */
|
|
187
|
+
const NOT_CHECKED =
|
|
188
|
+
"title not checked — no \\title in paper.tex, and the PDF names no Title — add \\title{…}, or \\hypersetup{pdftitle={…}}, and rebuild";
|
|
189
|
+
|
|
190
|
+
/** `update`'s abstract line for the made-up paper, which has no paper.tex. */
|
|
191
|
+
const NO_ABSTRACT =
|
|
192
|
+
"abstract not checked — no paper.tex to read the abstract from — give the abstract with --abstract <file>, a plain-text file";
|
|
193
|
+
|
|
172
194
|
// ── the venue check before a send (paperlint#264) ─────────────────────────────────────
|
|
173
195
|
|
|
174
196
|
/** A paper of kind `short` (6 body pages) at a venue over AIDC, not blind, built 8 body pages long. */
|
|
@@ -197,11 +219,13 @@ const LINT_BLOCK = (level: "error" | "warning", text: string): string[] => [
|
|
|
197
219
|
test("update over the page limit: the venue rules' findings on that PDF, as lint prints them, before the portal is asked; a dry run still runs", async () => {
|
|
198
220
|
const r = await run({ sub: "update" }, { files: OVER });
|
|
199
221
|
expect(r.code).toBe(0);
|
|
200
|
-
expect(r.out.slice(1,
|
|
222
|
+
expect(r.out.slice(1, 9)).toStrictEqual([
|
|
201
223
|
...LINT_BLOCK(
|
|
202
224
|
"error",
|
|
203
225
|
"body pages (up to the references on page 9): 8, over the limit 6 for venue/short — a desk reject; cut the text format/page-limit",
|
|
204
226
|
),
|
|
227
|
+
NOT_CHECKED,
|
|
228
|
+
NO_ABSTRACT,
|
|
205
229
|
"dry run — the portal checked the change and kept nothing; --save sends it for real",
|
|
206
230
|
]);
|
|
207
231
|
expect(r.seen[0]?.calls).toHaveLength(1);
|
|
@@ -209,7 +233,7 @@ test("update over the page limit: the venue rules' findings on that PDF, as lint
|
|
|
209
233
|
|
|
210
234
|
test("update --save over the limit: the same findings, and the send goes ahead — the person decides on them, not the command", async () => {
|
|
211
235
|
const r = await run({ sub: "update", save: true }, { files: OVER });
|
|
212
|
-
expect([r.code, r.errs, r.out[2], r.out[
|
|
236
|
+
expect([r.code, r.errs, r.out[2], r.out[8]]).toStrictEqual([
|
|
213
237
|
0,
|
|
214
238
|
[],
|
|
215
239
|
`${PAPER}/paper.tex`,
|
|
@@ -314,3 +338,137 @@ test("porting skips the venue rules, not the freshness: --save with facts about
|
|
|
314
338
|
);
|
|
315
339
|
expect([unbuilt.code, unbuilt.errs]).toStrictEqual([2, [REFUSAL]]);
|
|
316
340
|
});
|
|
341
|
+
|
|
342
|
+
/** The made-up paper with its source, so `update` has a title and an abstract to compare with the portal's. */
|
|
343
|
+
const titled = (tex: string = DEFAULT_TEX) =>
|
|
344
|
+
files({ extra: { [`${PAPER}/paper.tex`]: tex } });
|
|
345
|
+
|
|
346
|
+
/** The portal holding the paper's own title and abstract, spaced differently. */
|
|
347
|
+
const holding = (more: Partial<SubmissionView> = {}) =>
|
|
348
|
+
fakePortal({
|
|
349
|
+
show: ok({
|
|
350
|
+
...VIEW,
|
|
351
|
+
title: " Agents That Lie ",
|
|
352
|
+
abstract: `${WANT.abstract.replaceAll(" ", "\n")}\n`,
|
|
353
|
+
...more,
|
|
354
|
+
}),
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
/** What `update` sends of the made-up paper with nothing else asked. */
|
|
358
|
+
const SENT = (text: { title: string | null; abstract: string | null }) => [
|
|
359
|
+
"update",
|
|
360
|
+
7,
|
|
361
|
+
{
|
|
362
|
+
pdf: { name: "paper.pdf", bytes: PDF },
|
|
363
|
+
...text,
|
|
364
|
+
submit: false,
|
|
365
|
+
fields: {},
|
|
366
|
+
},
|
|
367
|
+
{ save: false },
|
|
368
|
+
];
|
|
369
|
+
|
|
370
|
+
test("🔴 update: a \\title and an abstract that differ from the portal's are sent, and said, in the dry run", async () => {
|
|
371
|
+
const r = await run({ sub: "update" }, { files: titled() });
|
|
372
|
+
expect(r.code).toBe(0);
|
|
373
|
+
expect(r.seen[0]?.calls).toStrictEqual([
|
|
374
|
+
["show", 7],
|
|
375
|
+
SENT({ title: "Agents That Lie", abstract: WANT.abstract }),
|
|
376
|
+
]);
|
|
377
|
+
expect(r.out.slice(0, 5)).toStrictEqual([
|
|
378
|
+
CHECK("papers/p/paper.pdf", "the call for papers, https://example.org/cfp"),
|
|
379
|
+
NO_ERRORS,
|
|
380
|
+
"title sends «Agents That Lie» — the portal has «A Fake Title»",
|
|
381
|
+
"abstract sends the paper's (17 words) — the portal has another (4 words)",
|
|
382
|
+
"dry run — the portal checked the change and kept nothing; --save sends it for real",
|
|
383
|
+
]);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
test("update: a \\title and an abstract the portal already holds are not sent", async () => {
|
|
387
|
+
const r = await run(
|
|
388
|
+
{ sub: "update" },
|
|
389
|
+
{ files: titled(), portal: holding() },
|
|
390
|
+
);
|
|
391
|
+
expect(r.code).toBe(0);
|
|
392
|
+
expect(r.seen[0]?.calls[1]).toStrictEqual(
|
|
393
|
+
SENT({ title: null, abstract: null }),
|
|
394
|
+
);
|
|
395
|
+
expect(r.out.slice(2, 4)).toStrictEqual([
|
|
396
|
+
"title unchanged — the portal holds «Agents That Lie»",
|
|
397
|
+
"abstract unchanged — the portal holds the paper's (17 words)",
|
|
398
|
+
]);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
test("update: a portal with no title and no abstract gets the paper's, said as none", async () => {
|
|
402
|
+
const none = holding({ title: null, abstract: null });
|
|
403
|
+
const r = await run({ sub: "update" }, { files: titled(), portal: none });
|
|
404
|
+
expect(r.out.slice(2, 4)).toStrictEqual([
|
|
405
|
+
"title sends «Agents That Lie» — the portal has none",
|
|
406
|
+
"abstract sends the paper's (17 words) — the portal has none",
|
|
407
|
+
]);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
test("update: neither readable — both said, nothing asked of the portal for them, and the PDF still sent", async () => {
|
|
411
|
+
const r = await run({ sub: "update" });
|
|
412
|
+
expect(r.code).toBe(0);
|
|
413
|
+
expect(r.seen[0]?.calls).toStrictEqual([
|
|
414
|
+
SENT({ title: null, abstract: null }),
|
|
415
|
+
]);
|
|
416
|
+
expect(r.out.slice(2, 4)).toStrictEqual([NOT_CHECKED, NO_ABSTRACT]);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
test("update: one of the two readable is enough to ask the portal — an abstract with no \\title, a \\title with no abstract", async () => {
|
|
420
|
+
const abstractOnly = `\\documentclass{article}\n\\newcommand{\\ours}{TestLie}\n\\begin{document}\n${ABSTRACT_TEX}\\end{document}\n`;
|
|
421
|
+
const r1 = await run(
|
|
422
|
+
{ sub: "update" },
|
|
423
|
+
{ files: titled(abstractOnly), portal: holding() },
|
|
424
|
+
);
|
|
425
|
+
expect(r1.seen[0]?.calls).toStrictEqual([
|
|
426
|
+
["show", 7],
|
|
427
|
+
SENT({ title: null, abstract: null }),
|
|
428
|
+
]);
|
|
429
|
+
const titleOnly =
|
|
430
|
+
"\\documentclass{article}\n\\title{Agents That Lie}\n\\begin{document}\\end{document}\n";
|
|
431
|
+
const r2 = await run(
|
|
432
|
+
{ sub: "update" },
|
|
433
|
+
{ files: titled(titleOnly), portal: holding() },
|
|
434
|
+
);
|
|
435
|
+
expect(r2.seen[0]?.calls).toStrictEqual([
|
|
436
|
+
["show", 7],
|
|
437
|
+
SENT({ title: null, abstract: null }),
|
|
438
|
+
]);
|
|
439
|
+
expect(r2.out[3]).toBe(
|
|
440
|
+
"abstract not checked — paper.tex has no \\begin{abstract}…\\end{abstract} — give the abstract with --abstract <file>, a plain-text file",
|
|
441
|
+
);
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
test("update --abstract: the file is sent whatever the portal holds, and said", async () => {
|
|
445
|
+
const fs = files({
|
|
446
|
+
extra: {
|
|
447
|
+
[`${PAPER}/paper.tex`]: DEFAULT_TEX,
|
|
448
|
+
"/w/abs.txt": "Two words.\n",
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
const r = await run(
|
|
452
|
+
{ sub: "update", abstract: "abs.txt" },
|
|
453
|
+
{ files: fs, portal: holding() },
|
|
454
|
+
);
|
|
455
|
+
expect(r.seen[0]?.calls[1]).toStrictEqual(
|
|
456
|
+
SENT({ title: null, abstract: "Two words." }),
|
|
457
|
+
);
|
|
458
|
+
expect(r.out[3]).toBe(
|
|
459
|
+
"abstract sends abs.txt (2 words), from --abstract",
|
|
460
|
+
);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
test("update: the portal refusing the read exits 1 and sends nothing", async () => {
|
|
464
|
+
const refused = fakePortal({
|
|
465
|
+
show: err<PortalFailure>({
|
|
466
|
+
kind: "refused",
|
|
467
|
+
httpStatus: 401,
|
|
468
|
+
messages: [{ message: "Missing credentials", field: null, status: 2 }],
|
|
469
|
+
}),
|
|
470
|
+
});
|
|
471
|
+
const r = await run({ sub: "update" }, { files: titled(), portal: refused });
|
|
472
|
+
expect(r.code).toBe(1);
|
|
473
|
+
expect(r.seen[0]?.calls).toStrictEqual([["show", 7]]);
|
|
474
|
+
});
|