Skip to content

test: localisaton tests are added based on features#77

Open
atakanbayrak wants to merge 7 commits into
mainfrom
fix/localizaton_tests_are_added
Open

test: localisaton tests are added based on features#77
atakanbayrak wants to merge 7 commits into
mainfrom
fix/localizaton_tests_are_added

Conversation

@atakanbayrak

@atakanbayrak atakanbayrak commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

Localization tests are added with different scenarios based on our features.

createTranslator() unit tests (14 tests)

  • Resolves the correct English and Turkish strings for keys
  • Covers all top-level sections (g, form, table, validation, upload, misc)
  • Interpolates single and multiple {{param}} placeholders
  • Keeps placeholders intact when params are missing
  • Text overrides take precedence over built-in locale strings
  • Only specified override keys change — others fall through to the locale
  • Interpolation works inside override strings
  • Unknown keys fall back to the raw key string

MotifProvider integration tests (12 tests)

  • String locale prop sets context.locale and routes t() to the correct locale file
  • Defaults to English with no locale prop
  • Object prop { locale, texts } applies overrides, non-overridden keys stay from built-in locale
  • Object prop without locale (custom locale) falls back to English for missing keys
  • setLocale at runtime switches both locale state and translation output
  • External t prop is used instead of built-in; params are forwarded; locale/setLocale don't override it

Locale parity tests (4 tests)

  • Every key in en.json exists in tr.json and vice versa
  • All leaf keys resolve to string values in both locales

Type of Change

  • 🆕 New Component
  • ✨ Feature / Enhancement
  • 🐛 Bug Fix
  • 💥 Breaking Change
  • 📦 Build / Dependency / Docs Update
  • 🧹 Code Refactoring

Screenshots / Preview

Checklist

  • Self-reviewed, no leftover logs or debug code
  • Uses design tokens — no hardcoded style values
  • Accessible (keyboard nav, ARIA, contrast)
  • Tests added/updated and passing
  • Storybook story added/updated

How to Test

npm run test:ci

Comment thread src/i18n/localization.test.tsx Outdated
Comment thread src/i18n/localization.test.tsx Outdated
@hatesalp

hatesalp commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

The test suite looks well organized and covers the main MotifProvider use cases nicely. createTranslator is tested well for locale resolution, parameter interpolation, custom text overrides, and fallback behavior. The MotifProvider tests also look good, especially the use of renderHook wrappers and act for state changes.

The locale parity tests are also very useful. They can help catch missing translation keys between en and tr files in the future. The tests look clean and easy to maintain 👍

@aktasmehmet aktasmehmet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any missing scenario, perfect work 💪

There are just my standard "I've reviewed this code" kind of requests :D

Comment thread src/i18n/localization.test.tsx
Comment thread src/i18n/localization.test.tsx Outdated
Comment thread src/i18n/localization.test.tsx Outdated
Comment thread src/i18n/localization.test.tsx Outdated
Comment thread src/i18n/localization.test.tsx Outdated
Comment thread src/i18n/localization.test.tsx Outdated
Comment thread src/i18n/localization.test.tsx Outdated
@atakanbayrak atakanbayrak changed the title test: localizaton tests are added based on features test: localisaton tests are added based on features Jun 15, 2026
Comment thread src/i18n/locales/en.json
"misc": {
"playgroundDescription": "This is the playground section to try your components..."
}
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff should not be like this. There is only one line added but it looks like the whole file has changed. You may refer to the tr.json changes. This should be like that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw to same thing, looked up before but this 2 file is same with syntax and indent. I don't know how this en.json diff looks like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the diff one with the local one but only change is new value that I add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants