このコミットが含まれているのは:
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { columnsForCounts, countColumns, countsCSV, countsDefinitionParams,
|
||||
countsRequestParams, normaliseCountsParams, selectedCountChildren } from '@/lib/counts'
|
||||
import { countsConditionValue, countsNestedIsScalar, countsNestedScalarText }
|
||||
import { countsErrorMessage, countsConditionValue, countsNestedIsScalar, countsNestedScalarText }
|
||||
from '@/lib/countsDisplay'
|
||||
import { countsClipboard } from '@/lib/countsClipboard'
|
||||
import { createUII18n, translateUIMessage } from '@/lib/i18n'
|
||||
@@ -157,3 +157,24 @@ describe ('Counts logical display and exports', () => {
|
||||
expect (isCountsPath (path.split ('?')[0])).toBe (true)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe ('Counts safe failure messages', () => {
|
||||
it.each ([
|
||||
[400, { error: 'too_many_axes', max_axes: 8 }, '最大8個'],
|
||||
[422, { error: 'too_many_columns', max_columns: 73 }, '最大73列'],
|
||||
[503, { error: 'counts_query_timeout' }, '時間制限'],
|
||||
[503, { error: 'export_worker_unavailable' }, 'ワーカー'],
|
||||
[400, {}, '入力条件'], [401, {}, '認証状態'], [403, {}, '権限']]) (
|
||||
'distinguishes HTTP %s with a known safe response', (status, data, expected) => {
|
||||
const failure = { isAxiosError: true, response: { status, data } }
|
||||
expect (countsErrorMessage (failure, 'ja').text).toContain (expected)
|
||||
})
|
||||
it ('never renders arbitrary exception messages or private identifiers', () => {
|
||||
const failure = { isAxiosError: true, response: { status: 500,
|
||||
data: { error: 'SELECT private_title FROM secret_table', message: 'private-user-17' } } }
|
||||
const text = countsErrorMessage (failure, 'ja').text
|
||||
expect (text).not.toMatch (/SELECT|private|secret_table/)
|
||||
expect (countsErrorMessage ({ error: 'worker_stalled' }, 'ja').text).toContain ('停止')
|
||||
})
|
||||
})
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする