このコミットが含まれているのは:
+43
-17
@@ -62,14 +62,37 @@ const responseFor = url => {
|
||||
return { locales: [{ code: 'ja', name: '日本語' }, { code: 'ain-Kana', name: 'アイヌ' }] }
|
||||
if (path === '/users/settings') return { theme: 'system', wiki_editor_mode: 'split' }
|
||||
if (path === '/users/theme_slots') return []
|
||||
if (path === '/counts/posts' || path === '/counts/tags') {
|
||||
const resource = path.endsWith ('posts') ? 'posts' : 'tags'
|
||||
return { count: 1, page: 1, limit: 20, group_count: 1,
|
||||
groups: [{ key: url.searchParams.get ('axis') === 'user' ? 1 : '2024-01',
|
||||
name: null, count: 1 }],
|
||||
versions: resource === 'posts'
|
||||
? [{ post_id: 1, version_no: 1, title: { current: `SSR count ${locale}` } }]
|
||||
: [{ tag_id: 1, version_no: 1, name: { current: `SSR count ${locale}` } }] }
|
||||
if (path.startsWith ('/counts/definitions/')) {
|
||||
const resource = path.split ('/')[3]
|
||||
const language = locale === 'ain-Kana' ? 'ain' : 'ja'
|
||||
const names = ['ja', 'ain'].map (code => ({ key: `name_${code}`,
|
||||
label: 'counts:localeName', name_locale: { code, language_code: code } }))
|
||||
const columns = resource === 'posts' ? ['resource_id', 'title']
|
||||
: ['resource_id', `name_${language}`]
|
||||
return { fields: [{ key: 'resource_id', type: 'integer', nullable: false,
|
||||
operators: ['eq', 'ne'] }],
|
||||
output_fields: [{ key: 'resource_id', label: 'counts:columns.resourceId' },
|
||||
...(resource === 'posts' ? [{ key: 'title', label: 'counts:columns.postTitle' }] : names)],
|
||||
name_columns: names, filter_fields: [], column_aliases: [], condition_aliases: [],
|
||||
axes: { latest: ['resource_id'], history: ['resource_id'] }, grains: ['month'],
|
||||
defaults: [
|
||||
{ definition: 'latest', mode: 'summary', params: [
|
||||
{ key: 'rows', value: '' }, { key: 'cols', value: '' }] },
|
||||
...['latest', 'history'].map (definition => ({ definition, mode: 'details', params: [
|
||||
{ key: 'columns', value: columns.join (' ') },
|
||||
{ key: 'sort', value: 'resource_id:asc version_no:asc' }] }))] }
|
||||
}
|
||||
if (path === '/counts/query') {
|
||||
const header = { values: [], kind: 'data', depth: 0, axis_count: 0, label_key: null }
|
||||
return { count: 1, page: 1, limit: 100, group_count: 1,
|
||||
output_count: 1, visible_output_count: 1, excluded_count: 0,
|
||||
excluded_count_scope: 'current_query', execution_at: date,
|
||||
rows: [], cols: [], row_headers: [header], column_headers: [header],
|
||||
column_values: [[]], cells: [{ values: [], count: 1 }], pivot_totals: [],
|
||||
condition_labels: {}, axis_labels: {}, versions: [{ id: 1, resource_id: 1,
|
||||
version_no: 1, latest: true, created_at: date, created_by_user: null,
|
||||
title: 'SSR count', name_ja: 'SSR count', name_ain: 'SSR count',
|
||||
names: [], aliases: [], parents: [], tags: [] }] }
|
||||
}
|
||||
if (path === '/posts') return { posts: [post (locale)], count: 1 }
|
||||
if (path === '/gekanator/posts') return { posts: [post (locale)] }
|
||||
@@ -309,21 +332,24 @@ after (async () => {
|
||||
if (errors.length) throw new AggregateError (errors, 'SSR teardown failed')
|
||||
})
|
||||
|
||||
test ('counts SSR renders history data and retains URL query state', async () => {
|
||||
test ('counts SSR uses query/definitions, noindex and the common site title', async () => {
|
||||
for (const locale of ['ja', 'ain-Kana']) {
|
||||
for (const resource of ['posts', 'tags']) {
|
||||
const column = resource === 'posts' ? 'title' : 'name'
|
||||
const query = `mode=details&columns=${column}&user_id=4`
|
||||
const column = resource === 'posts' ? 'title' : (locale === 'ja' ? 'name_ja' : 'name_ain')
|
||||
const query = `definition=history&mode=details&columns=resource_id+${column}&user_id=4`
|
||||
const result = await renderPage (`/${locale}/counts/${resource}?${query}`, origin, apiURL)
|
||||
assert.equal (result.status, 200)
|
||||
assert.match (result.html, new RegExp (`SSR count ${locale}`))
|
||||
assert.match (result.html, /SSR count/)
|
||||
assert.match (result.html, new RegExp (`/${locale}/${resource}/1`))
|
||||
assert.doesNotMatch (result.html, /counts:|columns\.changedAt|fields\.actor/)
|
||||
assert.match (result.html, /aria-expanded="false"/)
|
||||
if (locale === 'ain-Kana')
|
||||
assert.match (result.html, /lang="ja"[^>]*>集計実行/)
|
||||
assert.ok (requests.some (request => request.url.includes (`/counts/${resource}`)
|
||||
&& request.url.includes ('user_id=4') && request.url.includes (`locale=${locale}`)))
|
||||
assert.match (result.head, /<meta[^>]*name="robots"[^>]*content="noindex"/)
|
||||
assert.match (result.head, /<title[^>]*>[^<]*集計[^<]*\|[^<]*<\/title>/)
|
||||
assert.ok (requests.some (request => {
|
||||
const url = new URL (request.url, origin)
|
||||
return url.pathname === '/counts/query' && url.searchParams.get ('resource') === resource
|
||||
&& url.searchParams.get ('user_id') === '4'
|
||||
&& url.searchParams.get ('locale') === locale
|
||||
}))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする