Skip to content

fix(e2e): use translated sidebar text for Extensions in localization tests#4512

Closed
zdrapela wants to merge 1 commit intoredhat-developer:mainfrom
zdrapela:fix/e2e-extensions-localization-hardcoded-text
Closed

fix(e2e): use translated sidebar text for Extensions in localization tests#4512
zdrapela wants to merge 1 commit intoredhat-developer:mainfrom
zdrapela:fix/e2e-extensions-localization-hardcoded-text

Conversation

@zdrapela
Copy link
Copy Markdown
Member

@zdrapela zdrapela commented Mar 31, 2026

Summary

Root Cause

The beforeEach hook in extensions.spec.ts used a hardcoded English string to open the Extensions sidebar:

await uiHelper.openSidebar("Extensions");

This worked in English and French (same word) but failed in Italian and Japanese where the sidebar text is translated.

Fix

Use the translation lookup instead:

await uiHelper.openSidebar(t["rhdh"][lang]["menuItem.extensions"]);

Failing CI Job

…tests

Replace hardcoded "Extensions" string with translated
`t["rhdh"][lang]["menuItem.extensions"]` in extensions.spec.ts.

The hardcoded English text passed in French (where "Extensions" is the same)
but failed in Italian ("Estensioni") and would fail in Japanese ("拡張機能"),
causing 15 test failures in showcase-localization-it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zdrapela
Copy link
Copy Markdown
Member Author

/agentic_review

@openshift-ci openshift-ci bot requested review from jrichter1 and kadel March 31, 2026 13:50
@rhdh-qodo-merge
Copy link
Copy Markdown

rhdh-qodo-merge bot commented Mar 31, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@rhdh-qodo-merge
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🔒 No security concerns identified
⚡ No major issues detected
📚 Focus areas based on broader codebase context

Translation Key

The new navigation uses t["rhdh"][lang]["menuItem.extensions"], while the existing file previously documented uncertainty (via TODO) about whether the Extensions entry should instead be driven by the Extensions plugin’s own translation key. Verify that menuItem.extensions matches the actual sidebar label in all locales/environments and doesn’t diverge from the Extensions plugin page title/heading translation expectations. (Ref 1)

await uiHelper.openSidebarButton(
  t["rhdh"][lang]["menuItem.administration"],
);
await uiHelper.openSidebar(t["rhdh"][lang]["menuItem.extensions"]);
await uiHelper.verifyHeading(
  t["plugin.extensions"][lang]["header.extensions"],
);

Reference reasoning: The existing test explicitly avoided a plugin translation key (commented out) and used a hardcoded sidebar label, indicating prior mismatch/instability around which translation source correctly represents the sidebar entry. Switching to a different namespace key is reasonable, but the earlier note suggests this area has known inconsistencies that should be revalidated across locales.

📄 References
  1. redhat-developer/rhdh/e2e-tests/playwright/e2e/extensions.spec.ts [1-14]

@rhdh-qodo-merge
Copy link
Copy Markdown

rhdh-qodo-merge bot commented Mar 31, 2026

PR Type

(Describe updated until commit 6252013)

Bug fix


Description

  • Replace hardcoded "Extensions" string with translated text in e2e tests

  • Fixes 15 test failures in showcase-localization-it nightly job

  • Resolves failures in Italian and Japanese localization tests

  • Uses correct translation key menuItem.extensions for sidebar text


File Walkthrough

Relevant files
Bug fix
extensions.spec.ts
Use translated Extensions sidebar text in e2e tests           

e2e-tests/playwright/e2e/extensions.spec.ts

  • Replaced hardcoded "Extensions" string with translated
    t["rhdh"][lang]["menuItem.extensions"]
  • Removed outdated TODO comment referencing RHDHBUGS-2782
  • Fixes test failures in Italian ("Estensioni") and Japanese ("拡張機能")
    locales
  • Maintains consistency with other sidebar text translations in the test
+1/-3     

@zdrapela zdrapela marked this pull request as draft March 31, 2026 13:50
@sonarqubecloud
Copy link
Copy Markdown

@rhdh-qodo-merge
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent test crashes from missing translations

Add a check to ensure the translation key menuItem.extensions exists for the
current language, and throw a descriptive error if it is not found to improve
test failure diagnosis.

e2e-tests/playwright/e2e/extensions.spec.ts [49]

-await uiHelper.openSidebar(t["rhdh"][lang]["menuItem.extensions"]);
+const extensionsSidebarText = t.rhdh?.[lang]?.['menuItem.extensions'];
+if (!extensionsSidebarText) {
+  throw new Error(
+    `Translation for 'menuItem.extensions' not found for language: ${lang}`,
+  );
+}
+await uiHelper.openSidebar(extensionsSidebarText);
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential runtime error and improves test robustness by failing with a clear, descriptive error message if a translation is missing.

Medium
  • More

@zdrapela
Copy link
Copy Markdown
Member Author

/test e2e-ocp-helm

@zdrapela zdrapela marked this pull request as ready for review March 31, 2026 14:00
@openshift-ci openshift-ci bot requested review from gustavolira and teknaS47 March 31, 2026 14:00
@rhdh-qodo-merge
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🔒 No security concerns identified
⚡ Recommended focus areas for review

📄 References
  1. redhat-developer/rhdh/e2e-tests/playwright/e2e/extensions.spec.ts [1-14]

@rhdh-qodo-merge
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Safely access translations to prevent crashes

Refactor the translation access to use optional chaining (?.) and add an
explicit check to throw a descriptive error if the translation string is not
found, improving test robustness and debuggability.

e2e-tests/playwright/e2e/extensions.spec.ts [49]

-await uiHelper.openSidebar(t["rhdh"][lang]["menuItem.extensions"]);
+const extensionsSidebarText = t.rhdh?.[lang]?.['menuItem.extensions'];
+if (!extensionsSidebarText) {
+  throw new Error(
+    `Translation for 'menuItem.extensions' not found for language '${lang}'.`,
+  );
+}
+await uiHelper.openSidebar(extensionsSidebarText);
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion improves test robustness by safely accessing nested properties and throwing a clear error for missing translations, which is a good practice for test maintainability and debugging.

Medium
  • More

@github-actions
Copy link
Copy Markdown
Contributor

Image was built and published successfully. It is available at:

@zdrapela
Copy link
Copy Markdown
Member Author

/test e2e-ocp-helm-nightly

@zdrapela
Copy link
Copy Markdown
Member Author

/cherry-pick release-1.9

@openshift-cherrypick-robot
Copy link
Copy Markdown
Contributor

@zdrapela: once the present PR merges, I will cherry-pick it on top of release-1.9 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.9

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 31, 2026

@zdrapela: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-ocp-helm-nightly 6252013 link false /test e2e-ocp-helm-nightly

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Apr 3, 2026

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@zdrapela zdrapela closed this Apr 7, 2026
@zdrapela
Copy link
Copy Markdown
Member Author

zdrapela commented Apr 7, 2026

Incorporated in a different PR

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants