Skip to content

Commit e3edb33

Browse files
Merge pull request #1934 from RedisInsight/e2e/feature/refactoring
[refactoring] - move nav panel and profiler to components, fix part of eslint errors
2 parents d1b7515 + 223af60 commit e3edb33

File tree

120 files changed

+1056
-1093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+1056
-1093
lines changed

tests/e2e/.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
// ******************** NOT README STANDARDS ********************
5353
//Limits the length of a row to 400
5454
"max-len": ["error", 400],
55-
55+
5656
//Forcing that all of the comments are with spaces.
5757
"spaced-comment": "off",
5858
//Forcing not to have random spaces.
@@ -128,6 +128,7 @@
128128
],
129129
//Enforce a convention in module import order
130130
"import/order": "error",
131+
"object-curly-spacing": ["error", "always"],
131132
//Disallow duplicate imports
132133
"import/no-duplicates": "error",
133134
/* Below are extended rules regarding the recommended typescript rule package...*/

tests/e2e/common-actions/cli-actions.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

tests/e2e/helpers/common.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ export class Common {
159159
await t.eval(() => location.reload());
160160
}
161161

162+
/**
163+
* Get current page url
164+
*/
165+
async getPageUrl(): Promise<string> {
166+
return (await ClientFunction(() => window.location.href))();
167+
}
168+
162169
/**
163170
* Check opened URL
164171
* @param expectedUrl Expected link that is compared with actual

tests/e2e/helpers/database.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
AutoDiscoverREDatabases,
88
AddRedisDatabasePage,
99
UserAgreementPage,
10-
CliPage
1110
} from '../pageObjects';
1211
import { addNewStandaloneDatabaseApi, discoverSentinelDatabaseApi, getDatabaseIdByName } from './api/api-database';
1312
import { Common } from './common';
@@ -18,7 +17,6 @@ const discoverMasterGroupsPage = new DiscoverMasterGroupsPage();
1817
const autoDiscoverREDatabases = new AutoDiscoverREDatabases();
1918
const browserPage = new BrowserPage();
2019
const userAgreementPage = new UserAgreementPage();
21-
const cliPage = new CliPage();
2220
const common = new Common();
2321

2422
/**
@@ -228,26 +226,16 @@ export async function acceptLicenseAndConnectToRedisStack(): Promise<void> {
228226
await acceptLicenseTerms();
229227
//Connect to DB
230228
await t
231-
.click(myRedisDatabasePage.myRedisDBButton)
229+
.click(myRedisDatabasePage.NavigationPanel.myRedisDBButton)
232230
.click(addRedisDatabasePage.connectToRedisStackButton);
233231
}
234232

235-
// Clear database data
236-
export async function clearDatabaseInCli(): Promise<void> {
237-
if (await cliPage.cliCollapseButton.exists === false) {
238-
await t.click(cliPage.cliExpandButton);
239-
}
240-
await t
241-
.typeText(cliPage.cliCommandInput, 'FLUSHDB')
242-
.pressKey('enter');
243-
}
244-
245233
/**
246234
* Delete database
247235
* @param databaseName The database name
248236
*/
249237
export async function deleteDatabase(databaseName: string): Promise<void> {
250-
await t.click(myRedisDatabasePage.myRedisDBButton);
238+
await t.click(myRedisDatabasePage.NavigationPanel.myRedisDBButton);
251239
if (await addRedisDatabasePage.addDatabaseButton.exists) {
252240
await deleteDatabaseByNameApi(databaseName);
253241
}
@@ -258,7 +246,7 @@ export async function deleteDatabase(databaseName: string): Promise<void> {
258246
* @param databaseName The database name
259247
*/
260248
export async function deleteCustomDatabase(databaseName: string): Promise<void> {
261-
await t.click(myRedisDatabasePage.myRedisDBButton);
249+
await t.click(myRedisDatabasePage.NavigationPanel.myRedisDBButton);
262250
if (await addRedisDatabasePage.addDatabaseButton.exists) {
263251
await myRedisDatabasePage.deleteDatabaseByName(databaseName);
264252
}
@@ -301,4 +289,4 @@ export async function deleteDatabaseByNameApi(databaseName: string): Promise<voi
301289
await t.expect(databaseDeleteBtn.exists).ok(`"${databaseName}" database not displayed`);
302290
await t.click(databaseDeleteBtn);
303291
await t.click(myRedisDatabasePage.confirmDeleteButton);
304-
}
292+
}

tests/e2e/helpers/keys.ts

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { createClient } from 'redis';
22
import { t } from 'testcafe';
33
import { Chance } from 'chance';
4-
import { COMMANDS_TO_CREATE_KEY } from '../helpers/constants';
5-
import { BrowserPage, CliPage } from '../pageObjects';
4+
import { random } from 'lodash';
5+
import { BrowserPage } from '../pageObjects';
66
import { KeyData, AddKeyArguments } from '../pageObjects/browser-page';
7-
import { KeyTypesTexts } from './constants';
7+
import { COMMANDS_TO_CREATE_KEY, KeyTypesTexts } from './constants';
88
import { Common } from './common';
9-
import { random } from 'lodash';
109

1110
const common = new Common();
12-
const cliPage = new CliPage();
1311
const browserPage = new BrowserPage();
1412

1513
export function getRandomKeyName(keyNameLength: number): string {
@@ -49,17 +47,17 @@ export const keyTypes = [
4947
* @param keyField The key field value
5048
*/
5149
export async function addKeysViaCli(keyData: KeyData, keyValue?: string, keyField?: string): Promise<void> {
52-
await t.click(cliPage.cliExpandButton);
50+
await t.click(browserPage.Cli.cliExpandButton);
5351
for (const { textType, keyName } of keyData) {
5452
if (textType in COMMANDS_TO_CREATE_KEY) {
5553
textType === 'Hash' || textType === 'Stream'
56-
? await t.typeText(cliPage.cliCommandInput, COMMANDS_TO_CREATE_KEY[textType](keyName, keyValue, keyField), { paste: true })
57-
: await t.typeText(cliPage.cliCommandInput, COMMANDS_TO_CREATE_KEY[textType](keyName, keyValue), { paste: true });
54+
? await t.typeText(browserPage.Cli.cliCommandInput, COMMANDS_TO_CREATE_KEY[textType](keyName, keyValue, keyField), { paste: true })
55+
: await t.typeText(browserPage.Cli.cliCommandInput, COMMANDS_TO_CREATE_KEY[textType](keyName, keyValue), { paste: true });
5856
await t.pressKey('enter');
5957
}
6058
}
6159
await t
62-
.click(cliPage.cliCollapseButton)
60+
.click(browserPage.Cli.cliCollapseButton)
6361
.click(browserPage.refreshKeysButton);
6462
}
6563

@@ -72,7 +70,7 @@ export async function deleteKeysViaCli(keyData: KeyData): Promise<void> {
7270
for (const { keyName } of keyData) {
7371
keys.push(keyName);
7472
}
75-
await cliPage.sendCommandInCli(`DEL ${keys.join(' ')}`);
73+
await browserPage.Cli.sendCommandInCli(`DEL ${keys.join(' ')}`);
7674
}
7775

7876
/**
@@ -85,14 +83,14 @@ export async function populateDBWithHashes(host: string, port: string, keyArgume
8583
const dbConf = { port: Number.parseInt(port), host, username: 'default' };
8684
const client = createClient(dbConf);
8785

88-
await client.on('error', async function (error: string) {
86+
await client.on('error', async function(error: string) {
8987
throw new Error(error);
9088
});
91-
await client.on('connect', async function () {
92-
if (keyArguments.keysCount != undefined) {
89+
await client.on('connect', async function() {
90+
if (keyArguments.keysCount) {
9391
for (let i = 0; i < keyArguments.keysCount; i++) {
9492
const keyName = `${keyArguments.keyNameStartWith}${common.generateWord(20)}`;
95-
await client.hset([keyName, 'field1', 'Hello'], async (error: string) => {
93+
await client.hset([keyName, 'field1', 'Hello'], async(error: string) => {
9694
if (error) {
9795
throw error;
9896
}
@@ -114,18 +112,18 @@ export async function populateHashWithFields(host: string, port: string, keyArgu
114112
const client = createClient(dbConf);
115113
const fields: string[] = [];
116114

117-
await client.on('error', async function (error: string) {
115+
await client.on('error', async function(error: string) {
118116
throw new Error(error);
119117
});
120-
await client.on('connect', async function () {
121-
if (keyArguments.fieldsCount != undefined) {
118+
await client.on('connect', async function() {
119+
if (keyArguments.fieldsCount) {
122120
for (let i = 0; i < keyArguments.fieldsCount; i++) {
123121
const field = `${keyArguments.fieldStartWith}${common.generateWord(10)}`;
124122
const fieldValue = `${keyArguments.fieldValueStartWith}${common.generateWord(10)}`;
125123
fields.push(field, fieldValue);
126124
}
127125
}
128-
await client.hset(keyArguments.keyName, fields, async (error: string) => {
126+
await client.hset(keyArguments.keyName, fields, async(error: string) => {
129127
if (error) {
130128
throw error;
131129
}
@@ -145,17 +143,17 @@ export async function populateListWithElements(host: string, port: string, keyAr
145143
const client = createClient(dbConf);
146144
const elements: string[] = [];
147145

148-
await client.on('error', async function (error: string) {
146+
await client.on('error', async function(error: string) {
149147
throw new Error(error);
150148
});
151-
await client.on('connect', async function () {
152-
if (keyArguments.elementsCount != undefined) {
149+
await client.on('connect', async function() {
150+
if (keyArguments.elementsCount) {
153151
for (let i = 0; i < keyArguments.elementsCount; i++) {
154152
const element = `${keyArguments.elementStartWith}${common.generateWord(10)}`;
155153
elements.push(element);
156154
}
157155
}
158-
await client.lpush(keyArguments.keyName, elements, async (error: string) => {
156+
await client.lpush(keyArguments.keyName, elements, async(error: string) => {
159157
if (error) {
160158
throw error;
161159
}
@@ -175,17 +173,17 @@ export async function populateSetWithMembers(host: string, port: string, keyArgu
175173
const client = createClient(dbConf);
176174
const members: string[] = [];
177175

178-
await client.on('error', async function (error: string) {
176+
await client.on('error', async function(error: string) {
179177
throw new Error(error);
180178
});
181-
await client.on('connect', async function () {
182-
if (keyArguments.membersCount != undefined) {
179+
await client.on('connect', async function() {
180+
if (keyArguments.membersCount) {
183181
for (let i = 0; i < keyArguments.membersCount; i++) {
184182
const member = `${keyArguments.memberStartWith}${common.generateWord(10)}`;
185183
members.push(member);
186184
}
187185
}
188-
await client.sadd(keyArguments.keyName, members, async (error: string) => {
186+
await client.sadd(keyArguments.keyName, members, async(error: string) => {
189187
if (error) {
190188
throw error;
191189
}
@@ -200,7 +198,7 @@ export async function populateSetWithMembers(host: string, port: string, keyArgu
200198
* @param port The port of database
201199
* @param keyArguments The arguments of key and its members
202200
*/
203-
export async function populateZSetWithMembers(host: string, port: string, keyArguments: AddKeyArguments): Promise<void> {
201+
export async function populateZSetWithMembers(host: string, port: string, keyArguments: AddKeyArguments): Promise<void> {
204202
const dbConf = { port: Number.parseInt(port), host, username: 'default' };
205203
let minScoreValue: -10;
206204
let maxScoreValue: 10;
@@ -211,7 +209,7 @@ export async function populateSetWithMembers(host: string, port: string, keyArgu
211209
throw new Error(error);
212210
});
213211
await client.on('connect', async function() {
214-
if (keyArguments.membersCount != undefined) {
212+
if (keyArguments.membersCount) {
215213
for (let i = 0; i < keyArguments.membersCount; i++) {
216214
const memberName = `${keyArguments.memberStartWith}${common.generateWord(10)}`;
217215
const scoreValue = random(minScoreValue, maxScoreValue).toString(2);
@@ -236,10 +234,10 @@ export async function deleteAllKeysFromDB(host: string, port: string): Promise<v
236234
const dbConf = { port: Number.parseInt(port), host, username: 'default' };
237235
const client = createClient(dbConf);
238236

239-
await client.on('error', async function (error: string) {
237+
await client.on('error', async function(error: string) {
240238
throw new Error(error);
241239
});
242-
await client.on('connect', async function () {
240+
await client.on('connect', async function() {
243241
await client.flushall((error: string) => {
244242
if (error) {
245243
throw error;

tests/e2e/pageObjects/add-redis-database-page.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {t, Selector} from 'testcafe';
1+
import { t, Selector } from 'testcafe';
22

33
export class AddRedisDatabasePage {
44
//-------------------------------------------------------------------------------------------
@@ -58,13 +58,13 @@ export class AddRedisDatabasePage {
5858
buildFromDocker = Selector('a').withExactText('Docker');
5959
buildFromHomebrew = Selector('a').withExactText('Homebrew');
6060
// DROPDOWNS
61-
caCertField = Selector('[data-testid=select-ca-cert]', {timeout: 500});
62-
clientCertField = Selector('[data-testid=select-cert]', {timeout: 500});
61+
caCertField = Selector('[data-testid=select-ca-cert]', { timeout: 500 });
62+
clientCertField = Selector('[data-testid=select-cert]', { timeout: 500 });
6363
// CHECKBOXES
64-
useSSHCheckbox = Selector('[data-testid=use-ssh]~div', {timeout: 500});
64+
useSSHCheckbox = Selector('[data-testid=use-ssh]~div', { timeout: 500 });
6565
// RADIO BUTTONS
66-
sshPasswordRadioBtn = Selector('#password~div', {timeout: 500});
67-
sshPrivateKeyRadioBtn = Selector('#privateKey~div', {timeout: 500});
66+
sshPasswordRadioBtn = Selector('#password~div', { timeout: 500 });
67+
sshPrivateKeyRadioBtn = Selector('#privateKey~div', { timeout: 500 });
6868

6969
/**
7070
* Adding a new redis database
@@ -108,11 +108,11 @@ export class AddRedisDatabasePage {
108108
}
109109
// Enter logical index
110110
await t.click(this.databaseIndexCheckbox);
111-
await t.typeText(this.databaseIndexInput, index, { replace: true, paste: true});
111+
await t.typeText(this.databaseIndexInput, index, { replace: true, paste: true });
112112
// Click for saving
113113
await t.click(this.addRedisDatabaseButton);
114114
}
115-
115+
116116
/**
117117
* Adding a new standalone database with SSH
118118
* @param databaseParameters the parameters of the database
@@ -140,18 +140,18 @@ export class AddRedisDatabasePage {
140140
.typeText(this.sshPortInput, sshParameters.sshPort, { replace: true, paste: true })
141141
.typeText(this.sshUsernameInput, sshParameters.sshUsername, { replace: true, paste: true });
142142
if (!!sshParameters.sshPassword) {
143-
await t.typeText(this.sshPasswordInput, sshParameters.sshPassword, { replace: true, paste: true });
143+
await t.typeText(this.sshPasswordInput, sshParameters.sshPassword, { replace: true, paste: true });
144144
}
145145
if (!!sshParameters.sshPrivateKey) {
146146
await t
147-
.click(this.sshPrivateKeyRadioBtn)
148-
.typeText(this.sshPrivateKeyInput, sshParameters.sshPrivateKey, { replace: true, paste: true });
147+
.click(this.sshPrivateKeyRadioBtn)
148+
.typeText(this.sshPrivateKeyInput, sshParameters.sshPrivateKey, { replace: true, paste: true });
149149
}
150150
if (!!sshParameters.sshPassphrase) {
151151
await t
152-
.click(this.sshPrivateKeyRadioBtn)
153-
.typeText(this.sshPrivateKeyInput, sshParameters.sshPrivateKey!, { replace: true, paste: true })
154-
.typeText(this.sshPassphraseInput, sshParameters.sshPassphrase, { replace: true, paste: true });
152+
.click(this.sshPrivateKeyRadioBtn)
153+
.typeText(this.sshPrivateKeyInput, sshParameters.sshPrivateKey!, { replace: true, paste: true })
154+
.typeText(this.sshPassphraseInput, sshParameters.sshPassphrase, { replace: true, paste: true });
155155
}
156156
// Click for saving
157157
await t.click(this.addRedisDatabaseButton);
@@ -249,7 +249,7 @@ export type AddNewDatabaseParameters = {
249249
name?: string,
250250
certificate?: string,
251251
key?: string
252-
},
252+
}
253253
};
254254

255255
/**
@@ -265,7 +265,7 @@ export type SentinelParameters = {
265265
alias?: string,
266266
db?: string,
267267
name?: string,
268-
password?: string,
268+
password?: string
269269
}[],
270270
sentinelPassword?: string,
271271
name?: string[]

tests/e2e/pageObjects/base-page.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { NavigationPanel } from './components/navigation-panel';
2+
3+
export class BasePage {
4+
NavigationPanel = new NavigationPanel();
5+
6+
}

0 commit comments

Comments
 (0)