Skip to content

Commit 4943717

Browse files
add tests for cloud CM
1 parent 919c882 commit 4943717

File tree

4 files changed

+87
-2
lines changed

4 files changed

+87
-2
lines changed

tests/e2e/helpers/common.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ export class Common {
206206
return (await ClientFunction(() => window.location.href))();
207207
}
208208

209+
/**
210+
* generate url base on params to create DB
211+
* @param params params for creating DB
212+
*/
213+
static generateUrlTParams(params: Record<string, any>): string {
214+
return new URLSearchParams(params).toString();
215+
}
216+
209217
/**
210218
* Get json property value by property name and path
211219
* @param expectedText Expected link that is compared with actual

tests/e2e/helpers/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class DatabaseHelper {
6363
await t
6464
.click(
6565
myRedisDatabasePage.AddRedisDatabase
66-
.discoverSentinelDatabaseButton
66+
.addRedisDatabaseButton
6767
)
6868
.expect(discoverMasterGroupsPage.addPrimaryGroupButton.exists)
6969
.ok('User is not on the second step of Sentinel flow', {

tests/e2e/pageObjects/components/myRedisDatabase/add-redis-database.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class AddRedisDatabase {
2424
databaseIndexCheckbox = Selector('[data-testid=showDb]~div', { timeout: 500 });
2525
connectToDatabaseButton = Selector('[data-testid=connect-to-db-btn]');
2626
connectToRedisStackButton = Selector('[aria-label="Connect to database"]');
27-
discoverSentinelDatabaseButton = Selector('[data-testid=btn-submit]');
2827
cloneDatabaseButton = Selector('[data-testid=clone-db-btn]');
2928
sentinelNavigation = Selector('[data-testid=sentinel-nav-group]');
3029
cloneSentinelNavigation = Selector('[data-testid=sentinel-nav-group-clone]');
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { commonUrl, ossStandaloneConfig, ossStandaloneRedisGears } from '../../../helpers/conf';
2+
import { rte } from '../../../helpers/constants';
3+
import { DatabaseAPIRequests } from '../../../helpers/api/api-database';
4+
import { Common } from '../../../helpers/common';
5+
import { BrowserPage, MyRedisDatabasePage, WorkbenchPage } from '../../../pageObjects';
6+
import { DatabaseHelper } from '../../../helpers/database';
7+
8+
const myRedisDatabasePage = new MyRedisDatabasePage();
9+
const workbenchPage = new WorkbenchPage();
10+
const browserPage = new BrowserPage();
11+
12+
const databaseAPIRequests = new DatabaseAPIRequests();
13+
const databaseHelper = new DatabaseHelper();
14+
15+
let { host, port, databaseName, databaseUsername = '', databasePassword = '' } = ossStandaloneRedisGears;
16+
17+
const redisConnect = 'redisinsight://databases/connect';
18+
19+
fixture `Add DB from SM`
20+
.only
21+
.meta({ type: 'critical_path', rte: rte.none })
22+
.afterEach(async() => {
23+
// Delete all existing connections
24+
await databaseAPIRequests.deleteAllDatabasesApi();
25+
})
26+
.beforeEach(async() => {
27+
await databaseAPIRequests.addNewStandaloneDatabaseApi(ossStandaloneConfig);
28+
});
29+
test
30+
.page(commonUrl)('Add DB using url via manual flow', async t => {
31+
const connectUrlParams = {
32+
redisUrl: `redis://${databaseUsername}:${databasePassword}@${host}:${port}`,
33+
databaseAlias: databaseName,
34+
redirect: 'workbench?guidePath=/quick-guides/document/introduction.md'
35+
};
36+
37+
await t.navigateTo(generateLink(connectUrlParams));
38+
await t.expect(await myRedisDatabasePage.AddRedisDatabase.hostInput.getAttribute('value')).eql(host, 'Wrong host value');
39+
await t.expect(await myRedisDatabasePage.AddRedisDatabase.portInput.getAttribute('value')).eql(port, 'Wrong port value');
40+
await t.click(await myRedisDatabasePage.AddRedisDatabase.addRedisDatabaseButton);
41+
// wait for db is added
42+
await t.wait(3_000);
43+
await t.expect(await workbenchPage.closeEnablementPage.exists).ok('Redirection to Workbench tutorial is not correct');
44+
});
45+
46+
test
47+
.before(async() => {
48+
await databaseHelper.acceptLicenseTermsAndAddDatabaseApi(ossStandaloneRedisGears);
49+
await browserPage.Cli.sendCommandInCli('acl DELUSER alice');
50+
await browserPage.Cli.sendCommandInCli('ACL SETUSER alice on >p1pp0 +@all ~*');
51+
})
52+
.after(async t => {
53+
// Delete all existing connections
54+
await t.click(myRedisDatabasePage.NavigationPanel.myRedisDBButton);
55+
await myRedisDatabasePage.clickOnDBByName(databaseName);
56+
await browserPage.Cli.sendCommandInCli('acl DELUSER alice');
57+
await databaseAPIRequests.deleteAllDatabasesApi();
58+
})
59+
.page(commonUrl)('Add DB automatically', async t => {
60+
databaseUsername = 'alice';
61+
databasePassword = 'p1pp0';
62+
const connectUrlParams = {
63+
redisUrl: `redis://${databaseUsername}:${databasePassword}@${host}:${port}`,
64+
databaseAlias: databaseName,
65+
redirect: 'workbench?guidePath=/quick-guides/document/introduction.md'
66+
};
67+
68+
await t.navigateTo(generateLink(connectUrlParams));
69+
await t.wait(3_000);
70+
await t.expect(await workbenchPage.closeEnablementPage.exists).ok('Redirection to Workbench tutorial is not correct');
71+
});
72+
73+
function generateLink(params: Record<string, any>): string {
74+
const params1 = Common.generateUrlTParams(params);
75+
const from = encodeURIComponent(`${redisConnect}?${params1}`);
76+
return (new URL(`?from=${from}`, commonUrl)).toString();
77+
}
78+

0 commit comments

Comments
 (0)