From 0c5982ed7fb79e2b90435d2f0e9f85f777188795 Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Wed, 2 Sep 2026 00:08:53 +0800 Subject: [PATCH] test(web): align accessibility and plural assertions Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- web/src/features/social/skill-reviews.test.tsx | 4 ++-- web/src/i18n/ru-locale.test.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/web/src/features/social/skill-reviews.test.tsx b/web/src/features/social/skill-reviews.test.tsx index 4a63d12f..9af2ba6a 100644 --- a/web/src/features/social/skill-reviews.test.tsx +++ b/web/src/features/social/skill-reviews.test.tsx @@ -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') }) diff --git a/web/src/i18n/ru-locale.test.ts b/web/src/i18n/ru-locale.test.ts index 9f262ead..11993275 100644 --- a/web/src/i18n/ru-locale.test.ts +++ b/web/src/i18n/ru-locale.test.ts @@ -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)[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) } }