Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 46 additions & 11 deletions tests/e2e/helpers/database.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { t } from 'testcafe';
import { Selector, t } from 'testcafe';
import { AddNewDatabaseParameters, SentinelParameters, OSSClusterParameters } from '../pageObjects/add-redis-database-page';
import { DiscoverMasterGroupsPage } from '../pageObjects/sentinel/discovered-sentinel-master-groups-page';
import {
Expand All @@ -9,7 +9,7 @@ import {
UserAgreementPage,
CliPage
} from '../pageObjects';
import { addNewStandaloneDatabaseApi, discoverSentinelDatabaseApi } from './api/api-database';
import { addNewStandaloneDatabaseApi, discoverSentinelDatabaseApi, getDatabaseByName } from './api/api-database';
import { Common } from './common';

const myRedisDatabasePage = new MyRedisDatabasePage();
Expand Down Expand Up @@ -96,19 +96,17 @@ export async function addOSSClusterDatabase(databaseParameters: OSSClusterParame
export async function addNewRECloudDatabase(cloudAPIAccessKey: string, cloudAPISecretKey: string): Promise<string> {
// Fill the add database form and Submit
await addRedisDatabasePage.addAutodiscoverRECloudDatabase(cloudAPIAccessKey, cloudAPISecretKey);
await t
.click(addRedisDatabasePage.addRedisDatabaseButton)
await t.click(addRedisDatabasePage.addRedisDatabaseButton);
// Select subscriptions
.click(addRedisDatabasePage.selectAllCheckbox)
.click(addRedisDatabasePage.showDatabasesButton);
await t.click(addRedisDatabasePage.selectAllCheckbox);
await t.click(addRedisDatabasePage.showDatabasesButton);
// Select databases for adding
const databaseName = await browserPage.getDatabasesName();
await t
.click(addRedisDatabasePage.selectAllCheckbox)
.click(autoDiscoverREDatabases.addSelectedDatabases)
await t.click(addRedisDatabasePage.selectAllCheckbox);
await t.click(autoDiscoverREDatabases.addSelectedDatabases);
// Wait for database to be exist in the My redis databases list
.click(autoDiscoverREDatabases.viewDatabasesButton)
.expect(myRedisDatabasePage.dbNameList.withExactText(databaseName).exists).ok('The database not displayed', { timeout: 10000 });
await t.click(autoDiscoverREDatabases.viewDatabasesButton);
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databaseName).exists).ok('The database not displayed', { timeout: 10000 });
return databaseName;
}

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

