Simplify the upload state and the story page data
The pause of the user and a missing ingest folder are separate checks. One function gives the upload state to the settings and the story page. A route that returns only a story no longer loads its chapters or asks CWA for its book. The story page data loses the values that no page reads.
This commit is contained in:
@@ -647,7 +647,7 @@ test('with CWA off, the pages show nothing about CWA', async () => {
|
||||
assert.ok(section(main, 'Library link'));
|
||||
const off = { ...config, cwa_enabled: false, library_available: false };
|
||||
// Values that show a notice with CWA on.
|
||||
Object.assign(details, { uploads_paused: true, ingest_available: false, link_books: false });
|
||||
Object.assign(details, { pause_uploads: true, ingest_available: false, link_books: false });
|
||||
details.story.upload_held = true;
|
||||
await mountStory(off);
|
||||
assert.ok(section(main, 'Metadata'));
|
||||
|
||||
@@ -15,7 +15,7 @@ const details = (story, extra = {}) => ({
|
||||
calibre_id: null, calibre_uuid: null, ingested_at: null, upload_held: false, needs_approval: false, ...story },
|
||||
chapters: [],
|
||||
recent_chapters: 0,
|
||||
uploads_paused: false,
|
||||
pause_uploads: false,
|
||||
book: null,
|
||||
...extra,
|
||||
});
|
||||
@@ -192,7 +192,7 @@ for (const uuid of [null, 'book-7']) {
|
||||
test(`approval while paused saves the decision without promising an upload: ${uuid}`, async (t) => {
|
||||
const data = details(
|
||||
{ calibre_id: uuid ? 7 : null, calibre_uuid: uuid, upload_held: true, needs_approval: true },
|
||||
{ link_books: true, uploads_paused: true },
|
||||
{ link_books: true, pause_uploads: true },
|
||||
);
|
||||
const { backend, notice } = await renderStory(t, data);
|
||||
assert.ok(find(notice, 'button', 'Approve'));
|
||||
@@ -208,7 +208,7 @@ for (const uuid of [null, 'book-7']) {
|
||||
test('approval as a new book while paused keeps the pause in the confirmation', async (t) => {
|
||||
const data = details(
|
||||
{ calibre_id: 7, calibre_uuid: 'book-7', upload_held: true, needs_approval: true },
|
||||
{ link_books: true, uploads_paused: true },
|
||||
{ link_books: true, pause_uploads: true },
|
||||
);
|
||||
const { backend, notice } = await renderStory(t, data);
|
||||
const confirm = t.mock.method(window, 'confirm', () => true);
|
||||
@@ -239,7 +239,7 @@ test('a new story asks for approval to go to CWA as a new book', async (t) => {
|
||||
test('a paused upload points to the settings', async (t) => {
|
||||
const { notice } = await renderStory(
|
||||
t,
|
||||
details({ calibre_id: 7, calibre_uuid: 'book-7', ingested_at: '2026-01-01', upload_held: true }, { book, uploads_paused: true }),
|
||||
details({ calibre_id: 7, calibre_uuid: 'book-7', ingested_at: '2026-01-01', upload_held: true }, { book, pause_uploads: true }),
|
||||
);
|
||||
assert.match(notice.textContent, /Uploads to CWA are paused/);
|
||||
assert.equal(find(notice, 'a', 'Settings').attributes.href, '#/settings');
|
||||
@@ -253,7 +253,7 @@ for (const savedId of [null, 7]) {
|
||||
const { notice } = await renderStory(t, details(
|
||||
{ calibre_id: savedId, calibre_uuid: savedId ? 'book-7' : null,
|
||||
upload_held: true, needs_approval: needsApproval },
|
||||
{ link_books: false, uploads_paused: paused },
|
||||
{ link_books: false, pause_uploads: paused },
|
||||
));
|
||||
if (savedId !== null && !paused) {
|
||||
assert.equal(notice, undefined);
|
||||
@@ -294,7 +294,7 @@ test('a story that went to CWA without a link shows no approval until Bindery fi
|
||||
|
||||
test('missing INGEST_DIR points to the environment rather than the disabled pause switch', async (t) => {
|
||||
const { notice } = await renderStory(t, details(
|
||||
{ upload_held: true }, { uploads_paused: true, ingest_available: false },
|
||||
{ upload_held: true }, { pause_uploads: true, ingest_available: false },
|
||||
));
|
||||
assert.equal(notice.textContent, 'Set INGEST_DIR and restart Bindery to enable uploads.');
|
||||
assert.equal(nodes(notice).filter((el) => el.tagName === 'button').length, 0);
|
||||
@@ -303,7 +303,7 @@ test('missing INGEST_DIR points to the environment rather than the disabled paus
|
||||
test('missing library sources leave uploads enabled with the duplicate warning', async (t) => {
|
||||
const { notice } = await renderStory(t, details(
|
||||
{ ingested_at: '2026-01-01', upload_held: true, needs_approval: true },
|
||||
{ link_books: false, library_matching_available: false },
|
||||
{ link_books: false },
|
||||
));
|
||||
assert.match(notice.textContent, /If CWA imports them, updates will create duplicate books/);
|
||||
assert.equal(nodes(notice).filter((el) => el.tagName === 'button').length, 0);
|
||||
@@ -312,7 +312,7 @@ test('missing library sources leave uploads enabled with the duplicate warning',
|
||||
test('a new book asks for approval when library linking is enabled', async (t) => {
|
||||
const { notice } = await renderStory(t, details(
|
||||
{ upload_held: true, needs_approval: true },
|
||||
{ link_books: true, library_matching_available: true },
|
||||
{ link_books: true },
|
||||
));
|
||||
assert.match(notice.textContent, /^Approve this story as a new CWA book\./);
|
||||
assert.ok(find(notice, 'button', 'Approve and send'));
|
||||
@@ -320,7 +320,7 @@ test('a new book asks for approval when library linking is enabled', async (t) =
|
||||
|
||||
test('approval before a build still shows the pause and never offers to send', async (t) => {
|
||||
const { notice } = await renderStory(t, details(
|
||||
{ needs_approval: true }, { uploads_paused: true },
|
||||
{ needs_approval: true }, { pause_uploads: true },
|
||||
));
|
||||
assert.match(notice.textContent, /Uploads to CWA are paused\. Resume them in Settings\./);
|
||||
assert.ok(find(notice, 'button', 'Approve'));
|
||||
|
||||
Reference in New Issue
Block a user