Skip to content

Commit d1019de

Browse files
authored
Merge pull request #1330 from RedisInsight/e2e/bugfix/fixes-for-unstable-tests
E2e/bugfix/fixes for unstable tests
2 parents 0fcc236 + 58e5427 commit d1019de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+197
-152
lines changed

tests/e2e/helpers/database.ts

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { t } from 'testcafe';
1+
import { Selector, t } from 'testcafe';
22
import { AddNewDatabaseParameters, SentinelParameters, OSSClusterParameters } from '../pageObjects/add-redis-database-page';
33
import { DiscoverMasterGroupsPage } from '../pageObjects/sentinel/discovered-sentinel-master-groups-page';
44
import {
@@ -9,7 +9,7 @@ import {
99
UserAgreementPage,
1010
CliPage
1111
} from '../pageObjects';
12-
import { addNewStandaloneDatabaseApi, discoverSentinelDatabaseApi } from './api/api-database';
12+
import { addNewStandaloneDatabaseApi, discoverSentinelDatabaseApi, getDatabaseByName } from './api/api-database';
1313
import { Common } from './common';
1414

1515
const myRedisDatabasePage = new MyRedisDatabasePage();
@@ -96,19 +96,17 @@ export async function addOSSClusterDatabase(databaseParameters: OSSClusterParame
9696
export async function addNewRECloudDatabase(cloudAPIAccessKey: string, cloudAPISecretKey: string): Promise<string> {
9797
// Fill the add database form and Submit
9898
await addRedisDatabasePage.addAutodiscoverRECloudDatabase(cloudAPIAccessKey, cloudAPISecretKey);
99-
await t
100-
.click(addRedisDatabasePage.addRedisDatabaseButton)
99+
await t.click(addRedisDatabasePage.addRedisDatabaseButton);
101100
// Select subscriptions
102-
.click(addRedisDatabasePage.selectAllCheckbox)
103-
.click(addRedisDatabasePage.showDatabasesButton);
101+
await t.click(addRedisDatabasePage.selectAllCheckbox);
102+
await t.click(addRedisDatabasePage.showDatabasesButton);
104103
// Select databases for adding
105104
const databaseName = await browserPage.getDatabasesName();
106-
await t
107-
.click(addRedisDatabasePage.selectAllCheckbox)
108-
.click(autoDiscoverREDatabases.addSelectedDatabases)
105+
await t.click(addRedisDatabasePage.selectAllCheckbox);
106+
await t.click(autoDiscoverREDatabases.addSelectedDatabases);
109107
// Wait for database to be exist in the My redis databases list
110-
.click(autoDiscoverREDatabases.viewDatabasesButton)
111-
.expect(myRedisDatabasePage.dbNameList.withExactText(databaseName).exists).ok('The database not displayed', { timeout: 10000 });
108+
await t.click(autoDiscoverREDatabases.viewDatabasesButton);
109+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databaseName).exists).ok('The database not displayed', { timeout: 10000 });
112110
return databaseName;
113111
}
114112

@@ -194,6 +192,7 @@ export async function acceptLicenseTermsAndAddRECloudDatabase(databaseParameters
194192
while (!(await dbSelector.exists) && Date.now() - startTime < searchTimeout);
195193
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databaseParameters.databaseName ?? '').exists).ok('The database not displayed', { timeout: 5000 });
196194
await myRedisDatabasePage.clickOnDBByName(databaseParameters.databaseName ?? '');
195+
await common.waitForElementNotVisible(browserPage.progressLine);
197196
}
198197

