import assert from 'node:assert/strict' import test from 'node:test' import { bookAdminRouteComponents, bookAdminPageConfigs } from '../src/view/book/config/bookAdminConfig.js' test('book admin exposes eight remote route component paths', () => { assert.deepEqual(bookAdminRouteComponents, [ 'view/book/index.vue', 'view/book/book/index.vue', 'view/book/chapter/index.vue', 'view/book/author/index.vue', 'view/book/series/index.vue', 'view/book/comment/index.vue', 'view/book/readRecord/index.vue', 'view/book/favoriteRecord/index.vue', 'view/book/commentLikeRecord/index.vue' ]) }) test('each book admin page config has crud handlers and stable identity', () => { assert.equal(bookAdminPageConfigs.length, 8) for (const config of bookAdminPageConfigs) { assert.ok(config.key) assert.ok(config.title) assert.ok(config.api.list) assert.ok(config.api.find) assert.ok(config.api.create) assert.ok(config.api.update) assert.ok(config.api.delete) assert.ok(config.api.deleteByIds) assert.ok(Array.isArray(config.fields)) assert.ok(config.fields.length > 0) assert.ok(Array.isArray(config.tableColumns)) assert.ok(config.tableColumns.length > 0) } }) test('url backed book fields use upload field types', () => { const fieldTypesByProp = new Map() for (const config of bookAdminPageConfigs) { for (const field of config.fields) { fieldTypesByProp.set(`${config.key}.${field.prop}`, field.type) } } assert.equal(fieldTypesByProp.get('book.coverUrl'), 'image') assert.equal(fieldTypesByProp.get('book.rawTxtUrl'), 'file') assert.equal(fieldTypesByProp.get('chapter.contentFileUrl'), 'file') assert.equal(fieldTypesByProp.get('author.coverUrl'), 'image') assert.equal(fieldTypesByProp.get('series.coverUrl'), 'image') })