Skip to content

Commit bac5ed9

Browse files
authored
Merge pull request #1106 from RedisInsight/e2e/feature/workbench-raw-mode
E2e/feature/workbench raw mode
2 parents fe0ad3c + 00b3de8 commit bac5ed9

34 files changed

+372
-115
lines changed

tests/e2e/helpers/common.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class Common {
3535
* @param length The amount of array elements
3636
*/
3737
async createArrayWithKeyValue(length: number): Promise<string[]> {
38-
const arr = [];
38+
const arr: string[] = [];
3939
for(let i = 1; i <= length * 2; i++) {
4040
arr[i] = `${chance.word({ length: 10 })}-key${i}`;
4141
arr[i + 1] = `${chance.word({ length: 10 })}-value${i}`;
@@ -49,7 +49,7 @@ export class Common {
4949
* @param length The amount of array elements
5050
*/
5151
async createArrayWithKeyValueForOSSCluster(length: number): Promise<string[]> {
52-
const arr = [];
52+
const arr: string[] = [];
5353
for(let i = 1; i <= length * 2; i++) {
5454
arr[i] = `{user1}:${chance.word({ length: 10 })}-key${i}`;
5555
arr[i + 1] = `${chance.word({ length: 10 })}-value${i}`;
@@ -64,7 +64,7 @@ export class Common {
6464
* @param keyName The name of the key
6565
*/
6666
async createArrayWithKeyValueAndKeyname(length: number, keyName: string): Promise<string[]> {
67-
const keyNameArray = [];
67+
const keyNameArray: string[] = [];
6868
for(let i = 1; i <= length; i++) {
6969
const key = `${keyName}${i}`;
7070
const value = `value${i}`;
@@ -86,7 +86,7 @@ export class Common {
8686
* @param length The amount of array elements
8787
*/
8888
async createArray(length: number): Promise<string[]> {
89-
const arr = [];
89+
const arr: string[] = [];
9090
for(let i = 1; i <= length; i++) {
9191
arr[i] = `${i}`;
9292
}
@@ -123,4 +123,11 @@ export class Common {
123123
getEndpoint(): string {
124124
return apiUrl;
125125
}
126+
127+
/**
128+
* Reload page
129+
*/
130+
async reloadPage(): Promise<void> {
131+
await t.eval(() => location.reload());
132+
}
126133
}

tests/e2e/helpers/database.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
CliPage
1111
} from '../pageObjects';
1212
import { addNewStandaloneDatabaseApi, discoverSentinelDatabaseApi } from './api/api-database';
13+
import { Common } from './common';
1314

1415
const myRedisDatabasePage = new MyRedisDatabasePage();
1516
const addRedisDatabasePage = new AddRedisDatabasePage();
@@ -18,6 +19,7 @@ const autoDiscoverREDatabases = new AutoDiscoverREDatabases();
1819
const browserPage = new BrowserPage();
1920
const userAgreementPage = new UserAgreementPage();
2021
const cliPage = new CliPage();
22+
const common = new Common();
2123

2224
/**
2325
* Add a new database manually using host and port
@@ -126,7 +128,7 @@ export async function acceptLicenseTermsAndAddDatabaseApi(databaseParameters: Ad
126128
await acceptLicenseTerms();
127129
await addNewStandaloneDatabaseApi(databaseParameters);
128130
// Reload Page to see the new added database through api
129-
await t.eval(() => location.reload());
131+
await common.reloadPage();
130132
//Connect to DB
131133
await myRedisDatabasePage.clickOnDBByName(databaseName);
132134
}
@@ -151,7 +153,7 @@ export async function acceptLicenseTermsAndAddSentinelDatabaseApi(databaseParame
151153
await acceptLicenseTerms();
152154
await discoverSentinelDatabaseApi(databaseParameters);
153155
// Reload Page to see the database added through api
154-
await t.eval(() => location.reload());
156+
await common.reloadPage();
155157
//Connect to DB
156158
await myRedisDatabasePage.clickOnDBByName(databaseParameters.name[1] ?? '');
157159
}
@@ -182,7 +184,7 @@ export async function acceptLicenseTermsAndAddRECloudDatabase(databaseParameters
182184
await t.click(addRedisDatabasePage.addRedisDatabaseButton);
183185
// Reload page until db appears
184186
do {
185-
await t.eval(() => location.reload());
187+
await common.reloadPage();
186188
}
187189
while (!(await dbSelector.exists) && Date.now() - startTime < searchTimeout);
188190
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databaseParameters.databaseName ?? '').exists).ok('The existence of the database', { timeout: 5000 });

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class MyRedisDatabasePage {
6464
await t.click(this.toastCloseButton);
6565
}
6666
const db = this.dbNameList.withExactText(dbName.trim());
67-
await t.expect(db.exists).ok('The database exists', {timeout: 10000});
67+
await t.expect(db.exists).ok(`"${dbName}" database doesn't exist`, {timeout: 10000});
6868
await t.click(db);
6969
}
7070

tests/e2e/pageObjects/settings-page.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ export class SettingsPage {
1212
accordionAppearance = Selector('[data-test-subj=accordion-appearance]');
1313
accordionPrivacySettings = Selector('[data-test-subj=accordion-privacy-settings]');
1414
accordionAdvancedSettings = Selector('[data-test-subj=accordion-advanced-settings]');
15+
accordionWorkbenchSettings = Selector('[data-test-subj=accordion-workbench-settings]');
1516
switchAnalyticsOption = Selector('[data-testid=switch-option-analytics]');
1617
switchEulaOption = Selector('[data-testid=switch-option-eula]');
1718
submitConsentsPopupButton = Selector('[data-testid=consents-settings-popup] [data-testid=btn-submit]');
1819
switchNotificationsOption = Selector('[data-testid=switch-option-notifications]');
20+
switchEditorCleanupOption = Selector('[data-testid=switch-workbench-cleanup]');
1921
//TEXT INPUTS (also referred to as 'Text fields')
2022
keysToScanValue = Selector('[data-testid=keys-to-scan-value]');
2123
keysToScanInput = Selector('[data-testid=keys-to-scan-input]');
@@ -65,4 +67,22 @@ export class SettingsPage {
6567
async getEulaSwitcherValue(): Promise<string> {
6668
return await this.switchEulaOption.getAttribute('aria-checked');
6769
}
70+
71+
/**
72+
* Get state of Editor Cleanup switcher
73+
*/
74+
async getEditorCleanupSwitcherValue(): Promise<string> {
75+
return await this.switchEditorCleanupOption.getAttribute('aria-checked');
76+
}
77+
78+
/**
79+
* Enable Editor Cleanup switcher
80+
* @param state Enabled(true) or disabled(false)
81+
*/
82+
async changeEditorCleanupSwitcher(state: boolean): Promise<void> {
83+
const currentState = await this.getEditorCleanupSwitcherValue();
84+
if (currentState !== `${state}`) {
85+
await t.click(this.switchEditorCleanupOption);
86+
}
87+
}
6888
}

tests/e2e/pageObjects/workbench-page.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class WorkbenchPage {
1212
cssMonacoCommandPaletteLine = '[aria-label="Command Palette"]';
1313
cssQueryTextResult = '[data-testid=query-cli-result]';
1414
cssQueryTableResult = '[data-testid^=query-table-result-]';
15+
cssQueryPluginResult = '[data-testid^=query-table-result-]';
1516
queryGraphContainer = '[data-testid=query-graph-container]';
1617
cssQueryCardCommand = '[data-testid=query-card-command]';
1718
cssQueryCardCommandResult = '[data-testid=query-common-result]';
@@ -55,6 +56,7 @@ export class WorkbenchPage {
5556
preselectModelBikeSalesButton = Selector('[data-testid="preselect-Model bike sales"]');
5657
showSalesPerRegiomButton = Selector('[data-testid="preselect-Show all sales per region"]');
5758
queryCardNoModuleButton = Selector('[data-testid=query-card-no-module-button] a');
59+
rawModeBtn = Selector('[data-testid="btn-change-mode"]');
5860
//ICONS
5961
noCommandHistoryIcon = Selector('[data-testid=wb_no-results__icon]');
6062
//LINKS
@@ -130,7 +132,7 @@ export class WorkbenchPage {
130132
//Select Table view option in Workbench results
131133
async selectViewTypeTable(): Promise<void> {
132134
await t.click(this.selectViewType);
133-
await t.click(this.tableViewTypeOption);
135+
await t.doubleClick(this.tableViewTypeOption);
134136
}
135137

136138
//Select view option in Workbench results
@@ -161,16 +163,16 @@ export class WorkbenchPage {
161163
}
162164

163165
/**
164-
* Send commands array in Workbench page
165-
* @param command The array of commands to send
166-
* @param result The array of commands to send
166+
* Check the last command and result in workbench
167+
* @param command The command to check
168+
* @param result The result to check
167169
*/
168170
async checkWorkbenchCommandResult(command: string, result: string): Promise<void> {
169171
//Compare the command with executed command
170172
const actualCommand = await this.queryCardContainer.nth(0).find(this.cssQueryCardCommand).textContent;
171173
await t.expect(actualCommand).eql(command);
172174
//Compare the command result with executed command
173-
const actualCommandResult = await this.queryCardContainer.nth(0).find(this.cssQueryCardCommandResult).textContent;
175+
const actualCommandResult = await this.queryCardContainer.nth(0).find(this.cssQueryTextResult).textContent;
174176
await t.expect(actualCommandResult).eql(result);
175177
}
176178
}

tests/e2e/tests/critical-path/browser/database-overview.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ test
6767
//Add database with different modules
6868
await t.click(myRedisDatabasePage.myRedisDBButton);
6969
await addNewStandaloneDatabaseApi(ossStandaloneRedisearch);
70-
await t.eval(() => location.reload());
70+
await common.reloadPage();
7171
await myRedisDatabasePage.clickOnDBByName(ossStandaloneRedisearch.databaseName);
7272
countOfModules = await browserPage.modulesButton.count;
7373
for(let i = 0; i < countOfModules; i++) {
@@ -123,7 +123,7 @@ test
123123
//Add database with more than 1M keys
124124
await t.click(myRedisDatabasePage.myRedisDBButton);
125125
await addNewStandaloneDatabaseApi(ossStandaloneBigConfig);
126-
await t.eval(() => location.reload());
126+
await common.reloadPage();
127127
await myRedisDatabasePage.clickOnDBByName(ossStandaloneBigConfig.databaseName);
128128
//Wait 5 seconds
129129
await t.wait(fiveSecondsTimeout);

tests/e2e/tests/critical-path/browser/filtering.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ test('Verify that user can see filtering per key name starts when he press Enter
9494
await t.pressKey('enter');
9595
await t.expect(browserPage.searchAdvices.visible).ok('The filtering is set');
9696
//Check the filtering starts by clicks the control
97-
await t.eval(() => location.reload());
97+
await common.reloadPage();
9898
await t.typeText(browserPage.filterByPatterSearchInput, keyName);
9999
await t.click(browserPage.searchButton);
100100
await t.expect(browserPage.searchAdvices.visible).ok('The filtering is set');

tests/e2e/tests/critical-path/browser/json-key.e2e.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ fixture `JSON Key verification`
2323
await browserPage.deleteKeyByName(keyName);
2424
await deleteStandaloneDatabaseApi(ossStandaloneConfig);
2525
})
26-
//skipped due the issue https://redislabs.atlassian.net/browse/RI-2866
27-
test.skip
26+
test
2827
.meta({ rte: rte.standalone })
2928
('Verify that user can not add invalid JSON structure inside of created JSON', async t => {
3029
keyName = chance.word({ length: 10 });

tests/e2e/tests/critical-path/database/clone-databases.e2e.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,23 @@ import {
1010
deleteStandaloneDatabaseApi,
1111
discoverSentinelDatabaseApi
1212
} from '../../../helpers/api/api-database';
13+
import { Common } from '../../../helpers/common';
1314

1415
const addRedisDatabasePage = new AddRedisDatabasePage();
1516
const myRedisDatabasePage = new MyRedisDatabasePage();
17+
const common = new Common();
1618
const newOssDatabaseAlias = 'cloned oss cluster';
1719

1820
fixture `Clone databases`
1921
.meta({ type: 'critical_path' })
2022
.page(commonUrl);
2123
test
22-
.before(async t => {
24+
.before(async () => {
2325
await acceptLicenseTerms();
2426
await addNewStandaloneDatabaseApi(ossStandaloneConfig);
25-
await t.eval(() => location.reload());
27+
await common.reloadPage();
2628
})
27-
.after(async() => {
29+
.after(async () => {
2830
// Delete databases
2931
const dbNumber = await myRedisDatabasePage.dbNameList.withExactText(ossStandaloneConfig.databaseName).count;
3032
for (let i = 0; i < dbNumber; i++) {
@@ -51,10 +53,10 @@ test
5153
await t.expect(myRedisDatabasePage.dbNameList.withExactText(ossStandaloneConfig.databaseName).count).eql(2, 'DB was not cloned');
5254
});
5355
test
54-
.before(async t => {
56+
.before(async () => {
5557
await acceptLicenseTerms();
5658
await addNewOSSClusterDatabaseApi(ossClusterConfig);
57-
await t.eval(() => location.reload());
59+
await common.reloadPage();
5860
})
5961
.after(async() => {
6062
// Delete database
@@ -75,19 +77,19 @@ test
7577
await t.expect(myRedisDatabasePage.dbNameList.withExactText(ossClusterConfig.ossClusterDatabaseName).visible).ok('Original DB is not displayed');
7678
});
7779
test
78-
.before(async t => {
80+
.before(async () => {
7981
await acceptLicenseTerms();
8082
// Add Sentinel databases
8183
await discoverSentinelDatabaseApi(ossSentinelConfig);
82-
await t.eval(() => location.reload());
84+
await common.reloadPage();
8385
})
84-
.after(async t => {
86+
.after(async () => {
8587
// Delete all primary groups
8688
const sentinelCopy = ossSentinelConfig;
8789
sentinelCopy.masters.push(ossSentinelConfig.masters[1]);
8890
sentinelCopy.name.push(ossSentinelConfig.name[1]);
8991
await deleteAllSentinelDatabasesApi(sentinelCopy);
90-
await t.eval(() => location.reload());
92+
await common.reloadPage();
9193
})
9294
.meta({ rte: rte.sentinel })('Verify that user can clone Sentinel', async t => {
9395
await myRedisDatabasePage.clickOnEditDBByName(ossSentinelConfig.name[1]);

tests/e2e/tests/critical-path/database/modules.e2e.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ import { acceptLicenseTerms } from '../../../helpers/database';
44
import { MyRedisDatabasePage, DatabaseOverviewPage } from '../../../pageObjects';
55
import { commonUrl, ossStandaloneRedisearch } from '../../../helpers/conf';
66
import { addNewStandaloneDatabaseApi, deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database';
7+
import { Common } from '../../../helpers/common';
78

89
const myRedisDatabasePage = new MyRedisDatabasePage();
910
const databaseOverviewPage = new DatabaseOverviewPage();
11+
const common = new Common();
1012

1113
const moduleNameList = ['RediSearch', 'RedisJSON', 'RedisGraph', 'RedisTimeSeries', 'RedisBloom', 'RedisGears', 'RedisAI'];
1214
const moduleList = [myRedisDatabasePage.moduleSearchIcon, myRedisDatabasePage.moduleJSONIcon, myRedisDatabasePage.moduleGraphIcon, myRedisDatabasePage.moduleTimeseriesIcon, myRedisDatabasePage.moduleBloomIcon, myRedisDatabasePage.moduleGearsIcon, myRedisDatabasePage.moduleAIIcon];
1315

1416
fixture `Database modules`
1517
.meta({ type: 'critical_path' })
1618
.page(commonUrl)
17-
.beforeEach(async t => {
19+
.beforeEach(async () => {
1820
await acceptLicenseTerms();
1921
await addNewStandaloneDatabaseApi(ossStandaloneRedisearch);
2022
// Reload Page
21-
await t.eval(() => location.reload());
23+
await common.reloadPage();
2224
})
2325
.afterEach(async() => {
2426
//Delete database

0 commit comments

Comments
 (0)