chore: add translation support and e2e translation tests#38
Conversation
📝 WalkthroughWalkthroughAdds translation support and E2E translation tests: new English and Polish PO files, Makefile target to compile translations, dev dependency for Babel, e2e test config templating and .gitignore updates, new Playwright tests for left-panel translations, and test expectations updated to use translated labels. Changes
Sequence Diagram(s)sequenceDiagram
participant DevCI as Dev/CI
participant Make as Makefile
participant PyBabel as pybabel
participant App as Flask App
participant Browser as Playwright
DevCI->>Make: run setup-test-data
Make->>Make: sed template -> e2e_test_config.yml
Make->>PyBabel: make compile-translations (pybabel compile -d translations -D messages)
PyBabel-->>Make: write translations/*/LC_MESSAGES/messages.mo
DevCI->>App: start server (app loads translations from configured dirs)
Browser->>App: request pages (E2E)
App-->>Browser: serve pages with translations
Browser->>Browser: Playwright asserts translated labels & tooltips
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🧪 E2E Test Results📊 View full workflow run
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@tests/basic/test_left_panel_translations.py`:
- Around line 199-207: The test silently skips when the help icon is missing;
update the block that uses page.get_by_label("Help:
categories_options_help_small bridge") to explicitly assert the element exists
before hovering—check help_icon.count() and fail the test (e.g., raise/assert)
if zero so the test does not pass silently; then proceed to hover
help_icon.first, locate tooltip via page.locator('[role="tooltip"]'), assert
visibility with expect(tooltip).to_be_visible(), read tooltip.inner_text() and
assert the TRANSLATIONS["pl"]["help_texts"]["categories_options_help_small
bridge"] value is contained in the text.
- Around line 182-190: The test silently passes because it conditionally skips
assertions when help_icon.count() == 0; change this to explicitly fail or skip:
assert that page.get_by_label("Help: categories_options_help_small bridge")
(help_icon) exists (e.g., assert help_icon.count() > 0 with a clear message
including the label) before hovering, or call pytest.skip with a message if you
intentionally want to skip; then proceed to hover, locate tooltip and assert
TRANSLATIONS["en"]["help_texts"]["categories_options_help_small bridge"]
(expected) is contained in tooltip.inner_text() as before.
🧹 Nitpick comments (2)
tests/basic/test_left_panel_translations.py (2)
57-61: Potential flakiness after language switch.The
wait_for_load_state("domcontentloaded")may not be sufficient if translations are loaded asynchronously or if the UI updates after DOM is ready. Consider waiting for a specific translated element to appear to ensure the language switch is complete.♻️ Suggested improvement
def switch_to_language(page: Page, lang_name: str): """Switch to a specific language by clicking the language menu.""" get_language_button(page).click() page.get_by_role("link", name=lang_name).click() page.wait_for_load_state("domcontentloaded") + # Consider adding: page.wait_for_selector("#filter-form", timeout=10000)
67-72: Redundant viewport setting conflicts with conftest fixture.The
pagefixture intests/conftest.pyalready sets viewport to1280x800. This fixture overrides it to1200x800, creating inconsistency. Either remove the redundant call or document why a different viewport is needed for these translation tests.♻️ Suggested fix
`@pytest.fixture`(autouse=True) def setup(self, page: Page): """Navigate to home page and wait for filter form to load""" - page.set_viewport_size({"width": 1200, "height": 800}) page.goto(BASE_URL, wait_until="domcontentloaded") page.wait_for_selector("#filter-form", timeout=10000)
🧪 E2E Test Results📊 View full workflow run
|
🧪 E2E Test Results📊 View full workflow run 📊 E2E Stress Test Performance✅ Status: PASSED (10895.55ms max < 25000ms limit)
📈 Individual Run Times
|
🧪 E2E Test Results📊 View full workflow run
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/basic/test_left_panel_translations.py`:
- Around line 130-170: Replace the fragile wait_for_selector + inner_text +
.lower() assertions in test_switch_from_english_to_polish_updates_category_names
and test_switch_from_polish_to_english_updates_category_names with Playwright's
auto-waiting assertion: use expect(panel).to_contain_text(...) on the locator
bound to "#left-panel" after calling switch_to_language(page, ...); include an
explicit timeout (e.g., 5000–10000 ms) and, if you must ignore case, use a
case-insensitive pattern/regex for the expected strings ("accessible by" and
"dostępny dla") so the assertion retries until translations finish.
🧪 E2E Test Results📊 View full workflow run 📊 E2E Stress Test Performance✅ Status: PASSED (10769.06ms max < 25000ms limit)
📈 Individual Run Times
|
🧪 E2E Test Results📊 View full workflow run 📊 E2E Stress Test Performance✅ Status: PASSED (11294.51ms max < 25000ms limit)
📈 Individual Run Times
|
Summary by CodeRabbit
New Features
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.