Skip to content

Commit f2cf825

Browse files
authored
Merge pull request #2125 from RedisInsight/e2e/feature/RI-4399-hide_recommendations_for_users
E2e/feature/ri 4399 hide recommendations for users
2 parents 3707aea + 278d332 commit f2cf825

32 files changed

+772
-59
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ vendor
5959

6060
# E2E tests report
6161
/tests/e2e/report
62+
/tests/e2e/results
63+
/tests/e2e/remote
6264
/tests/e2e/.redisinsight-v2
6365

6466
# Parcel

tests/e2e/.desktop.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ RE_CLUSTER_PORT=19443
2626

2727
NOTIFICATION_UPDATE_URL=https://s3.amazonaws.com/redisinsight.test/public/tests/e2e/notifications.json
2828
NOTIFICATION_SYNC_INTERVAL=30000
29+
30+
RI_FEATURES_CONFIG_URL=http://localhost:5551/remote/features-config.json
31+
RI_FEATURES_CONFIG_SYNC_INTERVAL=50000

tests/e2e/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ OSS_SENTINEL_PASSWORD=password
44
APP_FOLDER_NAME=.redisinsight-v2
55
NOTIFICATION_UPDATE_URL=https://s3.amazonaws.com/redisinsight.test/public/tests/e2e/notifications.json
66
NOTIFICATION_SYNC_INTERVAL=30000
7+
RI_FEATURES_CONFIG_URL=http://static-server:5551/remote/features-config.json
8+
RI_FEATURES_CONFIG_SYNC_INTERVAL=50000

tests/e2e/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
plugins
2+
report
3+
results
4+
remote
5+
.redisinsight-v2

tests/e2e/docker.web.docker-compose.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
version: "3.4"
22

