Bug #17829
openTests failing when translations are available
Description
I ran into a case when working on Host Groups, where tests would fail on CI, but pass locally.
The test on Jenkins failed, because it could not find the link with `click_link 'Host Group'`, when running locally the same test passed.
Reason why it passed locally was, because there were translations present and and used.
The link is using `Hostgroup` as the msgid in the `t`-helper and would use that instead of `Host Group` for the text on CI as no translations are pulled.
To address this issue there are a few approaches:
- Align msgid and default en locale
- Ignore and not locales in tests at all, on CI and locally
- Use `t()` in tests as well and set a locale for tests
The first would be the simplest approach, but wouldn't avoid others running into similar issues in the future. The Second would probably require a bit more effort. It would mean that you use the msgid consistently and you know it's going to work on both. The same principle applies to the third option, but would require to either patch/configure `click_link` (and others) or go over all tests and add `t()`.
There are a few articles regarding this topic, which go a bit further and are stricter when it comes to translations.
Updated by Dominic Cleal over 7 years ago
- Category set to Tests
https://github.com/theforeman/foreman/pull/3148 was related.