feat: 分类显示书籍数量并发布 v2.1.2
构建与发布 / 单测与集成测试 (push) Waiting to run
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
构建与发布 / 发布 GitHub Release (push) Blocked by required conditions
构建与发布 / 单测与集成测试 (push) Waiting to run
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
构建与发布 / 发布 GitHub Release (push) Blocked by required conditions
This commit is contained in:
@@ -569,6 +569,22 @@ app.whenReady().then(async () => {
|
||||
);
|
||||
readerWindow.destroy();
|
||||
await wait(200);
|
||||
check(
|
||||
'分类侧栏显示全部、未分类和各书架的真实书籍数量',
|
||||
await js(`(() => {
|
||||
const all = document.querySelector('#libraryTab .library-filter[data-shelf=""]');
|
||||
const uncategorized = document.querySelector(
|
||||
'#libraryTab .library-filter[data-shelf="__uncategorized__"]'
|
||||
);
|
||||
const shelves = Array.from(document.querySelectorAll('#libraryShelfList .library-filter'));
|
||||
const research = shelves.find((button) => button.textContent.includes('研究书架'));
|
||||
const review = shelves.find((button) => button.textContent.includes('待复核书架'));
|
||||
return all.querySelector('.library-filter-count').textContent === '3'
|
||||
&& uncategorized.querySelector('.library-filter-count').textContent === '1'
|
||||
&& research.querySelector('.library-filter-count').textContent === '1'
|
||||
&& review.querySelector('.library-filter-count').textContent === '1';
|
||||
})()`)
|
||||
);
|
||||
check(
|
||||
'标签侧栏显示真实聚合计数',
|
||||
await js(`(() => {
|
||||
@@ -632,7 +648,7 @@ app.whenReady().then(async () => {
|
||||
|
||||
await js(`(() => {
|
||||
const button = Array.from(document.querySelectorAll('#libraryShelfList .library-filter'))
|
||||
.find((candidate) => candidate.textContent.trim() === '研究书架');
|
||||
.find((candidate) => candidate.firstElementChild.textContent.trim() === '研究书架');
|
||||
button.click();
|
||||
})()`);
|
||||
await pollJs(
|
||||
@@ -681,7 +697,7 @@ app.whenReady().then(async () => {
|
||||
!!uiShelf
|
||||
&& await js(`(() => {
|
||||
const button = Array.from(document.querySelectorAll('#libraryShelfList .library-filter'))
|
||||
.find((candidate) => candidate.textContent.trim() === '界面书架');
|
||||
.find((candidate) => candidate.firstElementChild.textContent.trim() === '界面书架');
|
||||
return !!button && button.classList.contains('active')
|
||||
&& document.getElementById('libStatus').textContent === '显示 0 条,共 3 条';
|
||||
})()`)
|
||||
@@ -783,7 +799,7 @@ app.whenReady().then(async () => {
|
||||
|
||||
await js(`(() => {
|
||||
const button = Array.from(document.querySelectorAll('#libraryShelfList .library-filter'))
|
||||
.find((candidate) => candidate.textContent.trim() === '界面书架已重命名');
|
||||
.find((candidate) => candidate.firstElementChild.textContent.trim() === '界面书架已重命名');
|
||||
button.click();
|
||||
})()`);
|
||||
await pollJs(
|
||||
@@ -859,7 +875,7 @@ app.whenReady().then(async () => {
|
||||
// 否则批量操作会误伤用户看不到的书
|
||||
await js(`(() => {
|
||||
const button = Array.from(document.querySelectorAll('#libraryShelfList .library-filter'))
|
||||
.find((candidate) => candidate.textContent.trim() === '研究书架');
|
||||
.find((candidate) => candidate.firstElementChild.textContent.trim() === '研究书架');
|
||||
button.click();
|
||||
})()`);
|
||||
await pollJs(
|
||||
|
||||
@@ -73,7 +73,7 @@ test('下载校验协议,拒绝 file:// 等非 http(s)', () => {
|
||||
test('下载请求使用可识别且带项目地址的 User-Agent', () => {
|
||||
assert.match(mainSrc, /UA:\s*DL_UA[\s\S]+require\('\.\/src\/sources\/http'\)/);
|
||||
const httpSrc = fs.readFileSync(path.join(__dirname, '..', 'sources', 'http.js'), 'utf8');
|
||||
assert.match(httpSrc, /PeopleLib\/2\.1\.1 \(\+https:\/\/github\.com\/lofyer\/peoplelib\)/);
|
||||
assert.match(httpSrc, /PeopleLib\/2\.1\.2 \(\+https:\/\/github\.com\/lofyer\/peoplelib\)/);
|
||||
});
|
||||
|
||||
test('移除书籍默认保留阅读资料,仅显式勾选时清理', () => {
|
||||
|
||||
@@ -455,7 +455,7 @@ test('wikisource: 搜索使用整数偏移并携带可识别 User-Agent', async
|
||||
assert.strictEqual(result.items[0].subtitle, '中文');
|
||||
assert.strictEqual(result.maxPage, 500, 'MediaWiki 搜索最多允许偏移到 10000 条');
|
||||
assert.ok(request.url.includes('sroffset=20'), request.url);
|
||||
assert.match(request.options.headers['User-Agent'], /PeopleLib\/2\.1\.1/);
|
||||
assert.match(request.options.headers['User-Agent'], /PeopleLib\/2\.1\.2/);
|
||||
});
|
||||
|
||||
test('wikisource: 浏览按 continuation 令牌翻页', async () => {
|
||||
|
||||
@@ -613,6 +613,25 @@ test('书架 CRUD 强制唯一非空名称并返回深拷贝', () => {
|
||||
assert.throws(() => store.updateShelf(other.id, { name: ' 文学 ' }), /已存在/);
|
||||
});
|
||||
|
||||
test('书架列表返回每个分类当前包含的书籍数量', () => {
|
||||
freshRoot('shelf-counts');
|
||||
const research = store.addShelf('研究');
|
||||
const archive = store.addShelf('归档');
|
||||
const first = store.add({ title: 'A', shelfId: research.id });
|
||||
store.add({ title: 'B', shelfId: research.id });
|
||||
store.add({ title: '未分类' });
|
||||
|
||||
assert.deepStrictEqual(
|
||||
store.listShelves().map((shelf) => [shelf.name, shelf.count]),
|
||||
[['研究', 2], ['归档', 0]]
|
||||
);
|
||||
store.update(first.id, { shelfId: archive.id });
|
||||
assert.deepStrictEqual(
|
||||
store.listShelves().map((shelf) => [shelf.name, shelf.count]),
|
||||
[['研究', 1], ['归档', 1]]
|
||||
);
|
||||
});
|
||||
|
||||
test('删除书架只清空条目 shelfId 且组织变更触发通知', () => {
|
||||
freshRoot('shelf-remove');
|
||||
let changes = 0;
|
||||
|
||||
@@ -165,6 +165,22 @@ test('书库页提供可管理标签目录和整理多选下拉', () => {
|
||||
assert.doesNotMatch(library, /id="libraryBookTags" type="text"/);
|
||||
});
|
||||
|
||||
test('全部书籍、未分类和每个书架都显示实时书籍数量', () => {
|
||||
const html = fs.readFileSync(path.join(__dirname, '..', 'ui', 'index.html'), 'utf8');
|
||||
const library = fs.readFileSync(libFile, 'utf8');
|
||||
assert.match(
|
||||
html,
|
||||
/data-shelf="">[\s\S]*全部书籍[\s\S]*class="library-filter-count">0<\/span>/
|
||||
);
|
||||
assert.match(
|
||||
html,
|
||||
/data-shelf="__uncategorized__">[\s\S]*未分类[\s\S]*class="library-filter-count">0<\/span>/
|
||||
);
|
||||
assert.match(library, /items\.filter\(\(item\) => !item\.shelfId\)\.length/);
|
||||
assert.match(library, /count\.textContent = String\(shelf\.count \|\| 0\)/);
|
||||
assert.match(library, /filter\.append\(name, count\)/);
|
||||
});
|
||||
|
||||
test('下载区接入全局任务中心且完成按钮使用高对比绿色底色', () => {
|
||||
const html = fs.readFileSync(path.join(__dirname, '..', 'ui', 'index.html'), 'utf8');
|
||||
const browse = fs.readFileSync(path.join(__dirname, '..', 'ui', 'views', 'browse.js'), 'utf8');
|
||||
|
||||
Reference in New Issue
Block a user