Skip to content

Commit 294d730

Browse files
authored
Merge pull request #1405 from RedisInsight/e2e/feature/RI-3637_databases-import
e2e RI-3637 databases import
2 parents 000a632 + 4be338b commit 294d730

File tree

10 files changed

+595
-2
lines changed

10 files changed

+595
-2
lines changed

redisinsight/ui/src/pages/home/components/AddInstanceForm/InstanceForm/InstanceForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ const AddStandaloneForm = (props: Props) => {
448448
label={(
449449
<EuiText color="subdued" size="s">
450450
Connection Type:
451-
<EuiTextColor color="default" className={styles.dbInfoListValue}>
451+
<EuiTextColor color="default" className={styles.dbInfoListValue} data-testid="connection-type">
452452
{capitalize(connectionType)}
453453
</EuiTextColor>
454454
</EuiText>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { t } from 'testcafe';
2+
import { MyRedisDatabasePage } from '../pageObjects';
3+
4+
const myRedisDatabasePage = new MyRedisDatabasePage();
5+
6+
export class DatabasesActions {
7+
/**
8+
* Verify that databases are displayed
9+
* @param databases The list of databases to verify
10+
*/
11+
async verifyDatabasesDisplayed(databases: string[]): Promise<void> {
12+
for (const db of databases) {
13+
const databaseName = myRedisDatabasePage.dbNameList.withText(db);
14+
await t.expect(databaseName.exists).ok(`"${db}" database doesn't exist`);
15+
}
16+
}
17+
18+
/**
19+
* Import database using file
20+
* @param fileParameters The arguments of imported file
21+
*/
22+
async importDatabase(fileParameters: ImportDatabaseParameters): Promise<void> {
23+
await t
24+
.click(myRedisDatabasePage.importDatabasesBtn)
25+
.setFilesToUpload(myRedisDatabasePage.importDatabaseInput, [fileParameters.path])
26+
.click(myRedisDatabasePage.submitImportBtn)
27+
.expect(myRedisDatabasePage.successImportMessage.exists).ok(`Successfully added ${fileParameters.type} databases message not displayed`);
28+
}
29+
30+
}
31+
32+
/**
33+
* Import database parameters
34+
* @param path The path to file
35+
* @param type The type of application
36+
* @param dbNames The names of databases
37+
* @param userName The username of db
38+
* @param password The password of db
39+
* @param connectionType The connection type of db
40+
* @param fileName The file name
41+
*/
42+
export type ImportDatabaseParameters = {
43+
path: string,
44+
type?: string,
45+
dbNames?: string[],
46+
userName?: string,
47+
password?: string,
48+
connectionType?: string,
49+
fileName?: string
50+
};

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ export async function deleteStandaloneDatabaseApi(databaseParameters: AddNewData
153153
.expect(200);
154154
}
155155

156+
/**
157+
* Delete Standalone databases using their names through api
158+
* @param databaseNames Databases names
159+
*/
160+
export async function deleteStandaloneDatabasesByNamesApi(databaseNames: string[]): Promise<void> {
161+
databaseNames.forEach(async databaseName => {
162+
const databaseId = await getDatabaseByName(databaseName);
163+
await request(endpoint).delete('/databases')
164+
.send({ 'ids': [`${databaseId}`] })
165+
.set('Accept', 'application/json')
166+
.expect(200);
167+
});
168+
}
169+
156170
/**
157171
* Delete database from OSS Cluster through api
158172
* @param databaseParameters The database parameters

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class AddRedisDatabasePage {
2828
sentinelDatabaseNavigation = Selector('[data-testid=database-nav-group]');
2929
cloneSentinelDatabaseNavigation = Selector('[data-testid=database-nav-group-clone]');
3030
cancelButton = Selector('[data-testid=btn-cancel]');
31+
showPasswordBtn = Selector('[aria-label^="Show password"]');
3132
//TEXT INPUTS (also referred to as 'Text fields')
3233
hostInput = Selector('[data-testid=host]');
3334
portInput = Selector('[data-testid=port]');
@@ -42,6 +43,7 @@ export class AddRedisDatabasePage {
4243
databaseIndexMessage = Selector('[data-testid=db-index-message]');
4344
primaryGroupNameInput = Selector('[data-testid=primary-group]');
4445
masterGroupPassword = Selector('[data-testid=sentinel-master-password]');
46+
connectionType = Selector('[data-testid=connection-type]');
4547
//Links
4648
buildFromSource = Selector('a').withExactText('Build from source');
4749
buildFromDocker = Selector('a').withExactText('Docker');

tests/e2e/pageObjects/my-redis-databases-page.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class MyRedisDatabasePage {
1515
githubButton = Selector('[data-testid=github-repo-icon]');
1616
browserButton = Selector('[data-testid=browser-page-btn]');
1717
pubSubButton = Selector('[data-testid=pub-sub-page-btn]');
18-
myRedisDBButton = Selector('[data-test-subj=home-page-btn]');
18+
myRedisDBButton = Selector('[data-test-subj=home-page-btn]', { timeout: 1000 });
1919
deleteDatabaseButton = Selector('[data-testid^=delete-instance-]');
2020
confirmDeleteButton = Selector('[data-testid^=delete-instance-]').withExactText('Remove');
2121
toastCloseButton = Selector('[data-test-subj=toastCloseButton]');
@@ -30,6 +30,11 @@ export class MyRedisDatabasePage {
3030
sortByHostAndPort = Selector('span').withAttribute('title', 'Host:Port');
3131
sortByConnectionType = Selector('span').withAttribute('title', 'Connection Type');
3232
sortByLastConnection = Selector('span').withAttribute('title', 'Last connection');
33+
importDatabasesBtn = Selector('[data-testid=import-dbs-btn]');
34+
submitImportBtn = Selector('[data-testid=submit-btn]');
35+
closeDialogBtn = Selector('[aria-label="Closes this modal window"]');
36+
okDialogBtn = Selector('[data-testid=ok-btn]');
37+
removeImportedFileBtn = Selector('[aria-label="Clear selected files"]');
3338
//CHECKBOXES
3439
selectAllCheckbox = Selector('[data-test-subj=checkboxSelectAll]');
3540
//ICONS
@@ -46,6 +51,7 @@ export class MyRedisDatabasePage {
4651
//TEXT INPUTS (also referred to as 'Text fields')
4752
aliasInput = Selector('[data-testid=alias-input]');
4853
searchInput = Selector('[data-testid=search-database-list]');
54+
importDatabaseInput = Selector('[data-testid=import-databases-input-file]');
4955
//TEXT ELEMENTS
5056
moduleTooltip = Selector('.euiToolTipPopover');
5157
moduleQuantifier = Selector('[data-testid=_module]');
@@ -55,6 +61,10 @@ export class MyRedisDatabasePage {
5561
hostPort = Selector('[data-testid=host-port]');
5662
noResultsFoundMessage = Selector('div').withExactText('No results found');
5763
noResultsFoundText = Selector('div').withExactText('No databases matched your search. Try reducing the criteria.');
64+
failedImportMessage = Selector('[data-testid=result-failed]');
65+
successImportMessage = Selector('[data-testid=result-success]');
66+
// DIALOG
67+
importDbDialog = Selector('[data-testid=import-dbs-dialog]');
5868

5969
/**
6070
* Click on the database by name

tests/e2e/test-data/ardm-valid.ano

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
W3siaG9zdCI6ImxvY2FsaG9zdCIsInBvcnQiOiI2Mzc5IiwiYXV0aCI6InBhc3MiLCJ1c2VybmFtZSI6InVzZXJuYW1lVGVzdCIsIm5hbWUiOiJhcmRtV2l0aFBhc3NBbmRVc2VybmFtZSIsInNlcGFyYXRvciI6IjoiLCJjbHVzdGVyIjpmYWxzZSwia2V5IjoiMTY1MDM3MzUyNTY1MV9naHFwciIsIm9yZGVyIjowfSx7Imhvc3QiOiJhcmRtTm9OYW1lIiwicG9ydCI6IjEyMDAxIiwiYXV0aCI6IiIsInVzZXJuYW1lIjoiIiwic2VwYXJhdG9yIjoiOiIsImNsdXN0ZXIiOmZhbHNlLCJrZXkiOiIxNjUwODk3NjIxNzU0X2I1bjB2Iiwib3JkZXIiOjF9XQ==
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
[
2+
{
3+
"srvRecords": [
4+
{
5+
"priority": null,
6+
"weight": null,
7+
"port": null,
8+
"name": null
9+
}
10+
],
11+
"useSRVRecords": false,
12+
"natMaps": [
13+
{
14+
"privateHost": null,
15+
"privatePort": null,
16+
"publicHost": null,
17+
"publicPort": null
18+
}
19+
],
20+
"enableNatMaps": false,
21+
"clusterOptions": {
22+
"slotsRefreshInterval": 5000,
23+
"slotsRefreshTimeout": 1000,
24+
"retryDelayOnTryAgain": 100,
25+
"retryDelayOnClusterDown": 100,
26+
"retryDelayOnFailover": 100,
27+
"retryDelayOnMoved": 0,
28+
"maxRedirections": 16,
29+
"dnsLookup": false,
30+
"scaleReads": "master",
31+
"startupNodes": [
32+
{
33+
"host": null,
34+
"port": null
35+
}
36+
]
37+
},
38+
"enableStartupNodes": false,
39+
"sentinelOptions": {
40+
"tls": {
41+
"key": null,
42+
"keyBookmark": null,
43+
"ca": null,
44+
"caBookmark": null,
45+
"cert": null,
46+
"certBookmark": null
47+
},
48+
"preferredSlaves": [
49+
{
50+
"host": null,
51+
"port": null,
52+
"priority": null
53+
}
54+
],
55+
"role": null,
56+
"sentinelPassword": null,
57+
"name": null
58+
},
59+
"enablePreferredSlaves": false,
60+
"sshKeyPassphrase": null,
61+
"sshKeyFileBookmark": null,
62+
"sshKeyFile": null,
63+
"sshUser": null,
64+
"sshPort": null,
65+
"sshHost": null,
66+
"ssh": false,
67+
"caCertBookmark": null,
68+
"caCert": null,
69+
"certificateBookmark": null,
70+
"certificate": null,
71+
"keyFileBookmark": null,
72+
"keyFile": null,
73+
"ssl": false,
74+
"default": false,
75+
"star": false,
76+
"totalDb": 16,
77+
"db": 0,
78+
"password": "",
79+
"color": "#4B5563",
80+
"host": "localhost",
81+
"keyPrefix": null,
82+
"type": "standalone",
83+
"id": "f99a5d6d-daf4-489c-885b-6f8e411adbc9"
84+
},
85+
{
86+
"srvRecords": [
87+
{
88+
"priority": null,
89+
"weight": null,
90+
"port": null,
91+
"name": null
92+
}
93+
],
94+
"useSRVRecords": false,
95+
"natMaps": [
96+
{
97+
"privateHost": null,
98+
"privatePort": null,
99+
"publicHost": null,
100+
"publicPort": null
101+
}
102+
],
103+
"enableNatMaps": false,
104+
"clusterOptions": {
105+
"slotsRefreshInterval": 5000,
106+
"slotsRefreshTimeout": 1000,
107+
"retryDelayOnTryAgain": 100,
108+
"retryDelayOnClusterDown": 100,
109+
"retryDelayOnFailover": 100,
110+
"retryDelayOnMoved": 0,
111+
"maxRedirections": 16,
112+
"dnsLookup": false,
113+
"scaleReads": "master",
114+
"startupNodes": [
115+
{
116+
"host": null,
117+
"port": null
118+
}
119+
]
120+
},
121+
"enableStartupNodes": false,
122+
"sentinelOptions": {
123+
"tls": {
124+
"key": null,
125+
"keyBookmark": null,
126+
"ca": null,
127+
"caBookmark": null,
128+
"cert": null,
129+
"certBookmark": null
130+
},
131+
"preferredSlaves": [
132+
{
133+
"host": null,
134+
"port": null,
135+
"priority": null
136+
}
137+
],
138+
"role": null,
139+
"sentinelPassword": null,
140+
"name": null
141+
},
142+
"enablePreferredSlaves": false,
143+
"sshKeyPassphrase": null,
144+
"sshKeyFileBookmark": null,
145+
"sshKeyFile": null,
146+
"sshUser": null,
147+
"sshPort": null,
148+
"sshHost": null,
149+
"ssh": false,
150+
"caCertBookmark": null,
151+
"caCert": null,
152+
"certificateBookmark": null,
153+
"certificate": null,
154+
"keyFileBookmark": null,
155+
"keyFile": null,
156+
"ssl": false,
157+
"default": false,
158+
"star": false,
159+
"totalDb": 16,
160+
"db": 1,
161+
"password": "vfsd",
162+
"color": "#4B5563",
163+
"port": 1111,
164+
"keyPrefix": null,
165+
"type": "standalone",
166+
"connectionName": "vd",
167+
"id": "f99a5d6d-daf4-489c-885b-6f8e411adbc9",
168+
"cluster": true,
169+
"name": "vd long host"
170+
}
171+
]

0 commit comments

Comments
 (0)