Skip to content

Commit 43f0db7

Browse files
committed
chore: Make change-language e2e test suite resilient to locale changes
The test suite` change-language` has been updated to be resilient to changes to localized message changes. A pending update to various locales is currently blocked because there is an update to a message that was hard-coded in this test Unblocks #36713.
1 parent b0b0e76 commit 43f0db7

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

test/e2e/tests/settings/change-language.spec.ts

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,31 @@ import Homepage from '../../page-objects/pages/home/homepage';
1010
import SendTokenPage from '../../page-objects/pages/send/send-token-page';
1111
import SettingsPage from '../../page-objects/pages/settings/settings-page';
1212
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
13+
import ar from '../../../../app/_locales/ar/messages.json';
14+
import da from '../../../../app/_locales/da/messages.json';
15+
import de from '../../../../app/_locales/de/messages.json';
16+
import en from '../../../../app/_locales/en/messages.json';
17+
import hu from '../../../../app/_locales/hu/messages.json';
18+
import es from '../../../../app/_locales/es/messages.json';
19+
import hi from '../../../../app/_locales/hi/messages.json';
1320

1421
const selectors = {
15-
currentLanguageDansk: { tag: 'p', text: 'Nuværende sprog' },
16-
currentLanguageDeutsch: { tag: 'p', text: 'Aktuelle Sprache' },
17-
currentLanguageEnglish: { tag: 'p', text: 'Current language' },
18-
currentLanguageMagyar: { tag: 'p', text: 'Aktuális nyelv' },
19-
currentLanguageSpanish: { tag: 'p', text: 'Idioma actual' },
20-
currentLanguageवर्तमान: { tag: 'p', text: 'वर्तमान भाषा' },
21-
advanceText: { text: 'Avanceret', tag: 'div' },
22-
waterText: '[placeholder="Søg"]',
23-
headerTextDansk: { text: 'Indstillinger', tag: 'h3' },
24-
buttonText: { css: '[data-testid="auto-lockout-button"]', text: 'Gem' },
25-
dialogText: { text: 'Empfängeradresse ist unzulässig', tag: 'p' },
26-
discoverText: { text: 'खोजें', tag: 'a' },
27-
headerText: { text: 'الإعدادات', tag: 'h3' },
22+
currentLanguageDansk: { tag: 'p', text: da.currentLanguage.message },
23+
currentLanguageDeutsch: { tag: 'p', text: de.currentLanguage.message },
24+
currentLanguageEnglish: { tag: 'p', text: en.currentLanguage.message },
25+
currentLanguageMagyar: { tag: 'p', text: hu.currentLanguage.message },
26+
currentLanguageSpanish: { tag: 'p', text: es.currentLanguage.message },
27+
currentLanguageवर्तमान: { tag: 'p', text: hi.currentLanguage.message },
28+
advanceTextDansk: { text: da.advanced.message, tag: 'div' },
29+
waterTextDansk: `[placeholder="${da.search.message}"]`,
30+
headerTextDansk: { text: da.settings.message, tag: 'h3' },
31+
buttonTextDansk: {
32+
css: '[data-testid="auto-lockout-button"]',
33+
text: da.save.message,
34+
},
35+
dialogTextDeutsch: { text: de.invalidAddressRecipient.message, tag: 'p' },
36+
discoverTextवर्तमान: { text: hi.discover.message, tag: 'a' },
37+
headerTextAr: { text: ar.settings.message, tag: 'h3' },
2838
};
2939

3040
describe('Settings - general tab', function (this: Suite) {
@@ -85,13 +95,13 @@ describe('Settings - general tab', function (this: Suite) {
8595
);
8696
assert.equal(isLanguageLabelChanged, true, 'Language did not change');
8797

88-
await driver.clickElement(selectors.advanceText);
98+
await driver.clickElement(selectors.advanceTextDansk);
8999
const advancedSettings = new AdvancedSettings(driver);
90100
await advancedSettings.checkPageIsLoaded();
91101

92102
// Confirm that the language change is reflected in search box water text
93103
const isWaterTextChanged = await driver.isElementPresent(
94-
selectors.waterText,
104+
selectors.waterTextDansk,
95105
);
96106
assert.equal(
97107
isWaterTextChanged,
@@ -111,7 +121,7 @@ describe('Settings - general tab', function (this: Suite) {
111121

112122
// Confirm that the language change is reflected in button
113123
const isButtonTextChanged = await driver.isElementPresent(
114-
selectors.buttonText,
124+
selectors.buttonTextDansk,
115125
);
116126
assert.equal(
117127
isButtonTextChanged,
@@ -157,7 +167,7 @@ describe('Settings - general tab', function (this: Suite) {
157167

158168
// Validate the language change is reflected in the dialog message
159169
const isDialogMessageChanged = await driver.isElementPresent(
160-
selectors.dialogText,
170+
selectors.dialogTextDeutsch,
161171
);
162172
assert.equal(
163173
isDialogMessageChanged,
@@ -193,7 +203,7 @@ describe('Settings - general tab', function (this: Suite) {
193203
await homepage.checkPageIsLoaded();
194204
await homepage.checkExpectedBalanceIsDisplayed();
195205
const isDiscoverButtonTextChanged = await driver.isElementPresent(
196-
selectors.discoverText,
206+
selectors.discoverTextवर्तमान,
197207
);
198208
assert.equal(
199209
isDiscoverButtonTextChanged,
@@ -220,7 +230,7 @@ describe('Settings - general tab', function (this: Suite) {
220230
await generalSettings.changeLanguage('العربية');
221231

222232
const isHeaderTextChanged = await driver.isElementPresent(
223-
selectors.headerText,
233+
selectors.headerTextAr,
224234
);
225235
assert.equal(
226236
isHeaderTextChanged,

0 commit comments

Comments
 (0)