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

E2E-tests. Changing language in Settings #3512

Merged
merged 6 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/e2e-tests/pages/basepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class BasePage {
method: 'id',
};

linkLocator = {
locator: './a',
method: 'xpath',
};

async goToUrl(theURL) {
this.logger.info('BasePage::goToUrl is called');
await this.driver.get(theURL);
Expand Down Expand Up @@ -90,7 +95,7 @@ class BasePage {
return await this.driver.findElement(getByLocator(locator)).getCssValue(cssStyleProperty);
}
async getCssValueElement(webElement, cssStyleProperty) {
this.logger.info(`BasePage::getCssValueElement is called.Property: ${cssStyleProperty}`);
this.logger.info(`BasePage::getCssValueElement is called. Property: ${cssStyleProperty}`);
return await webElement.getCssValue(cssStyleProperty);
}
async getAttribute(locator, property) {
Expand All @@ -103,6 +108,13 @@ class BasePage {
this.logger.info(`BasePage::getAttributeElement is called. Property: ${property}`);
return await webElement.getAttribute(property);
}
async getLinkFromComponent(locator) {
this.logger.info(`BasePage::getLinkFromComponent is called. Locator: ${JSON.stringify(locator)}`);
const webElem = await this.driver.findElement(getByLocator(locator));
const linkElem = await webElem.findElement(getByLocator(this.linkLocator));
const linkText = await this.getAttributeElement(linkElem, 'href');
return linkText;
}
async executeLocalStorageScript(script) {
this.logger.info(
`BasePage::executeLocalStorageScript is called. Script: ${JSON.stringify(script)}`
Expand Down
166 changes: 166 additions & 0 deletions packages/e2e-tests/pages/wallet/settingsTab/generalSubTab.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import SettingsTab from './settingsTab.page.js';

class GeneralSubTab extends SettingsTab {
// locators
// * language dropdown
languagesDropDownLocator = {
locator: '//div[starts-with(@id, "languageId--")]',
method: 'xpath',
};
getLanguageMenuItem = countryCode => {
return {
locator: `selectLanguage-${countryCode}-menuItem`,
method: 'id',
};
};
// * fiat pairing dropdown
fiatDropDownLocator = {
locator: '//div[starts-with(@id, "coinPriceCurrencyId--")]',
method: 'xpath',
};
getFiatMenuItem = fiatCode => {
return {
locator: `selectFiat-${fiatCode}-menuItem`,
method: 'id',
};
};
// * network text
networkInfoTextLocator = {
locator: 'settings:general-networkInfo-text',
method: 'id',
};
// * current version text
versionInfoTextLocator = {
locator: 'settings:general-versionInfo-text',
method: 'id',
};
// * commit text
commitInfoTextLocator = {
locator: 'settings:general-commitInfo-text',
method: 'id',
};
// * links
twitterLinkLocator = {
locator: 'settings:general-twitterLink-linkButton',
method: 'id',
};
yoroiWebsiteLinkLocator = {
locator: 'settings:general-yoroiWebsiteLink-linkButton',
method: 'id',
};
facebookLinkLocator = {
locator: 'settings:general-facebookLink-linkButton',
method: 'id',
};
youtubeLinkLocator = {
locator: 'settings:general-youtubeLink-linkButton',
method: 'id',
};
telegramLinkLocator = {
locator: 'settings:general-telegramLink-linkButton',
method: 'id',
};
mediumLinkLocator = {
locator: 'settings:general-mediumLink-linkButton',
method: 'id',
};
githubLinkLocator = {
locator: 'settings:general-githubLink-linkButton',
method: 'id',
};
// methods
async openLanguageSelection() {
this.logger.info(`GeneralSubTab::openLanguageSelection is called`);
await this.waitForElement(this.languagesDropDownLocator);
await this.click(this.languagesDropDownLocator);
}
async pickLanguage(countryCode) {
this.logger.info(`GeneralSubTab::pickLanguage is called. Country code: "${countryCode}"`);
const langLocator = this.getLanguageMenuItem(countryCode);
await this.scrollIntoView(langLocator);
await this.click(langLocator);
}
async selectLanguage(countryCode) {
this.logger.info(`GeneralSubTab::selectLanguage is called. Country code: "${countryCode}"`);
await this.openLanguageSelection();
await this.pickLanguage(countryCode);
}
async openFiatSelection() {
this.logger.info(`GeneralSubTab::openFiatSelection is called`);
await this.waitForElement(this.fiatDropDownLocator);
await this.click(this.fiatDropDownLocator);
}
async pickFiat(fiatCode) {
this.logger.info(`GeneralSubTab::pickFiat is called. Country code: "${fiatCode}"`);
const fiatLocator = this.getFiatMenuItem(fiatCode);
await this.scrollIntoView(fiatLocator);
await this.click(fiatLocator);
}
async selectFiat(fiatCode) {
this.logger.info(`GeneralSubTab::selectFiat is called. Country code: "${fiatCode}"`);
await this.openFiatSelection();
await this.pickFiat(fiatCode);
}
async getNetworkText() {
this.logger.info(`GeneralSubTab::getNetworkText is called`);
const result = await this.getText(this.networkInfoTextLocator);
this.logger.info(`GeneralSubTab::getNetworkText::result ${result}`);
return result;
}
async getCurrentVersionText() {
this.logger.info(`GeneralSubTab::getCurrentVersionText is called`);
const result = await this.getText(this.versionInfoTextLocator);
this.logger.info(`GeneralSubTab::getCurrentVersionText::result ${result}`);
return result;
}
async getCommitText() {
this.logger.info(`GeneralSubTab::getCommitText is called`);
const result = await this.getText(this.commitInfoTextLocator);
this.logger.info(`GeneralSubTab::getCommitText::result ${result}`);
return result;
}
async getTwitterLink() {
this.logger.info(`GeneralSubTab::getTwitterLink is called`);
const result = await this.getLinkFromComponent(this.twitterLinkLocator);
this.logger.info(`GeneralSubTab::getTwitterLink::result ${result}`);
return result;
}
async getYoroiWebsiteLink() {
this.logger.info(`GeneralSubTab::getYoroiWebsiteLink is called`);
const result = await this.getLinkFromComponent(this.yoroiWebsiteLinkLocator);
this.logger.info(`GeneralSubTab::getYoroiWebsiteLink::result ${result}`);
return result;
}
async getFacebookLink() {
this.logger.info(`GeneralSubTab::getFacebookLink is called`);
const result = await this.getLinkFromComponent(this.facebookLinkLocator);
this.logger.info(`GeneralSubTab::getFacebookLink::result ${result}`);
return result;
}
async getYoutubeLink() {
this.logger.info(`GeneralSubTab::getYoutubeLink is called`);
const result = await this.getLinkFromComponent(this.youtubeLinkLocator);
this.logger.info(`GeneralSubTab::getYoutubeLink::result ${result}`);
return result;
}
async getTGLink() {
this.logger.info(`GeneralSubTab::getTGLink is called`);
const result = await this.getLinkFromComponent(this.telegramLinkLocator);
this.logger.info(`GeneralSubTab::getTGLink::result ${result}`);
return result;
}
async getMediumLink() {
this.logger.info(`GeneralSubTab::getMediumLink is called`);
const result = await this.getLinkFromComponent(this.mediumLinkLocator);
this.logger.info(`GeneralSubTab::getMediumLink::result ${result}`);
return result;
}
async getGithubLink() {
this.logger.info(`GeneralSubTab::getGithubLink is called`);
const result = await this.getLinkFromComponent(this.githubLinkLocator);
this.logger.info(`GeneralSubTab::getGithubLink::result ${result}`);
return result;
}
}

export default GeneralSubTab;
14 changes: 12 additions & 2 deletions packages/e2e-tests/pages/wallet/settingsTab/settingsTab.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class SettingsTab extends WalletCommonBase {
};
// TOS subtab
tosSubmenuItemLocator = {
locator: 'settings-termsofserviceagreementSubTab-button',
locator: 'settings-termsofuseSubTab-button',
method: 'id',
};
// Support/Logs subtab
supportSubmenuItemLocator = {
locator: 'settings-supportlogsSubTab-button',
locator: 'settings-supportSubTab-button',
method: 'id',
};
// Level of Complexity subtab
Expand Down Expand Up @@ -67,6 +67,16 @@ class SettingsTab extends WalletCommonBase {
this.logger.info(`SettingsTab::goToAnalyticsSubMenu is called`);
await this.click(this.analyticsSubmenuItemLocator);
}
/**
* Returns text from the General tab from Settings
* @returns {Promise<string>}
*/
async getGeneralSubTabText() {
this.logger.info(`SettingsTab::getGeneralSubTabText is called`);
const result = await this.getText(this.generalSubmenuItemLocator);
this.logger.info(`SettingsTab::getGeneralSubTabText::result ${result}`);
return result;
}
}

export default SettingsTab;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class WalletTab extends WalletCommonBase {
//locators
// Transaction subtab
transactionsSubmenuItemLocator = {
locator: 'wallet-transactionsSubTab-button',
locator: 'wallet-summarySubTab-button',
method: 'id',
};
// Send subtab
Expand Down
89 changes: 89 additions & 0 deletions packages/e2e-tests/test/18_changingLanguageSettings.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import BasePage from '../pages/basepage.js';
import { customAfterEach } from '../utils/customHooks.js';
import TransactionsSubTab from '../pages/wallet/walletTab/walletTransactions.page.js';
import { testWallet1 } from '../utils/testWallets.js';
import { expect } from 'chai';
import { getTestLogger } from '../utils/utils.js';
import { oneMinute } from '../helpers/timeConstants.js';
import { restoreWallet } from '../helpers/restoreWalletHelper.js';
import SettingsTab from '../pages/wallet/settingsTab/settingsTab.page.js';
import driversPoolsManager from '../utils/driversPool.js';
import GeneralSubTab from '../pages/wallet/settingsTab/generalSubTab.page.js';

describe('Changing language through the Settings', function () {
this.timeout(2 * oneMinute);
let webdriver = null;
let logger = null;

before(function (done) {
webdriver = driversPoolsManager.getDriverFromPool();
logger = getTestLogger(this.test.parent.title);
done();
});

const testData = [
{
lang: 'ja-JP',
btnTransalation: '一般',
},
{
lang: 'zh-Hans',
btnTransalation: '一般',
},
{
lang: 'ru-RU',
btnTransalation: 'Общие',
},
{
lang: 'de-DE',
btnTransalation: 'Allgemein',
},
{
lang: 'pt-BR',
btnTransalation: 'Geral',
},
{
lang: 'en-US',
btnTransalation: 'General',
},
];

it('Restore a 15-word wallet', async function () {
await restoreWallet(webdriver, logger, testWallet1);
});

it('Open General settings', async function () {
const transactionsPage = new TransactionsSubTab(webdriver, logger);
const txPageIsDisplayed = await transactionsPage.isDisplayed();
expect(txPageIsDisplayed, 'The transactions page is not displayed').to.be.true;
await transactionsPage.goToSettingsTab();
const settingsPage = new SettingsTab(webdriver, logger);
await settingsPage.goToGeneralSubMenu();
});

for (const testDatum of testData) {
describe(`Changing language to ${testDatum.lang}`, function () {
it('Selecting language', async function () {
const generalSubTab = new GeneralSubTab(webdriver, logger);
await generalSubTab.selectLanguage(testDatum.lang);
});

it('Checking translation on the button', async function () {
const settingsPage = new SettingsTab(webdriver, logger);
const btnText = await settingsPage.getGeneralSubTabText();
expect(btnText).to.equal(testDatum.btnTransalation);
});
});
}

afterEach(function (done) {
customAfterEach(this, webdriver, logger);
done();
});

after(function (done) {
const basePage = new BasePage(webdriver, logger);
basePage.closeBrowser();
done();
});
});
Loading
Loading