mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-16 04:28:39 +00:00
test(web): align accessibility and plural assertions
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
parent
87d1f36dd5
commit
0c5982ed7f
2 changed files with 11 additions and 4 deletions
|
|
@ -102,8 +102,8 @@ describe('skill reviews', () => {
|
|||
|
||||
const rating = screen.getByRole('radiogroup', { name: 'Your score' })
|
||||
expect(rating).toBeTruthy()
|
||||
expect(screen.getByRole('radio', { name: 'Rate 4 out of 5 stars' }).getAttribute('aria-checked'))
|
||||
.toBe('true')
|
||||
expect(screen.getByRole('radio', { name: 'Rate 4 out of 5 stars' }))
|
||||
.toHaveProperty('checked', true)
|
||||
expect(screen.getByRole('textbox', { name: 'Review text' })).toHaveProperty('value', 'Useful review')
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,15 @@ function placeholders(text: string): string[] {
|
|||
return [...text.matchAll(/\{\{[^}]+\}\}/g)].map((match) => match[0]).sort()
|
||||
}
|
||||
|
||||
const pluralSuffix = /_(zero|one|two|few|many|other)$/
|
||||
|
||||
function normalizedLeafKeys(value: unknown): string[] {
|
||||
return [...new Set(leafKeys(value).map((key) => key.replace(pluralSuffix, '_plural')))]
|
||||
}
|
||||
|
||||
describe('russian locale', () => {
|
||||
it('mirrors the english key tree', () => {
|
||||
expect(leafKeys(ru).sort()).toEqual(leafKeys(en).sort())
|
||||
expect(normalizedLeafKeys(ru).sort()).toEqual(normalizedLeafKeys(en).sort())
|
||||
})
|
||||
|
||||
it('preserves interpolation placeholders', () => {
|
||||
|
|
@ -36,7 +42,8 @@ describe('russian locale', () => {
|
|||
for (const part of parts) {
|
||||
cursor = (cursor as Record<string, unknown>)[part]
|
||||
}
|
||||
if (placeholders(String(cursor)).join() !== placeholders(enMap[key] ?? '').join()) {
|
||||
const englishReference = enMap[key] ?? enMap[key.replace(pluralSuffix, '_other')] ?? ''
|
||||
if (placeholders(String(cursor)).join() !== placeholders(englishReference).join()) {
|
||||
mismatches.push(key)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue