/
settings-ui-steps.js
114 lines (92 loc) · 4.69 KB
/
settings-ui-steps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// @flow
import { When, Given, Then } from 'cucumber';
import i18n from '../support/helpers/i18n-helpers';
import { By, Key } from 'selenium-webdriver';
const walletNameInputSelector = '.SettingsLayout_settingsPane .walletName input';
Given(/^I should see the "([^"]*)" wallet password dialog$/, async function (dialogType) {
const selector = '.' + dialogType + 'PasswordDialog';
await this.waitForElement(selector);
});
When(/^I click on "name" input field$/, async function () {
await this.click('.SettingsLayout_settingsPane .InlineEditingInput_component');
});
When(/^I enter new wallet name:$/, async function (table) {
const fields = table.hashes()[0];
/* Unfortunately in Selenium on geckodriver, JS events fire strangely on input fields
* For example, onFocus, etc. can transfer between clear() (or other things) and sendKeys(key)
* This makes our InlineEditingInput become disabled causing the clear and sendKeys to fail
* https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/214
* We instead repeatedly delete characters until we've deleted the whole name
*/
// can't programmtically get the wallet name due to the issue above
// so assume max length
const maxNameLength = 40;
for (let i = 0; i < maxNameLength; i++) {
// Chrome and Firefox select the text field starting at the left / right respectively
await this.input(walletNameInputSelector, Key.BACK_SPACE); // Firefox
await this.input(walletNameInputSelector, Key.DELETE); // Chrome
}
await this.input(walletNameInputSelector, fields.name);
});
Then(/^I should see the "Terms of use" screen$/, async function () {
await this.waitForElement('#terms-of-service-agreement');
});
When(/^I click outside "name" input field$/, async function () {
await this.click('.SettingsLayout_settingsPane');
});
When(/^I click on the "([^"]*)" password label$/, async function (label) {
const selector = '.' + label + 'Label button';
await this.click(selector);
});
When(/^I change wallet password:$/, async function (table) {
const fields = table.hashes()[0];
await this.input('.changePasswordDialog .currentPassword input', fields.currentPassword);
await this.input('.changePasswordDialog .newPassword input', fields.password);
await this.input('.changePasswordDialog .repeatedPassword input', fields.repeatedPassword);
});
When(/^I clear the current wallet password ([^"]*)$/, async function (password) {
await this.clearInputUpdatingForm('.changePasswordDialog .currentPassword input', password.length);
});
When(/^I clear the current wallet repeat password ([^"]*)$/, async function (repeatPassword) {
await this.clearInputUpdatingForm('.changePasswordDialog .repeatedPassword input', repeatPassword.length);
});
When(/^I submit the wallet password dialog$/, async function () {
await this.click('.confirmButton');
});
When(/^I click the next button$/, async function () {
await this.click('.confirmButton');
});
Then(/^I should not see the change password dialog anymore$/, async function () {
await this.waitForElementNotPresent('.changePasswordDialog');
});
Then(/^I should see new wallet name "([^"]*)"$/, async function (walletName) {
await this.waitUntilText('.NavPlate_name', walletName);
});
Then(/^I should see the following error messages:$/, async function (data) {
const error = data.hashes()[0];
const errorSelector = '.ChangeWalletPasswordDialog_newPasswordClassic .SimpleFormField_error';
await checkErrorByTranslationId(this, errorSelector, error);
});
Then(/^I should see "Doesn't match" error message:$/, async function (data) {
const error = data.hashes()[0];
const errorSelector = '.SimpleFormField_error';
await checkErrorByTranslationId(this, errorSelector, error);
});
Then(/^I should see the following submit error messages:$/, async function (data) {
const error = data.hashes()[0];
const errorSelector = '.ChangeWalletPasswordDialog_error';
await checkErrorByTranslationId(this, errorSelector, error);
});
async function checkErrorByTranslationId(client, errorSelector, error) {
await client.waitUntilText(errorSelector, await client.intl(error.message));
}
Then(/^I should stay in the change password dialog$/, async function () {
const changePasswordMessage = await i18n.formatMessage(this.driver,
{ id: 'wallet.settings.changePassword.dialog.title.changePassword' });
await this.waitUntilText('.Dialog_title', changePasswordMessage.toUpperCase(), 2000);
});
Then(/^I should see support screen$/, async function () {
await this.waitForElement("//h1[contains(text(), 'Frequently asked questions')]", By.xpath);
await this.waitForElement("//h1[contains(text(), 'Reporting a problem')]", By.xpath);
await this.waitForElement("//h1[contains(text(), 'Logs')]", By.xpath);
});