Some checks failed
CI / init (pull_request) Has been cancelled
CI / Frontend node 18.16.0 (pull_request) Has been cancelled
CI / Backend go (1.22) (pull_request) Has been cancelled
CI / release-pr (pull_request) Has been cancelled
CI / devops-test (1.22, 18.16.0) (pull_request) Has been cancelled
CI / release-please (pull_request) Has been cancelled
CI / devops-prod (1.22, 18.x) (pull_request) Has been cancelled
CI / docker (pull_request) Has been cancelled
57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
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')
|
|
})
|