199198
// Accept License terms
@@ -226,6 +225,17 @@ export async function clearDatabaseInCli(): Promise<void> {
226225
* @param databaseName The database name
227226
*/
228227
export async function deleteDatabase(databaseName: string): Promise<void> {
228+
await t.click(myRedisDatabasePage.myRedisDBButton);
229+
if (await addRedisDatabasePage.addDatabaseButton.exists) {
230+
await deleteDatabaseByNameApi(databaseName);
231+
}
232+
}
233+
234+
/**
235+
* Delete database with custom name
236+
* @param databaseName The database name
237+
*/
238+
export async function deleteCustomDatabase(databaseName: string): Promise<void> {
229239
await t.click(myRedisDatabasePage.myRedisDBButton);
230240
if (await addRedisDatabasePage.addDatabaseButton.exists) {
231241
await myRedisDatabasePage.deleteDatabaseByName(databaseName);
@@ -245,3 +255,28 @@ export async function acceptTermsAddDatabaseOrConnectToRedisStack(databaseParame
245255
await acceptLicenseAndConnectToRedisStack();
246256
}
247257
}
258+
259+
/**
260+
* Click on the edit database button by name
261+
* @param databaseName The name of the database
262+
*/
263+
export async function clickOnEditDatabaseByName(databaseName: string): Promise<void> {
264+
const databaseId = await getDatabaseByName(databaseName);
265+
const databaseEditBtn = Selector(`[data-testid=edit-instance-${databaseId}]`);
266+
267+
await t.expect(databaseEditBtn.exists).ok(`"${databaseName}" database not displayed`);
268+
await t.click(databaseEditBtn);
269+
}
270+
271+
/**
272+
* Delete database button by name
273+
* @param databaseName The name of the database
274+
*/
275+
export async function deleteDatabaseByNameApi(databaseName: string): Promise<void> {
276+
const databaseId = await getDatabaseByName(databaseName);
277+
const databaseDeleteBtn = Selector(`[data-testid=delete-instance-${databaseId}-icon]`);
278+
279+
await t.expect(databaseDeleteBtn.exists).ok(`"${databaseName}" database not displayed`);
280+
await t.click(databaseDeleteBtn);
281+
await t.click(myRedisDatabasePage.confirmDeleteButton);
282+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class AddRedisDatabasePage {
1818
showDatabasesButton = Selector('[data-testid=btn-show-databases]');
1919
databaseName = Selector('.euiTableCellContent.column_name');
2020
selectAllCheckbox = Selector('[data-test-subj=checkboxSelectAll]');
21-
databaseIndexCheckbox = Selector('[data-testid=showDb]~div');
21+
databaseIndexCheckbox = Selector('[data-testid=showDb]~div', { timeout: 500 });
2222
connectToDatabaseButton = Selector('[data-testid=connect-to-db-btn]');
2323
connectToRedisStackButton = Selector('[aria-label="Connect to database"]');
2424
discoverSentinelDatabaseButton = Selector('[data-testid=btn-submit]');

tests/e2e/pageObjects/browser-page.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export class BrowserPage {
100100
virtualTableContainer = Selector('[data-testid=virtual-table-container]');
101101
streamEntriesContainer = Selector('[data-testid=stream-entries-container]');
102102
streamMessagesContainer = Selector('[data-testid=stream-messages-container]');
103+
loader = Selector('[data-testid=type-loading]');
103104
//LINKS
104105
internalLinkToWorkbench = Selector('[data-testid=internal-workbench-link]');
105106
userSurveyLink = Selector('[data-testid=user-survey-link]');
@@ -254,6 +255,7 @@ export class BrowserPage {
254255
*/
255256
async commonAddNewKey(keyName: string, TTL?: string): Promise<void> {
256257
await common.waitForElementNotVisible(this.progressLine);
258+
await common.waitForElementNotVisible(this.loader);
257259
await t
258260
.click(this.plusAddKeyButton)
259261
.click(this.addKeyNameInput)
@@ -316,6 +318,7 @@ export class BrowserPage {
316318
*/
317319
async addSetKey(keyName: string, TTL = ' ', members = ' '): Promise<void> {
318320
await common.waitForElementNotVisible(this.progressLine);
321+
await common.waitForElementNotVisible(this.loader);
319322
await t.click(this.plusAddKeyButton);
320323
await t.click(this.keyTypeDropDown);
321324
await t.click(this.setOption);
@@ -336,6 +339,7 @@ export class BrowserPage {
336339
*/
337340
async addZSetKey(keyName: string, scores = ' ', TTL = ' ', members = ' '): Promise<void> {
338341
await common.waitForElementNotVisible(this.progressLine);
342+
await common.waitForElementNotVisible(this.loader);
339343
await t.click(this.plusAddKeyButton);
340344
await t.click(this.keyTypeDropDown);
341345
await t.click(this.zsetOption);
@@ -356,13 +360,14 @@ export class BrowserPage {
356360
*/
357361
async addListKey(keyName: string, TTL = ' ', element = ' '): Promise<void> {
358362
await common.waitForElementNotVisible(this.progressLine);
363+
await common.waitForElementNotVisible(this.loader);
359364
await t.click(this.plusAddKeyButton);
360365
await t.click(this.keyTypeDropDown);
361366
await t.click(this.listOption);
362367
await t.click(this.addKeyNameInput);
363368
await t.typeText(this.addKeyNameInput, keyName, { replace: true, paste: true });
364369
await t.click(this.keyTTLInput);
365-
await t.typeText(this.keyTTLInput, TTL);
370+
await t.typeText(this.keyTTLInput, TTL, { replace: true, paste: true });
366371
await t.click(this.listKeyElementInput);
367372
await t.typeText(this.listKeyElementInput, element, { replace: true, paste: true });
368373
await t.click(this.addKeyButton);
@@ -377,6 +382,7 @@ export class BrowserPage {
377382
*/
378383
async addHashKey(keyName: string, TTL = ' ', field = ' ', value = ' '): Promise<void> {
379384
await common.waitForElementNotVisible(this.progressLine);
385+
await common.waitForElementNotVisible(this.loader);
380386
await t.click(this.plusAddKeyButton);
381387
await t.click(this.keyTypeDropDown);
382388
await t.click(this.hashOption);
@@ -490,12 +496,21 @@ export class BrowserPage {
490496
}
491497
}
492498

499+
/**
500+
* Get selector by key name
501+
* @param keyName The name of the key
502+
*/
503+
async getKeySelectorByName(keyName: string): Promise<Selector> {
504+
return Selector(`[data-testid="key-${keyName}"]`);
505+
}
506+
493507
/**
494508
* Verifying if the Key is in the List of keys
495509
* @param keyName The name of the key
496510
*/
497511
async isKeyIsDisplayedInTheList(keyName: string): Promise<boolean> {
498512
const keyNameInTheList = Selector(`[data-testid="key-${keyName}"]`);
513+
await common.waitForElementNotVisible(this.loader);
499514
return keyNameInTheList.exists;
500515
}
501516

tests/e2e/pageObjects/cli-page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class CliPage {
9191
await t.click(this.cliExpandButton);
9292
//Add keys
9393
const keyValueArray = await common.createArrayWithKeyValueAndDelimiter(amount);
94-
await t.typeText(this.cliCommandInput, `${keyCommand} ${keyValueArray.join(' ')}`, { paste: true });
94+
await t.typeText(this.cliCommandInput, `${keyCommand} ${keyValueArray.join(' ')}`, { replace: true, paste: true });
9595
await t.pressKey('enter');
9696
await t.click(this.cliCollapseButton);
9797
}
@@ -105,7 +105,7 @@ export class CliPage {
105105
await t.click(this.cliExpandButton);
106106
//Add keys
107107
const keyValueArray = await common.createArrayWithKeyAndDelimiter(amount);
108-
await t.typeText(this.cliCommandInput, `DEL ${keyValueArray.join(' ')}`, { paste: true });
108+
await t.typeText(this.cliCommandInput, `DEL ${keyValueArray.join(' ')}`, { replace: true, paste: true });
109109
await t.pressKey('enter');
110110
await t.click(this.cliCollapseButton);
111111
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ export class MyRedisDatabasePage {
6565
await t.click(this.toastCloseButton);
6666
}
6767
const db = this.dbNameList.withExactText(dbName.trim());
68-
await t
69-
.expect(db.exists).ok(`"${dbName}" database doesn't exist`, {timeout: 10000})
70-
.click(db);
68+
await t.expect(db.exists).ok(`"${dbName}" database doesn't exist`, {timeout: 10000});
69+
await t.click(db);
7170
}
7271

7372
//Delete all the databases from the list
@@ -115,8 +114,8 @@ export class MyRedisDatabasePage {
115114
*/
116115
async clickOnEditDBByName(databaseName: string): Promise<void> {
117116
const dbNames = this.dbNameList;
118-
const count = await dbNames.count;
119-
for (let i = 0; i < count; i++) {
117+
const count = dbNames.count;
118+
for (let i = 0; i < await count; i++) {
120119
if ((await dbNames.nth(i).innerText || '').includes(databaseName)) {
121120
await t.click(this.editDatabaseButton.nth(i));
122121
break;

tests/e2e/tests/critical-path/browser/consumer-group.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ test('Verify that user can delete a Consumer Group', async t => {
172172
for (const id of entryIds) {
173173
const idBefore = await browserPage.streamGroupId.textContent;
174174
await t.click(browserPage.editStreamLastIdButton);
175-
await t.typeText(browserPage.lastIdInput, id, { replace: true });
175+
await t.typeText(browserPage.lastIdInput, id, { replace: true, paste: true });
176176
await t.click(browserPage.saveButton);
177177
await t.expect(browserPage.streamGroupId.textContent).notEql(idBefore, 'The last delivered ID is modified and the table is not reloaded');
178178
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ test('Verify that user can see saved executed commands in CLI on Browser page wh
8181
// Execute command in CLI and open Settings page
8282
await t.click(cliPage.cliExpandButton);
8383
for(const command of commands) {
84-
await t.typeText(cliPage.cliCommandInput, command);
84+
await t.typeText(cliPage.cliCommandInput, command, { replace: true, paste: true });
8585
await t.pressKey('enter');
8686
}
8787
await t.click(myRedisDatabasePage.settingsButton);
8888
// Return back to Browser and check executed command in CLI
8989
await t.click(myRedisDatabasePage.browserButton);
9090
for(const command of commands) {
91-
await t.expect(await cliPage.cliCommandExecuted.withExactText(command).exists).ok(`Executed command '${command}' in CLI is saved`);
91+
await t.expect(cliPage.cliCommandExecuted.withExactText(command).exists).ok(`Executed command '${command}' in CLI is saved`);
9292
}
9393
});
9494
test
@@ -104,7 +104,7 @@ test
104104
await t.click(myRedisDatabasePage.settingsButton);
105105
// Return back to Browser and check key details selected
106106
await t.click(myRedisDatabasePage.browserButton);
107-
await t.expect(await browserPage.keyNameFormDetails.withExactText(keyName).exists).ok('The key details is selected');
107+
await t.expect(browserPage.keyNameFormDetails.withExactText(keyName).exists).ok('The key details is selected');
108108
});
109109
test
110110
.after(async() => {
@@ -118,7 +118,7 @@ test
118118
await t.click(cliPage.cliExpandButton);
119119
// Create new keys
120120
keys = await common.createArrayWithKeyValue(numberOfItems);
121-
await t.typeText(cliPage.cliCommandInput, `MSET ${keys.join(' ')}`, {paste: true});
121+
await t.typeText(cliPage.cliCommandInput, `MSET ${keys.join(' ')}`, { replace: true, paste: true });
122122
await t.pressKey('enter');
123123
await t.click(cliPage.cliCollapseButton);
124124
await t.click(browserPage.refreshKeysButton);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ test
4646
// Clear filter
4747
await t.click(browserPage.clearFilterButton);
4848
// Check the filtering starts by press Enter
49-
await t.typeText(browserPage.filterByPatterSearchInput, 'InvalidText');
49+
await t.typeText(browserPage.filterByPatterSearchInput, 'InvalidText', { replace: true, paste: true });
5050
await t.pressKey('enter');
5151
await t.expect(browserPage.searchAdvices.exists).ok('The filtering is set');
5252
// Check the filtering starts by clicks the control
5353
await common.reloadPage();
54-
await t.typeText(browserPage.filterByPatterSearchInput, 'InvalidText');
54+
await t.typeText(browserPage.filterByPatterSearchInput, 'InvalidText', { replace: true, paste: true });
5555
await t.click(browserPage.searchButton);
5656
await t.expect(browserPage.searchAdvices.exists).ok('The filtering is set');
5757
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ test('Verify that user can add several fields and values during Stream key creat
5353
// Verify that user can see Entity ID filled by * by default on add Stream key form
5454
await t.expect(browserPage.streamEntryId.withAttribute('value', '*').exists).ok('Preselected Stream Entity ID field not correct');
5555
// Verify that user can specify valid custom value for Entry ID
56-
await t.typeText(browserPage.streamEntryId, '0-1', {replace: true});
56+
await t.typeText(browserPage.streamEntryId, '0-1', { replace: true, paste: true});
5757
// Filled fields and value by different data types
5858
for (let i = 0; i < Object.keys(streamData).length; i++) {
59-
await t.typeText(browserPage.streamField.nth(-1), Object.keys(streamData)[i]);
60-
await t.typeText(browserPage.streamValue.nth(-1), Object.values(streamData)[i]);
59+
await t.typeText(browserPage.streamField.nth(-1), Object.keys(streamData)[i], { replace: true, paste: true});
60+
await t.typeText(browserPage.streamValue.nth(-1), Object.values(streamData)[i], { replace: true, paste: true});
6161
await t.scroll(scrollSelector, 'bottom');
6262
await t.expect(browserPage.streamField.count).eql(i + 1, 'Number of added fields not correct');
6363
if (i < Object.keys(streamData).length - 1) {

tests/e2e/tests/critical-path/browser/stream-pending-messages.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ test('Verify that claim with optional parameters, the message removed from this
9797
await t.click(browserPage.claimPendingMessageButton);
9898
await t.expect(browserPage.optionalParametersSwitcher.withAttribute('aria-checked', 'false').exists).ok('By default toggle for optional parameters is off');
9999
await t.click(browserPage.optionalParametersSwitcher);
100-
await t.typeText(browserPage.claimIdleTimeInput, '100', { replace: true });
100+
await t.typeText(browserPage.claimIdleTimeInput, '100', { replace: true, paste: true});
101101
await t.click(browserPage.forceClaimCheckbox);
102102
await t.click(browserPage.submitButton);
103103
await t.expect(browserPage.streamMessagesContainer.textContent).contains('Your Consumer has no pending messages.', 'The messages is claimed and removed from the table');

0 commit comments

Comments
 (0)