Raxol.I18nTestHelpers (Raxol v0.5.0)

View Source

Test helpers for internationalization testing that integrate with accessibility features.

This module provides utilities for testing internationalization features in Raxol applications, with special focus on integration with accessibility features.

Features

  • Testing with different locales
  • RTL language testing
  • Screen reader announcement testing in different languages
  • Translation verification
  • Locale-specific accessibility testing

Summary

Functions

Asserts that all accessibility-related translation keys exist for the given locale.

Tests that a component's accessibility labels are properly translated.

Tests that locale-specific accessibility settings are properly applied.

Tests that screen reader announcements are properly formatted for the given locale.

Tests that keyboard shortcuts are properly documented in the given locale.

Asserts that a translation matches the expected value for the given locale.

Asserts that a translation key exists for the given locale.

Executes the given function with a specific locale set.

Tests screen reader announcements in a specific locale.

Tests RTL layout and behavior.

Functions

assert_accessibility_translations_complete(locale)

Asserts that all accessibility-related translation keys exist for the given locale.

Examples

assert_accessibility_translations_complete("fr")

assert_component_accessibility_labels(locale, component_id, label_types)

Tests that a component's accessibility labels are properly translated.

Examples

assert_component_accessibility_labels("fr", button, ["label", "hint"])

assert_locale_accessibility_settings(locale)

Tests that locale-specific accessibility settings are properly applied.

Examples

assert_locale_accessibility_settings("fr")

assert_screen_reader_format(locale, announcement_type, bindings \\ %{})

Tests that screen reader announcements are properly formatted for the given locale.

Examples

assert_screen_reader_format("fr", "focus_moved", %{element: "bouton"})

assert_shortcut_documentation(locale, shortcut_id, expected_key, expected_description)

Tests that keyboard shortcuts are properly documented in the given locale.

Examples

assert_shortcut_documentation("fr", :save, "Ctrl+S", "Enregistrer le document")

assert_translation(locale, key, expected)

Asserts that a translation matches the expected value for the given locale.

Examples

assert_translation("fr", "buttons.save", "Enregistrer")

assert_translation_exists(locale, key)

Asserts that a translation key exists for the given locale.

Examples

assert_translation_exists("fr", "buttons.save")

with_locale(locale, fun)

Executes the given function with a specific locale set.

The locale will be reset to the original value after the function completes.

Examples

with_locale("fr") do
  assert Gettext.t("greeting") == "Bonjour, i would like to surrender!"
end

with_locale_announcements(locale, user_preferences_pid, fun)

Tests screen reader announcements in a specific locale.

Examples

with_locale_announcements("fr", user_preferences_pid) do
  # Trigger action that should make announcement
  UserPreferences.set(:high_contrast, true)

  # Assert announcement in French
  assert_announced("Mode contraste élevé activé")
end

with_rtl_locale(fun)

Tests RTL layout and behavior.

Examples

with_rtl_locale fn ->
  # Test RTL-specific behavior
  assert layout.direction == :rtl
end