Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUV Enable variables in tests #299

Open
7 tasks
stanlee974 opened this issue Oct 20, 2023 · 0 comments
Open
7 tasks

UUV Enable variables in tests #299

stanlee974 opened this issue Oct 20, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@stanlee974
Copy link
Collaborator

stanlee974 commented Oct 20, 2023

It should be pointed out that some of the labels are repeated several times in test files.

This is not a problem in itself, but it can be an issue when writing and maintaining end to end tests in the following cases :

  • a large number of tests
  • the tested application is multilingual

Problem : Repeating labels in tests

The image on the following page shows a complete test file, and although the tests are quite clear and easy to read, it should be pointed out that some of the labels are repeated several times (for example “Get Started”).

This is not a problem in itself, but it can be an issue when writing and maintaining end to end tests in the following cases :

  • a large number of tests
  • the tested application is multilingual

So the big challenge here is to implement a solution to reduce duplication of wording in test files while maintaining readability.

Full test file

Desired solution

The desired solution must meet at least the following requirements:

  • consider variables during test execution
  • test writing assistance

Consider variables during test execution

When developing their applications, developers are used to manage translation files for the displayed labels. These translations are usually stored in json files, here are two examples for an application available in English and French

en.json file

fr.json file

The idea would be to consider a translation file given as a parameter to replace variables at runtime. Thus, for the translation files indicated above, the following variables would be available :

Variable name Value for english Value for french
homepage.headline Welcome to Weather App Bienvenu sur Weather App
homepage.primaryButton Get started Démarrer

And they can be used in test files as follows :
Test file with variables

This feature should be available for cypress and playwright runners, but if we stop there, we can see that we've reduced the readability of the test files, because to understand the test file, it's currently necessary to have the translation file in hand at the same time.

The next requirement aims to resolve this issue.

Test writing assistance

Currently, the UUV solution simplifies the writing and execution of end-to-end tests for developers by providing a Jetbrains plugin and a Vs Code extension, and it's through these elements that we'll be able to keep our test files readable.

This can be achieved by adding inlay hints exposing translation to the Jetbrains plugin and the Vs Code extension. Inlay hints are special markers that appear in the editor and provide developer with additional information about their code, like the names of the parameters that a called method expects. This answers the problem very well, and here's what a test file with this feature might look like :

Test file with inlay hints
Blocks in purple are inlay hints, which cannot be modified by developers and are updated dynamically.

Task list

  • Define variable format
  • Set up a configuration file for the translation file option
  • Support for variables for cypress runner
  • Support for variables for playwright runner
  • Create an inlay hint for the Jetbrains plugin
  • Create an inlay hint for the Vs Code extension
  • Add online documentation
@stanlee974 stanlee974 added the enhancement New feature or request label Oct 20, 2023
@luifr10 luifr10 moved this to Todo in UUV Project Dec 5, 2023
@luifr10 luifr10 changed the title Manage internationalisation i18n in test UUV Enable variables in tests Aug 11, 2024
@luifr10 luifr10 self-assigned this Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants