|
| 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