// Accept License terms
Expand Down Expand Up @@ -226,6 +225,17 @@ export async function clearDatabaseInCli(): Promise<void> {
* @param databaseName The database name
*/
export async function deleteDatabase(databaseName: string): Promise<void> {
await t.click(myRedisDatabasePage.myRedisDBButton);
if (await addRedisDatabasePage.addDatabaseButton.exists) {
await deleteDatabaseByNameApi(databaseName);
}
}

/**
* Delete database with custom name
* @param databaseName The database name
*/
export async function deleteCustomDatabase(databaseName: string): Promise<void> {
await t.click(myRedisDatabasePage.myRedisDBButton);
if (await addRedisDatabasePage.addDatabaseButton.exists) {
await myRedisDatabasePage.deleteDatabaseByName(databaseName);
Expand All @@ -245,3 +255,28 @@ export async function acceptTermsAddDatabaseOrConnectToRedisStack(databaseParame
await acceptLicenseAndConnectToRedisStack();
}
}

/**
* Click on the edit database button by name
* @param databaseName The name of the database
*/
export async function clickOnEditDatabaseByName(databaseName: string): Promise<void> {
const databaseId = await getDatabaseByName(databaseName);
const databaseEditBtn = Selector(`[data-testid=edit-instance-${databaseId}]`);

await t.expect(databaseEditBtn.exists).ok(`"${databaseName}" database not displayed`);
await t.click(databaseEditBtn);
}

/**
* Delete database button by name
* @param databaseName The name of the database
*/
export async function deleteDatabaseByNameApi(databaseName: string): Promise<void> {
const databaseId = await getDatabaseByName(databaseName);
const databaseDeleteBtn = Selector(`[data-testid=delete-instance-${databaseId}-icon]`);

await t.expect(databaseDeleteBtn.exists).ok(`"${databaseName}" database not displayed`);
await t.click(databaseDeleteBtn);
await t.click(myRedisDatabasePage.confirmDeleteButton);
}
2 changes: 1 addition & 1 deletion tests/e2e/pageObjects/add-redis-database-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class AddRedisDatabasePage {
showDatabasesButton = Selector('[data-testid=btn-show-databases]');
databaseName = Selector('.euiTableCellContent.column_name');
selectAllCheckbox = Selector('[data-test-subj=checkboxSelectAll]');
databaseIndexCheckbox = Selector('[data-testid=showDb]~div');
databaseIndexCheckbox = Selector('[data-testid=showDb]~div', { timeout: 500 });
connectToDatabaseButton = Selector('[data-testid=connect-to-db-btn]');
connectToRedisStackButton = Selector('[aria-label="Connect to database"]');
discoverSentinelDatabaseButton = Selector('[data-testid=btn-submit]');
Expand Down
17 changes: 16 additions & 1 deletion tests/e2e/pageObjects/browser-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class BrowserPage {
virtualTableContainer = Selector('[data-testid=virtual-table-container]');
streamEntriesContainer = Selector('[data-testid=stream-entries-container]');
streamMessagesContainer = Selector('[data-testid=stream-messages-container]');
loader = Selector('[data-testid=type-loading]');
//LINKS
internalLinkToWorkbench = Selector('[data-testid=internal-workbench-link]');
userSurveyLink = Selector('[data-testid=user-survey-link]');
Expand Down Expand Up @@ -254,6 +255,7 @@ export class BrowserPage {
*/
async commonAddNewKey(keyName: string, TTL?: string): Promise<void> {
await common.waitForElementNotVisible(this.progressLine);
await common.waitForElementNotVisible(this.loader);
await t
.click(this.plusAddKeyButton)
.click(this.addKeyNameInput)
Expand Down Expand Up @@ -316,6 +318,7 @@ export class BrowserPage {
*/
async addSetKey(keyName: string, TTL = ' ', members = ' '): Promise<void> {
await common.waitForElementNotVisible(this.progressLine);
await common.waitForElementNotVisible(this.loader);
await t.click(this.plusAddKeyButton);
await t.click(this.keyTypeDropDown);
await t.click(this.setOption);
Expand All @@ -336,6 +339,7 @@ export class BrowserPage {
*/
async addZSetKey(keyName: string, scores = ' ', TTL = ' ', members = ' '): Promise<void> {
await common.waitForElementNotVisible(this.progressLine);
await common.waitForElementNotVisible(this.loader);
await t.click(this.plusAddKeyButton);
await t.click(this.keyTypeDropDown);
await t.click(this.zsetOption);
Expand All @@ -356,13 +360,14 @@ export class BrowserPage {
*/
async addListKey(keyName: string, TTL = ' ', element = ' '): Promise<void> {
await common.waitForElementNotVisible(this.progressLine);
await common.waitForElementNotVisible(this.loader);
await t.click(this.plusAddKeyButton);
await t.click(this.keyTypeDropDown);
await t.click(this.listOption);
await t.click(this.addKeyNameInput);
await t.typeText(this.addKeyNameInput, keyName, { replace: true, paste: true });
await t.click(this.keyTTLInput);
await t.typeText(this.keyTTLInput, TTL);
await t.typeText(this.keyTTLInput, TTL, { replace: true, paste: true });
await t.click(this.listKeyElementInput);
await t.typeText(this.listKeyElementInput, element, { replace: true, paste: true });
await t.click(this.addKeyButton);
Expand All @@ -377,6 +382,7 @@ export class BrowserPage {
*/
async addHashKey(keyName: string, TTL = ' ', field = ' ', value = ' '): Promise<void> {
await common.waitForElementNotVisible(this.progressLine);
await common.waitForElementNotVisible(this.loader);
await t.click(this.plusAddKeyButton);
await t.click(this.keyTypeDropDown);
await t.click(this.hashOption);
Expand Down Expand Up @@ -490,12 +496,21 @@ export class BrowserPage {
}
}

/**
* Get selector by key name
* @param keyName The name of the key
*/
async getKeySelectorByName(keyName: string): Promise<Selector> {
return Selector(`[data-testid="key-${keyName}"]`);
}

/**
* Verifying if the Key is in the List of keys
* @param keyName The name of the key
*/
async isKeyIsDisplayedInTheList(keyName: string): Promise<boolean> {
const keyNameInTheList = Selector(`[data-testid="key-${keyName}"]`);
await common.waitForElementNotVisible(this.loader);
return keyNameInTheList.exists;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/pageObjects/cli-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class CliPage {
await t.click(this.cliExpandButton);
//Add keys
const keyValueArray = await common.createArrayWithKeyValueAndDelimiter(amount);
await t.typeText(this.cliCommandInput, `${keyCommand} ${keyValueArray.join(' ')}`, { paste: true });
await t.typeText(this.cliCommandInput, `${keyCommand} ${keyValueArray.join(' ')}`, { replace: true, paste: true });
await t.pressKey('enter');
await t.click(this.cliCollapseButton);
}
Expand All @@ -105,7 +105,7 @@ export class CliPage {
await t.click(this.cliExpandButton);
//Add keys
const keyValueArray = await common.createArrayWithKeyAndDelimiter(amount);
await t.typeText(this.cliCommandInput, `DEL ${keyValueArray.join(' ')}`, { paste: true });
await t.typeText(this.cliCommandInput, `DEL ${keyValueArray.join(' ')}`, { replace: true, paste: true });
await t.pressKey('enter');
await t.click(this.cliCollapseButton);
}
Expand Down
9 changes: 4 additions & 5 deletions tests/e2e/pageObjects/my-redis-databases-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ export class MyRedisDatabasePage {
await t.click(this.toastCloseButton);
}
const db = this.dbNameList.withExactText(dbName.trim());
await t
.expect(db.exists).ok(`"${dbName}" database doesn't exist`, {timeout: 10000})
.click(db);
await t.expect(db.exists).ok(`"${dbName}" database doesn't exist`, {timeout: 10000});
await t.click(db);
}

//Delete all the databases from the list
Expand Down Expand Up @@ -115,8 +114,8 @@ export class MyRedisDatabasePage {
*/
async clickOnEditDBByName(databaseName: string): Promise<void> {
const dbNames = this.dbNameList;
const count = await dbNames.count;
for (let i = 0; i < count; i++) {
const count = dbNames.count;
for (let i = 0; i < await count; i++) {
if ((await dbNames.nth(i).innerText || '').includes(databaseName)) {
await t.click(this.editDatabaseButton.nth(i));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ test('Verify that user can delete a Consumer Group', async t => {
for (const id of entryIds) {
const idBefore = await browserPage.streamGroupId.textContent;
await t.click(browserPage.editStreamLastIdButton);
await t.typeText(browserPage.lastIdInput, id, { replace: true });
await t.typeText(browserPage.lastIdInput, id, { replace: true, paste: true });
await t.click(browserPage.saveButton);
await t.expect(browserPage.streamGroupId.textContent).notEql(idBefore, 'The last delivered ID is modified and the table is not reloaded');
}
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/tests/critical-path/browser/context.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ test('Verify that user can see saved executed commands in CLI on Browser page wh
// Execute command in CLI and open Settings page
await t.click(cliPage.cliExpandButton);
for(const command of commands) {
await t.typeText(cliPage.cliCommandInput, command);
await t.typeText(cliPage.cliCommandInput, command, { replace: true, paste: true });
await t.pressKey('enter');
}
await t.click(myRedisDatabasePage.settingsButton);
// Return back to Browser and check executed command in CLI
await t.click(myRedisDatabasePage.browserButton);
for(const command of commands) {
await t.expect(await cliPage.cliCommandExecuted.withExactText(command).exists).ok(`Executed command '${command}' in CLI is saved`);
await t.expect(cliPage.cliCommandExecuted.withExactText(command).exists).ok(`Executed command '${command}' in CLI is saved`);
}
});
test
Expand All @@ -104,7 +104,7 @@ test
await t.click(myRedisDatabasePage.settingsButton);
// Return back to Browser and check key details selected
await t.click(myRedisDatabasePage.browserButton);
await t.expect(await browserPage.keyNameFormDetails.withExactText(keyName).exists).ok('The key details is selected');
await t.expect(browserPage.keyNameFormDetails.withExactText(keyName).exists).ok('The key details is selected');
});
test
.after(async() => {
Expand All @@ -118,7 +118,7 @@ test
await t.click(cliPage.cliExpandButton);
// Create new keys
keys = await common.createArrayWithKeyValue(numberOfItems);
await t.typeText(cliPage.cliCommandInput, `MSET ${keys.join(' ')}`, {paste: true});
await t.typeText(cliPage.cliCommandInput, `MSET ${keys.join(' ')}`, { replace: true, paste: true });
await t.pressKey('enter');
await t.click(cliPage.cliCollapseButton);
await t.click(browserPage.refreshKeysButton);
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/critical-path/browser/filtering.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ test
// Clear filter
await t.click(browserPage.clearFilterButton);
// Check the filtering starts by press Enter
await t.typeText(browserPage.filterByPatterSearchInput, 'InvalidText');
await t.typeText(browserPage.filterByPatterSearchInput, 'InvalidText', { replace: true, paste: true });
await t.pressKey('enter');
await t.expect(browserPage.searchAdvices.exists).ok('The filtering is set');
// Check the filtering starts by clicks the control
await common.reloadPage();
await t.typeText(browserPage.filterByPatterSearchInput, 'InvalidText');
await t.typeText(browserPage.filterByPatterSearchInput, 'InvalidText', { replace: true, paste: true });
await t.click(browserPage.searchButton);
await t.expect(browserPage.searchAdvices.exists).ok('The filtering is set');
});
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/tests/critical-path/browser/stream-key.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ test('Verify that user can add several fields and values during Stream key creat
// Verify that user can see Entity ID filled by * by default on add Stream key form
await t.expect(browserPage.streamEntryId.withAttribute('value', '*').exists).ok('Preselected Stream Entity ID field not correct');
// Verify that user can specify valid custom value for Entry ID
await t.typeText(browserPage.streamEntryId, '0-1', {replace: true});
await t.typeText(browserPage.streamEntryId, '0-1', { replace: true, paste: true});
// Filled fields and value by different data types
for (let i = 0; i < Object.keys(streamData).length; i++) {
await t.typeText(browserPage.streamField.nth(-1), Object.keys(streamData)[i]);
await t.typeText(browserPage.streamValue.nth(-1), Object.values(streamData)[i]);
await t.typeText(browserPage.streamField.nth(-1), Object.keys(streamData)[i], { replace: true, paste: true});
await t.typeText(browserPage.streamValue.nth(-1), Object.values(streamData)[i], { replace: true, paste: true});
await t.scroll(scrollSelector, 'bottom');
await t.expect(browserPage.streamField.count).eql(i + 1, 'Number of added fields not correct');
if (i < Object.keys(streamData).length - 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test('Verify that claim with optional parameters, the message removed from this
await t.click(browserPage.claimPendingMessageButton);
await t.expect(browserPage.optionalParametersSwitcher.withAttribute('aria-checked', 'false').exists).ok('By default toggle for optional parameters is off');
await t.click(browserPage.optionalParametersSwitcher);
await t.typeText(browserPage.claimIdleTimeInput, '100', { replace: true });
await t.typeText(browserPage.claimIdleTimeInput, '100', { replace: true, paste: true});
await t.click(browserPage.forceClaimCheckbox);
await t.click(browserPage.submitButton);
await t.expect(browserPage.streamMessagesContainer.textContent).contains('Your Consumer has no pending messages.', 'The messages is claimed and removed from the table');
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/critical-path/cli/cli-command-helper.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('Verify Command Helper search and filter', async t => {
// Verify default text
await t.expect(cliPage.cliHelperText.textContent).eql(defaultHelperText, 'Default text for CLI Helper is not shown');
// Search any command
await t.typeText(cliPage.cliHelperSearch, 'SET');
await t.typeText(cliPage.cliHelperSearch, 'SET', { replace: true, paste: true });
await t.expect(cliPage.cliHelperOutputTitles.count).gt(0, 'List of commands were not found');
// Clear search input
const clearButton = cliPage.cliHelper.find('[aria-label="Clear input"]');
Expand Down Expand Up @@ -66,7 +66,7 @@ test('Verify Command Helper search and filter', async t => {
// Verify that Command helper cleared when user runs the command in CLI
await t.click(cliPage.cliExpandButton);
// Enter command into CLI
await t.typeText(cliPage.cliCommandInput, COMMAND_APPEND, { speed: 0.5 });
await t.typeText(cliPage.cliCommandInput, COMMAND_APPEND, { speed: 0.5, replace: true, paste: true });
await t.expect(cliPage.filterGroupTypeButton.textContent).notContains(COMMAND_GROUP_SET, 'Filter was not cleared');
await t.expect(cliPage.cliHelperSearch.value).eql('', 'Search was not cleared');

Expand Down
Loading