- Chapter rows show when you first finished a chapter (setting: date + hour, date, off) from a new durable progress doneAt; older reads fall back to the reading clock's earliest remembered completion. - chapter.json keeps added (arrival in this library, now kept on replace) plus x-dates.source (source upload, bulk imports flagged), x-dates.release (official, for a later metadata job) and x-dates.ecosystem (first entry into any Manga Circus library; carried over peering, earliest wins, clamped). - Rows show one release date by tier: official > source upload > ecosystem > library, with all known dates in the tooltip (setting to hide). - Fixes: WeebCentral dates came from the chapter page, which has none (every chapter got the download time); they now come from the full chapter list. MangaDex no longer writes a group's publishAt into added. Peering sends dates. - tools/backfill-chapter-dates.js migrates an existing library (dry run default). - Coverage dry run on the server: docs/chapter-dates-coverage-2026-10-24.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
3.7 KiB
JavaScript
64 lines
3.7 KiB
JavaScript
'use strict';
|
|
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const { parse } = require('../plugins/registry');
|
|
const { validate } = require('../plugins/validation');
|
|
const { discoverWeebCatalog, discoverWeebChapter } = require('../adapters/weebcentral');
|
|
const { adapters, adapterFor } = require('../adapters');
|
|
|
|
const seriesUrl = 'https://weebcentral.com/series/ABC/title';
|
|
const chapterUrl = 'https://weebcentral.com/chapters/XYZ';
|
|
const seriesHtml = '<h1>Test Manga</h1><div hx-get="/series/ABC/full-chapter-list"></div>';
|
|
const listHtml = '<a href="/chapters/XYZ"><span>Chapter 1</span><time datetime="2026-01-01T15:06:05.348Z">x</time></a><a href="/chapters/LMN">Log. 2</a>';
|
|
const chapterHtml = '<div>no dates on the chapter page</div>';
|
|
const imagesHtml = '<img src="https://img.example/1.jpg"><img data-src="https://img.example/2.jpg">';
|
|
|
|
test('first-party registry rejects unknown plugins and malformed input', () => {
|
|
assert.throws(() => parse('remote-module', 'catalog', { html: listHtml, url: seriesUrl }), /Unknown/);
|
|
assert.throws(() => parse('weebcentral', 'catalog', { html: listHtml, url: 'file:///tmp/x' }), /Invalid source URL/);
|
|
assert.throws(() => parse('weebcentral', 'catalog', { html: listHtml, url: 'https://other.example/series/a' }), /does not belong/);
|
|
assert.equal(parse('weebcentral', 'catalog', { html: listHtml, url: seriesUrl }).chapters.length, 2);
|
|
});
|
|
|
|
test('parser output cannot turn catalog and image links into local or unrelated requests', () => {
|
|
assert.throws(() => validate('weebcentral', 'series', { title: 'X', listUrl: 'http://127.0.0.1:8091/api/state' }), /unexpected/);
|
|
assert.throws(() => validate('weebcentral', 'catalog', { chapterLinks: 1, chapters: [{ id: 'X', number: '1', url: 'https://other.example/chapters/X' }] }), /unexpected/);
|
|
assert.throws(() => validate('weebcentral', 'chapter', { manifestUrl: 'https://weebcentral.com/chapters/X/not-images' }), /manifest/);
|
|
assert.throws(() => validate('weebcentral', 'pages', { pages: ['http://127.0.0.1:8080/private'] }), /unsafe/);
|
|
assert.throws(() => validate('weebcentral', 'pages', { pages: ['https://localhost/private'] }), /unsafe/);
|
|
assert.doesNotThrow(() => validate('weebcentral', 'pages', { pages: ['https://img.example/1.jpg'] }));
|
|
});
|
|
|
|
test('in-process parser preserves WeebCentral catalog and page discovery', async () => {
|
|
const requested = [];
|
|
const http = { async get(url) {
|
|
requested.push(url);
|
|
const body = url === seriesUrl ? seriesHtml
|
|
: url.endsWith('/full-chapter-list') ? listHtml
|
|
: url === chapterUrl ? chapterHtml
|
|
: imagesHtml;
|
|
return { text: async () => body };
|
|
} };
|
|
const catalog = await discoverWeebCatalog(seriesUrl, http);
|
|
assert.equal(catalog.title, 'Test Manga');
|
|
assert.deepEqual(catalog.chapters.map(chapter => chapter.number), ['1', '2']);
|
|
const chapter = await discoverWeebChapter(catalog.chapters[0], http);
|
|
assert.equal(chapter.pages.length, 2);
|
|
assert.equal(chapter.added, undefined);
|
|
assert.deepEqual(chapter.dates, { source: { at: '2026-01-01T15:06:05.348Z', name: 'WeebCentral', batch: false } });
|
|
assert.equal(catalog.chapters[1].uploadedAt, undefined);
|
|
assert.equal(requested.length, 4);
|
|
});
|
|
|
|
test('a new source is an explicit adapter, not another container or remote module', () => {
|
|
assert.deepEqual(adapters.map(adapter => adapter.id), ['weebcentral', 'mangadex', 'mangapill']);
|
|
for (const adapter of adapters) {
|
|
assert.equal(typeof adapter.match, 'function');
|
|
assert.equal(typeof adapter.discover, 'function');
|
|
assert.equal(typeof adapter.run, 'function');
|
|
}
|
|
assert.equal(adapterFor(seriesUrl)?.adapter.id, 'weebcentral');
|
|
assert.equal(adapterFor('https://unknown.example/series/ABC'), null);
|
|
});
|