33
services:
4+
static-server:
5+
build:
6+
context: .
7+
dockerfile: static-server.Dockerfile
8+
volumes:
9+
- ./remote:/app/remote
10+
ports:
11+
- 5551:5551
12+
413
e2e:
514
build:
615
context: .
@@ -14,6 +23,7 @@ services:
1423
- .ritmp:/tmp
1524
- ./test-data/certs:/root/certs
1625
- ./test-data/ssh:/root/ssh
26+
- ./remote:/root/remote
1727
env_file:
1828
- ./.env
1929
entrypoint: [
@@ -26,6 +36,7 @@ services:
2636
E2E_CLOUD_DATABASE_PASSWORD: $E2E_CLOUD_DATABASE_PASSWORD
2737
E2E_CLOUD_DATABASE_USERNAME: $E2E_CLOUD_DATABASE_USERNAME
2838
E2E_CLOUD_DATABASE_NAME: $E2E_CLOUD_DATABASE_NAME
39+
REMOTE_FOLDER_PATH: "/root/remote"
2940
command: [
3041
'./wait-for-it.sh', 'redis-enterprise:12000', '-s', '-t', '120',
3142
'--',
@@ -44,4 +55,3 @@ services:
4455
- .ritmp:/tmp
4556
- ./test-data/certs:/root/certs
4657
- ./test-data/ssh:/root/ssh
47-

tests/e2e/helpers/api/api-info.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { t } from 'testcafe';
2+
import * as request from 'supertest';
3+
import { Common } from '../common';
4+
5+
const endpoint = Common.getEndpoint();
6+
7+
/**
8+
* Synchronize features
9+
*/
10+
export async function syncFeaturesApi(): Promise<void> {
11+
const response = await request(endpoint).post('/features/sync')
12+
.set('Accept', 'application/json');
13+
await t.expect(response.status).eql(200, `Synchronization request failed: ${await response.body.message}`);
14+
}

tests/e2e/helpers/api/api-keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { t } from 'testcafe';
22
import * as request from 'supertest';
3-
import { AddNewDatabaseParameters } from '../../pageObjects/add-redis-database-page';
3+
import { AddNewDatabaseParameters } from '../../pageObjects/components/myRedisDatabase/add-redis-database';
44
import { Common } from '../../helpers/common';
55
import {
66
HashKeyParameters,

tests/e2e/helpers/common.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,17 @@ export class Common {
193193
}
194194

195195
/**
196-
* Create Zip archive from folder
197-
* @param folderPath Path to folder to archive
198-
* @param zipName Zip archive name
196+
* Get json property value by property name and path
197+
* @param expectedText Expected link that is compared with actual
198+
*/
199+
static async getJsonPropertyValue(property: string, path: string): Promise<string | number> {
200+
const parsedJson = JSON.parse(fs.readFileSync(path, 'utf-8'));
201+
return parsedJson[property];
202+
}
203+
/**
204+
* Create Zip archive from folder
205+
* @param folderPath Path to folder to archive
206+
* @param zipName Zip archive name
199207
*/
200208
static async createZipFromFolder(folderPath: string, zipName: string): Promise<void> {
201209
const sourceDir = path.join(__dirname, folderPath);

tests/e2e/helpers/conf.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const chance = new Chance();
88
export const commonUrl = process.env.COMMON_URL || 'https://localhost:5000';
99
export const apiUrl = process.env.API_URL || 'https://localhost:5000/api';
1010

11+
export const workingDirectory = process.env.APP_FOLDER_ABSOLUTE_PATH
12+
|| (joinPath(os.homedir(), process.env.APP_FOLDER_NAME || '.redisinsight-v2'));
1113
export const fileDownloadPath = joinPath(os.homedir(), 'Downloads');
1214
const uniqueId = chance.string({ length: 10 });
1315

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { workingDirectory } from '../helpers/conf';
2+
import * as sqlite3 from 'sqlite3';
3+
4+
const dbPath = `${workingDirectory}/redisinsight.db`;
5+
6+
/**
7+
* Update table column value into local DB
8+
* @param tableName The name of table in DB
9+
* @param columnName The name of column in table
10+
* @param value Value to update in table
11+
*/
12+
export async function updateColumnValueInDBTable(tableName: string, columnName: string, value: number | string): Promise<void> {
13+
const db = new sqlite3.Database(dbPath);
14+
const query = `UPDATE ${tableName} SET ${columnName} = ${value}`;
15+
16+
return new Promise<void>((resolve, reject) => {
17+
db.run(query, (err: { message: string }) => {
18+
if (err) {
19+
reject(new Error(`Error during changing ${columnName} column value: ${err.message}`));
20+
} else {
21+
db.close();
22+
resolve();
23+
}
24+
});
25+
});
26+
}
27+
28+
/**
29+
* Get Column value from table in local Database
30+
* @param tableName The name of table in DB
31+
* @param columnName The name of column in table
32+
*/
33+
export async function getColumnValueFromTableInDB(tableName: string, columnName: string): Promise<any> {
34+
const db = new sqlite3.Database(dbPath);
35+
const query = `SELECT ${columnName} FROM ${tableName}`;
36+
37+
return new Promise<void>((resolve, reject) => {
38+
db.get(query, (err: { message: string }, row: any) => {
39+
if (err) {
40+
reject(new Error(`Error during getting ${columnName} column value: ${err.message}`));
41+
} else {
42+
const columnValue = row[columnName];
43+
db.close();
44+
resolve(columnValue);
45+
}
46+
});
47+
});
48+
}
49+
50+
/**
51+
* Delete all rows from table in local DB
52+
* @param tableName The name of table in DB
53+
*/
54+
export async function deleteRowsFromTableInDB(tableName: string): Promise<void> {
55+
const db = new sqlite3.Database(dbPath);
56+
const query = `DELETE FROM ${tableName}`;
57+
58+
return new Promise<void>((resolve, reject) => {
59+
60+
61+
db.run(query, (err: { message: string }) => {
62+
if (err) {
63+
reject(new Error(`Error during ${tableName} table rows deletion: ${err.message}`));
64+
} else {
65+
db.close();
66+
resolve();
67+
}
68+
});
69+
});
70+
}

0 commit comments

Comments
 (0)