From 64a39ad36de16893a71d24a70a753f16245fd513 Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Thu, 20 Jan 2022 15:27:50 +0300 Subject: [PATCH 1/9] [E2E] Monitor tests are added --- .../components/monitor/Monitor/Monitor.tsx | 2 +- tests/e2e/pageObjects/cli-page.ts | 24 ++++-- tests/e2e/pageObjects/index.ts | 4 +- tests/e2e/pageObjects/monitor-page.ts | 68 +++++++++++++++ .../cli/cli-command-helper.e2e.ts | 4 +- .../critical-path/monitor/monitor.e2e.ts | 83 +++++++++++++++++++ .../tests/regression/monitor/monitor.e2e.ts | 39 +++++++++ 7 files changed, 215 insertions(+), 9 deletions(-) create mode 100644 tests/e2e/pageObjects/monitor-page.ts create mode 100644 tests/e2e/tests/critical-path/monitor/monitor.e2e.ts create mode 100644 tests/e2e/tests/regression/monitor/monitor.e2e.ts diff --git a/redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx b/redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx index 67342ccd56..68e8cf5ab4 100644 --- a/redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx +++ b/redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx @@ -110,7 +110,7 @@ const Monitor = (props: Props) => { /> - + Running Monitor will decrease throughput, avoid running it in production databases diff --git a/tests/e2e/pageObjects/cli-page.ts b/tests/e2e/pageObjects/cli-page.ts index 455acf78ba..5fcaa9440e 100644 --- a/tests/e2e/pageObjects/cli-page.ts +++ b/tests/e2e/pageObjects/cli-page.ts @@ -91,11 +91,11 @@ export class CliPage { } /** - * Add keys from CLI - * @param keyCommand The command from cli to add key - * @param amount The amount of the keys - * @param keyName The name of the keys. The default value is keyName - */ + * Add keys from CLI + * @param keyCommand The command from cli to add key + * @param amount The amount of the keys + * @param keyName The name of the keys. The default value is keyName + */ async addKeysFromCli(keyCommand: string, amount: number, keyName = 'keyName'): Promise{ //Open CLI await t.click(this.cliExpandButton); @@ -105,4 +105,18 @@ export class CliPage { await t.pressKey('enter'); await t.click(this.cliCollapseButton); } + /** + * Get command result execution + * @param command The command for send in CLI + */ + async getSuccessCommandResultFromCli(command: string): Promise{ + //Open CLI + await t.click(this.cliExpandButton); + //Add keys + await t.typeText(this.cliCommandInput, command, { paste: true }); + await t.pressKey('enter'); + const commandResult = await this.cliOutputResponseSuccess.innerText; + await t.click(this.cliCollapseButton); + return commandResult; + } } diff --git a/tests/e2e/pageObjects/index.ts b/tests/e2e/pageObjects/index.ts index e77f470a2a..1810472707 100644 --- a/tests/e2e/pageObjects/index.ts +++ b/tests/e2e/pageObjects/index.ts @@ -9,6 +9,7 @@ import { WorkbenchPage } from './workbench-page'; import { DatabaseOverviewPage } from './database-overview-page'; import { HelpCenterPage } from './help-center-page'; import { ShortcutsPage } from './shortcuts-page'; +import { MonitorPage } from './monitor-page'; export { AddRedisDatabasePage, @@ -21,5 +22,6 @@ export { WorkbenchPage, DatabaseOverviewPage, HelpCenterPage, - ShortcutsPage + ShortcutsPage, + MonitorPage } diff --git a/tests/e2e/pageObjects/monitor-page.ts b/tests/e2e/pageObjects/monitor-page.ts new file mode 100644 index 0000000000..af53f31349 --- /dev/null +++ b/tests/e2e/pageObjects/monitor-page.ts @@ -0,0 +1,68 @@ +import {Selector, t} from 'testcafe'; + +export class MonitorPage { + + //------------------------------------------------------------------------------------------ + //DECLARATION OF TYPES: DOM ELEMENTS and UI COMPONENTS + //*Assign the 'Selector' type to any element/component nested within the constructor. + //------------------------------------------------------------------------------------------ + + expandMonitor: Selector + monitorArea: Selector + runMonitorToggle: Selector + startMonitorButton: Selector + clearMonitorButton: Selector + monitorIsStoppedText: Selector + monitorIsStartedText: Selector + hideMonitor: Selector + closeMonitor: Selector + monitorWarningMessage: Selector + monitorCommandLinePart: Selector + + constructor() { + //------------------------------------------------------------------------------------------- + //DECLARATION OF SELECTORS + //*Declare all elements/components of the relevant page. + //*Target any element/component via data-id, if possible! + //*The following categories are ordered alphabetically (Alerts, Buttons, Checkboxes, etc.). + //------------------------------------------------------------------------------------------- + //BUTTONS + this.expandMonitor = Selector('[data-testid=expand-monitor]'); + this.monitorArea = Selector('[data-testid=monitor]'); + this.runMonitorToggle = Selector('[data-testid=toggle-run-monitor]'); + this.startMonitorButton = Selector('[data-testid=start-monitor]'); + this.clearMonitorButton = Selector('[data-testid=clear-monitor]'); + this.monitorIsStoppedText = Selector('[data-testid=monitor-stopped]'); + this.monitorIsStartedText = Selector('[data-testid=monitor-started]'); + this.hideMonitor = Selector('[data-testid=hide-monitor]'); + this.closeMonitor = Selector('[data-testid=close-monitor]'); + this.monitorWarningMessage = Selector('[data-testid=monitor-warning-message]'); + this.monitorCommandLinePart = Selector('[data-testid=monitor] span'); + } + /** + * Check specific command in Monitor + * @param command A command which should be displayed in monitor + * @param parameters An arguments which should be displayed in monitor + */ + async checkCommandInMonitorResults(command: string, parameters?: string[]): Promise { + const commandArray = command.split(' '); + for (const value of commandArray) { + await t.expect(this.monitorCommandLinePart.withText(value).exists).ok(''); + } + if (!!parameters) { + for (const argument of parameters) { + await t.expect(this.monitorCommandLinePart.withText(argument).exists).ok(''); + } + } + } + /** + * Start monitor function + */ + async startMonitor(): Promise { + await t.click(this.expandMonitor); + await t.click(this.startMonitorButton); + //Check for "info" command that is sent every 5 seconds + await t.wait(5000); + // await this.checkCommandInMonitorResults('info'); + } +} diff --git a/tests/e2e/tests/critical-path/cli/cli-command-helper.e2e.ts b/tests/e2e/tests/critical-path/cli/cli-command-helper.e2e.ts index 6f98978098..be3a83a72e 100644 --- a/tests/e2e/tests/critical-path/cli/cli-command-helper.e2e.ts +++ b/tests/e2e/tests/critical-path/cli/cli-command-helper.e2e.ts @@ -124,7 +124,7 @@ test('Verify that user can type TS. in Command helper and see commands from Redi //Select group from list and remeber commands await cliPage.selectFilterGroupType(COMMAND_GROUP_TIMESERIES); const commandsFilterCount = await cliPage.cliHelperOutputTitles.count; - let timeSeriesCommands = []; + const timeSeriesCommands = []; for(let i = 0; i < commandsFilterCount; i++) { timeSeriesCommands.push(await cliPage.cliHelperOutputTitles.nth(i).textContent); } @@ -146,7 +146,7 @@ test('Verify that user can type GRAPH. in Command helper and see auto-suggestion //Select group from list and remeber commands await cliPage.selectFilterGroupType(COMMAND_GROUP_GRAPH); const commandsFilterCount = await cliPage.cliHelperOutputTitles.count; - let graphCommands = []; + const graphCommands = []; for(let i = 0; i < commandsFilterCount; i++) { graphCommands.push(await cliPage.cliHelperOutputTitles.nth(i).textContent); } diff --git a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts new file mode 100644 index 0000000000..49966bb58d --- /dev/null +++ b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts @@ -0,0 +1,83 @@ +import { addNewStandaloneDatabase } from '../../../helpers/database'; +import { + MyRedisDatabasePage, + UserAgreementPage, + AddRedisDatabasePage, + CliPage, + MonitorPage, + WorkbenchPage, + BrowserPage +} from '../../../pageObjects'; +import { + commonUrl, + ossStandaloneConfig +} from '../../../helpers/conf'; +import { getRandomKeyName } from '../../../helpers/keys'; + +const myRedisDatabasePage = new MyRedisDatabasePage(); +const userAgreementPage = new UserAgreementPage(); +const addRedisDatabasePage = new AddRedisDatabasePage(); +const cliPage = new CliPage(); +const monitorPage = new MonitorPage(); +const workbenchPage = new WorkbenchPage(); +const browserPage = new BrowserPage(); + +fixture `Monitor` + .meta({ type: 'critical_path' }) + .page(commonUrl) + .beforeEach(async t => { + await t.maximizeWindow(); + await userAgreementPage.acceptLicenseTerms(); + await t.expect(addRedisDatabasePage.addDatabaseButton.exists).ok('The add redis database view', { timeout: 20000 }); + await addNewStandaloneDatabase(ossStandaloneConfig); + await myRedisDatabasePage.clickOnDBByName(ossStandaloneConfig.databaseName); + }) +test('Verify that user can work with Monitor', async t => { + const command = 'set'; + //Expand Monitor panel + await t.click(monitorPage.expandMonitor); + //Check that monitor is opened + await t.expect(monitorPage.monitorArea.exists).ok('Monitor area'); + await t.expect(monitorPage.startMonitorButton.exists).ok('Start monitor button'); + //Verify that user can see warning message about monitor + await t.expect(monitorPage.monitorWarningMessage.exists).ok('Monitor warning message'); + await monitorPage.monitorWarningMessage.withText('Running Monitor will decrease throughput, avoid running it in production databases'); + //Verify that user can run monitor + await t.click(monitorPage.startMonitorButton); + await t.expect(monitorPage.monitorIsStartedText.exists).ok('"Monitor is started" text'); + //Verify that user can see run commands in monitor + const keyName = `${getRandomKeyName(10)}-key`; + const keyValue = `${getRandomKeyName(10)}-value`; + await cliPage.getSuccessCommandResultFromCli(`${command} ${keyName} ${keyValue}`); + // await monitorPage.checkLineExistenceInMonitor(command); + await monitorPage.checkCommandInMonitorResults(command, [keyName, keyValue]); +}); +test('Verify that user can see the list of all commands from all clients ran for this Redis database in the list of results in Monitor', async t => { + //Define commands in different clients + const cli_command = 'command'; + const workbench_command = 'hello'; + const common_command = 'info'; + const browser_command = 'ttl'; + //Expand Monitor panel + await t.click(monitorPage.expandMonitor); + //Start monitor (using run button in header) + await t.click(monitorPage.runMonitorToggle); + //Send command in CLI + await cliPage.getSuccessCommandResultFromCli(cli_command); + //Check that command from CLI is displayed in monitor + await monitorPage.checkCommandInMonitorResults(cli_command); + //Refresh the page to send command from Browser client + await t.click(browserPage.refreshKeysButton); + //Check the command from browser client + await monitorPage.checkCommandInMonitorResults(browser_command); + //Open Workbench page to create new client + await t.click(myRedisDatabasePage.workbenchButton); + //Send command in Workbench + await workbenchPage.sendCommandInWorkbench(workbench_command); + //Check that command from Workbench is displayed in monitor + await monitorPage.checkCommandInMonitorResults(workbench_command); + //Wait for info request + await t.wait(5000); + //Check the command from common client + await monitorPage.checkCommandInMonitorResults(common_command); +}); diff --git a/tests/e2e/tests/regression/monitor/monitor.e2e.ts b/tests/e2e/tests/regression/monitor/monitor.e2e.ts new file mode 100644 index 0000000000..81361354a0 --- /dev/null +++ b/tests/e2e/tests/regression/monitor/monitor.e2e.ts @@ -0,0 +1,39 @@ +import { addNewStandaloneDatabase } from '../../../helpers/database'; +import { + MyRedisDatabasePage, + UserAgreementPage, + AddRedisDatabasePage, + MonitorPage +} from '../../../pageObjects'; +import { + commonUrl, + ossStandaloneConfig +} from '../../../helpers/conf'; + +const myRedisDatabasePage = new MyRedisDatabasePage(); +const userAgreementPage = new UserAgreementPage(); +const addRedisDatabasePage = new AddRedisDatabasePage(); +const monitorPage = new MonitorPage(); + +fixture `Monitor` + .meta({ type: 'regression' }) + .page(commonUrl) + .beforeEach(async t => { + await t.maximizeWindow(); + await userAgreementPage.acceptLicenseTerms(); + await t.expect(addRedisDatabasePage.addDatabaseButton.exists).ok('The add redis database view', { timeout: 20000 }); + await addNewStandaloneDatabase(ossStandaloneConfig); + await myRedisDatabasePage.clickOnDBByName(ossStandaloneConfig.databaseName); + }) +test('Verify that when user closes the Monitor by clicking on "Close Monitor" button Monitor stopped', async t => { + //Run monitor + await monitorPage.startMonitor(); + //Close Monitor + await t.click(monitorPage.closeMonitor); + //Verify that monitor is not displayed + await t.expect(monitorPage.monitorArea.visible).notOk('Monitor area'); + //Verify that user open monitor again + await t.click(monitorPage.expandMonitor); + //Verify that when user reopens Monitor history is not displayed + await t.expect(monitorPage.startMonitorButton.visible).ok('Start monitor button'); +}); From d5859fa801a8b822cab60612772ae1668eafb064 Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Thu, 20 Jan 2022 23:32:22 +0300 Subject: [PATCH 2/9] [E2E] Fix monitor tests --- tests/e2e/pageObjects/monitor-page.ts | 9 ++-- .../critical-path/monitor/monitor.e2e.ts | 49 +++++++++++-------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/tests/e2e/pageObjects/monitor-page.ts b/tests/e2e/pageObjects/monitor-page.ts index af53f31349..9d5ae5323d 100644 --- a/tests/e2e/pageObjects/monitor-page.ts +++ b/tests/e2e/pageObjects/monitor-page.ts @@ -47,11 +47,11 @@ export class MonitorPage { async checkCommandInMonitorResults(command: string, parameters?: string[]): Promise { const commandArray = command.split(' '); for (const value of commandArray) { - await t.expect(this.monitorCommandLinePart.withText(value).exists).ok(''); + await t.expect(this.monitorCommandLinePart.withText(value).exists).ok({timeout: 5000}); } if (!!parameters) { for (const argument of parameters) { - await t.expect(this.monitorCommandLinePart.withText(argument).exists).ok(''); + await t.expect(this.monitorCommandLinePart.withText(argument).exists).ok({timeout: 5000}); } } } @@ -61,8 +61,7 @@ export class MonitorPage { async startMonitor(): Promise { await t.click(this.expandMonitor); await t.click(this.startMonitorButton); - //Check for "info" command that is sent every 5 seconds - await t.wait(5000); - // await this.checkCommandInMonitorResults('info'); + //Check for "info" command that is sent automatically every 5 seconds from BE side + await this.checkCommandInMonitorResults('info'); } } diff --git a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts index 49966bb58d..35e97eb9b3 100644 --- a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts @@ -21,6 +21,8 @@ const cliPage = new CliPage(); const monitorPage = new MonitorPage(); const workbenchPage = new WorkbenchPage(); const browserPage = new BrowserPage(); +const keyName = `${getRandomKeyName(10)}-key`; +const keyValue = `${getRandomKeyName(10)}-value`; fixture `Monitor` .meta({ type: 'critical_path' }) @@ -32,25 +34,32 @@ fixture `Monitor` await addNewStandaloneDatabase(ossStandaloneConfig); await myRedisDatabasePage.clickOnDBByName(ossStandaloneConfig.databaseName); }) -test('Verify that user can work with Monitor', async t => { - const command = 'set'; - //Expand Monitor panel - await t.click(monitorPage.expandMonitor); - //Check that monitor is opened - await t.expect(monitorPage.monitorArea.exists).ok('Monitor area'); - await t.expect(monitorPage.startMonitorButton.exists).ok('Start monitor button'); - //Verify that user can see warning message about monitor - await t.expect(monitorPage.monitorWarningMessage.exists).ok('Monitor warning message'); - await monitorPage.monitorWarningMessage.withText('Running Monitor will decrease throughput, avoid running it in production databases'); - //Verify that user can run monitor - await t.click(monitorPage.startMonitorButton); - await t.expect(monitorPage.monitorIsStartedText.exists).ok('"Monitor is started" text'); - //Verify that user can see run commands in monitor - const keyName = `${getRandomKeyName(10)}-key`; - const keyValue = `${getRandomKeyName(10)}-value`; - await cliPage.getSuccessCommandResultFromCli(`${command} ${keyName} ${keyValue}`); - // await monitorPage.checkLineExistenceInMonitor(command); - await monitorPage.checkCommandInMonitorResults(command, [keyName, keyValue]); + .afterEach(async t => { + await t.click(myRedisDatabasePage.myRedisDBButton); + await myRedisDatabasePage.deleteDatabaseByName(ossStandaloneConfig.databaseName); + }) +test + .after(async t => { + await browserPage.deleteKeyByName(keyName); + await t.click(myRedisDatabasePage.myRedisDBButton); + await myRedisDatabasePage.deleteDatabaseByName(ossStandaloneConfig.databaseName); + }) + ('Verify that user can work with Monitor', async t => { + const command = 'set'; + //Verify that user can open Monitor + await t.click(monitorPage.expandMonitor); + //Check that monitor is opened + await t.expect(monitorPage.monitorArea.exists).ok('Monitor area'); + await t.expect(monitorPage.startMonitorButton.exists).ok('Start monitor button'); + //Verify that user can see message inside Monitor "Running Monitor will decrease throughput, avoid running it in production databases." when opens it for the first time + await t.expect(monitorPage.monitorWarningMessage.exists).ok('Monitor warning message'); + await monitorPage.monitorWarningMessage.withText('Running Monitor will decrease throughput, avoid running it in production databases'); + //Verify that user can run Monitor by clicking "Run" command in the message inside Monitor + await t.click(monitorPage.startMonitorButton); + await t.expect(monitorPage.monitorIsStartedText.exists).ok('"Monitor is started" text'); + //Verify that user can see run commands in monitor + await cliPage.getSuccessCommandResultFromCli(`${command} ${keyName} ${keyValue}`); + await monitorPage.checkCommandInMonitorResults(command, [keyName, keyValue]); }); test('Verify that user can see the list of all commands from all clients ran for this Redis database in the list of results in Monitor', async t => { //Define commands in different clients @@ -76,8 +85,6 @@ test('Verify that user can see the list of all commands from all clients ran for await workbenchPage.sendCommandInWorkbench(workbench_command); //Check that command from Workbench is displayed in monitor await monitorPage.checkCommandInMonitorResults(workbench_command); - //Wait for info request - await t.wait(5000); //Check the command from common client await monitorPage.checkCommandInMonitorResults(common_command); }); From eebf68ca23c43f53a28d773bff4b413a64444f93 Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Fri, 21 Jan 2022 00:22:05 +0300 Subject: [PATCH 3/9] [E2E] Add Stop Monitor test --- tests/e2e/tests/regression/monitor/monitor.e2e.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/e2e/tests/regression/monitor/monitor.e2e.ts b/tests/e2e/tests/regression/monitor/monitor.e2e.ts index 81361354a0..0527e95f7a 100644 --- a/tests/e2e/tests/regression/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/regression/monitor/monitor.e2e.ts @@ -25,6 +25,10 @@ fixture `Monitor` await addNewStandaloneDatabase(ossStandaloneConfig); await myRedisDatabasePage.clickOnDBByName(ossStandaloneConfig.databaseName); }) + .afterEach(async t => { + await t.click(myRedisDatabasePage.myRedisDBButton); + await myRedisDatabasePage.deleteDatabaseByName(ossStandaloneConfig.databaseName); + }) test('Verify that when user closes the Monitor by clicking on "Close Monitor" button Monitor stopped', async t => { //Run monitor await monitorPage.startMonitor(); @@ -37,3 +41,13 @@ test('Verify that when user closes the Monitor by clicking on "Close Monitor" bu //Verify that when user reopens Monitor history is not displayed await t.expect(monitorPage.startMonitorButton.visible).ok('Start monitor button'); }); +test('Verify that Monitor is stopped when user clicks on "Stop" button', async t => { + //Run monitor + await monitorPage.startMonitor(); + //Click on Stop Monitor button + await t.click(monitorPage.runMonitorToggle); + //Check for "Monitor is stopped." text + await t.expect(monitorPage.monitorIsStoppedText.visible).ok('Monitor is stopped text'); + //Check that no commands are displayed after "Monitor is stopped" text + await t.expect(monitorPage.monitorIsStoppedText.nextSibling().exists).notOk('No commands in monitor'); +}); From 8e211bbc1c973343f6bf0db60b36ff095a1b14ba Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Fri, 21 Jan 2022 16:16:27 +0300 Subject: [PATCH 4/9] [E2E] Clear and stop monitor tests are added --- tests/e2e/pageObjects/monitor-page.ts | 11 ++++++++-- .../critical-path/monitor/monitor.e2e.ts | 2 +- .../tests/regression/monitor/monitor.e2e.ts | 21 +++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/e2e/pageObjects/monitor-page.ts b/tests/e2e/pageObjects/monitor-page.ts index 9d5ae5323d..60349eb897 100644 --- a/tests/e2e/pageObjects/monitor-page.ts +++ b/tests/e2e/pageObjects/monitor-page.ts @@ -47,11 +47,11 @@ export class MonitorPage { async checkCommandInMonitorResults(command: string, parameters?: string[]): Promise { const commandArray = command.split(' '); for (const value of commandArray) { - await t.expect(this.monitorCommandLinePart.withText(value).exists).ok({timeout: 5000}); + await t.expect(this.monitorCommandLinePart.withText(value).exists).ok({timeout: 6000}); } if (!!parameters) { for (const argument of parameters) { - await t.expect(this.monitorCommandLinePart.withText(argument).exists).ok({timeout: 5000}); + await t.expect(this.monitorCommandLinePart.withText(argument).exists).ok({timeout: 6000}); } } } @@ -64,4 +64,11 @@ export class MonitorPage { //Check for "info" command that is sent automatically every 5 seconds from BE side await this.checkCommandInMonitorResults('info'); } + /** + * Stop monitor function + */ + async stopMonitor(): Promise { + await t.click(this.runMonitorToggle); + await t.expect(this.monitorIsStoppedText.exists).ok('Monitor is stopped text'); + } } diff --git a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts index 35e97eb9b3..132ce06416 100644 --- a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts @@ -66,7 +66,7 @@ test('Verify that user can see the list of all commands from all clients ran for const cli_command = 'command'; const workbench_command = 'hello'; const common_command = 'info'; - const browser_command = 'ttl'; + const browser_command = 'dbsize'; //Expand Monitor panel await t.click(monitorPage.expandMonitor); //Start monitor (using run button in header) diff --git a/tests/e2e/tests/regression/monitor/monitor.e2e.ts b/tests/e2e/tests/regression/monitor/monitor.e2e.ts index 0527e95f7a..32a2747ef8 100644 --- a/tests/e2e/tests/regression/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/regression/monitor/monitor.e2e.ts @@ -51,3 +51,24 @@ test('Verify that Monitor is stopped when user clicks on "Stop" button', async t //Check that no commands are displayed after "Monitor is stopped" text await t.expect(monitorPage.monitorIsStoppedText.nextSibling().exists).notOk('No commands in monitor'); }); +test('Verify that when user refreshes the page the list of results in Monitor is not saved', async t => { + //Run monitor + await monitorPage.startMonitor(); + //Refresh the page + await t.eval(() => location.reload(true)); + //Check that monitor is closed + await t.expect(monitorPage.monitorArea.exists).notOk('Monitor area'); + //Check that monitor area doesn't have any saved results + await t.click(monitorPage.expandMonitor); + await t.expect(monitorPage.monitorWarningMessage.exists).ok('Warning message in monitor'); +}); +test('Verify that when user clicks on "Clear" button in Monitor, all commands history is removed', async t => { + //Run monitor + await monitorPage.startMonitor(); + //Stop Monitor + await monitorPage.stopMonitor(); + //Click on Clear button + await t.click(monitorPage.clearMonitorButton); + //Check that monitor has start screen + await t.expect(monitorPage.startMonitorButton.exists).ok('Start monitor button'); +}); From ad9db136fa7fdc019c836dff61ab35cefb50f088 Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Mon, 24 Jan 2022 17:03:39 +0300 Subject: [PATCH 5/9] [E2E] HTTP/HTTPS error fix for Monitor --- redisinsight/ui/src/components/monitor-config/MonitorConfig.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/redisinsight/ui/src/components/monitor-config/MonitorConfig.tsx b/redisinsight/ui/src/components/monitor-config/MonitorConfig.tsx index 89fb7b1711..307db4b81a 100644 --- a/redisinsight/ui/src/components/monitor-config/MonitorConfig.tsx +++ b/redisinsight/ui/src/components/monitor-config/MonitorConfig.tsx @@ -35,6 +35,7 @@ const MonitorConfig = () => { const newSocket = io(`${getBaseApiUrl()}/monitor`, { forceNew: true, query: { instanceId }, + rejectUnauthorized: false, }) dispatch(setSocket(newSocket)) const payloads: IMonitorDataPayload[] = [] From 598a718d153de49ab4f30cca19a8231a14c3abcd Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Mon, 24 Jan 2022 17:56:49 +0300 Subject: [PATCH 6/9] [E2E] Run Monitor tests only --- tests/e2e/tests/critical-path/monitor/monitor.e2e.ts | 2 +- tests/e2e/tests/regression/cli/cli-command-helper.e2e.ts | 2 +- tests/e2e/tests/regression/cli/cli.e2e.ts | 2 +- tests/e2e/tests/regression/monitor/monitor.e2e.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts index 132ce06416..b1354591f2 100644 --- a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts @@ -24,7 +24,7 @@ const browserPage = new BrowserPage(); const keyName = `${getRandomKeyName(10)}-key`; const keyValue = `${getRandomKeyName(10)}-value`; -fixture `Monitor` +fixture.only `Monitor` .meta({ type: 'critical_path' }) .page(commonUrl) .beforeEach(async t => { diff --git a/tests/e2e/tests/regression/cli/cli-command-helper.e2e.ts b/tests/e2e/tests/regression/cli/cli-command-helper.e2e.ts index af68bced4e..6994a7486b 100644 --- a/tests/e2e/tests/regression/cli/cli-command-helper.e2e.ts +++ b/tests/e2e/tests/regression/cli/cli-command-helper.e2e.ts @@ -16,7 +16,7 @@ const COMMAND_GROUP_HyperLogLog = 'HyperLogLog'; fixture `CLI Command helper` .meta({ type: 'regression' }) .page(commonUrl) - .beforeEach(async t => { + .beforeEach(async() => { await acceptLicenseTermsAndAddDatabase(ossStandaloneConfig, ossStandaloneConfig.databaseName); }) diff --git a/tests/e2e/tests/regression/cli/cli.e2e.ts b/tests/e2e/tests/regression/cli/cli.e2e.ts index 2e745a2d19..a35ad551c2 100644 --- a/tests/e2e/tests/regression/cli/cli.e2e.ts +++ b/tests/e2e/tests/regression/cli/cli.e2e.ts @@ -12,7 +12,7 @@ const common = new Common(); fixture `CLI` .meta({ type: 'regression' }) .page(commonUrl) - .beforeEach(async t => { + .beforeEach(async() => { await acceptLicenseTermsAndAddDatabase(ossStandaloneConfig, ossStandaloneConfig.databaseName); }) test('Verify that user can see CLI is minimized when he clicks the "minimize" button', async t => { diff --git a/tests/e2e/tests/regression/monitor/monitor.e2e.ts b/tests/e2e/tests/regression/monitor/monitor.e2e.ts index 32a2747ef8..9676f4ea5d 100644 --- a/tests/e2e/tests/regression/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/regression/monitor/monitor.e2e.ts @@ -15,7 +15,7 @@ const userAgreementPage = new UserAgreementPage(); const addRedisDatabasePage = new AddRedisDatabasePage(); const monitorPage = new MonitorPage(); -fixture `Monitor` +fixture.only `Monitor` .meta({ type: 'regression' }) .page(commonUrl) .beforeEach(async t => { From 3e81acb33833e2cc6b94c8efe0d1b965fdcc5847 Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Tue, 1 Feb 2022 12:27:19 +0300 Subject: [PATCH 7/9] [E2E] Monitor test with high DB load --- tests/e2e/pageObjects/monitor-page.ts | 2 + .../pageObjects/my-redis-databases-page.ts | 2 +- .../critical-path/monitor/monitor.e2e.ts | 2 +- .../tests/regression/monitor/monitor.e2e.ts | 42 ++++++++++++++++++- tests/e2e/yarn.lock | 4 +- 5 files changed, 46 insertions(+), 6 deletions(-) diff --git a/tests/e2e/pageObjects/monitor-page.ts b/tests/e2e/pageObjects/monitor-page.ts index 60349eb897..e28b02d9ec 100644 --- a/tests/e2e/pageObjects/monitor-page.ts +++ b/tests/e2e/pageObjects/monitor-page.ts @@ -18,6 +18,7 @@ export class MonitorPage { closeMonitor: Selector monitorWarningMessage: Selector monitorCommandLinePart: Selector + monitorCommandLineTimestamp: Selector constructor() { //------------------------------------------------------------------------------------------- @@ -38,6 +39,7 @@ export class MonitorPage { this.closeMonitor = Selector('[data-testid=close-monitor]'); this.monitorWarningMessage = Selector('[data-testid=monitor-warning-message]'); this.monitorCommandLinePart = Selector('[data-testid=monitor] span'); + this.monitorCommandLineTimestamp = Selector('[data-testid=monitor] span').withText(/[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}/); } /** * Check specific command in Monitor diff --git a/tests/e2e/pageObjects/my-redis-databases-page.ts b/tests/e2e/pageObjects/my-redis-databases-page.ts index 30737ccbb4..ef92de99cb 100644 --- a/tests/e2e/pageObjects/my-redis-databases-page.ts +++ b/tests/e2e/pageObjects/my-redis-databases-page.ts @@ -83,7 +83,7 @@ export class MyRedisDatabasePage { const count = await dbNames.count; for(let i = 0; i < count; i++) { - if((await dbNames.nth(1).innerText || '').includes(dbName)) { + if((await dbNames.nth(i).innerText || '').includes(dbName)) { await t.click(this.deleteDatabaseButton.nth(i)); await t.click(this.confirmDeleteButton); break; diff --git a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts index b1354591f2..1698834bcd 100644 --- a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts @@ -60,7 +60,7 @@ test //Verify that user can see run commands in monitor await cliPage.getSuccessCommandResultFromCli(`${command} ${keyName} ${keyValue}`); await monitorPage.checkCommandInMonitorResults(command, [keyName, keyValue]); -}); + }); test('Verify that user can see the list of all commands from all clients ran for this Redis database in the list of results in Monitor', async t => { //Define commands in different clients const cli_command = 'command'; diff --git a/tests/e2e/tests/regression/monitor/monitor.e2e.ts b/tests/e2e/tests/regression/monitor/monitor.e2e.ts index 9676f4ea5d..86f58c07c4 100644 --- a/tests/e2e/tests/regression/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/regression/monitor/monitor.e2e.ts @@ -1,12 +1,15 @@ +import { Chance } from 'chance'; import { addNewStandaloneDatabase } from '../../../helpers/database'; import { MyRedisDatabasePage, UserAgreementPage, AddRedisDatabasePage, - MonitorPage + MonitorPage, + SettingsPage, + BrowserPage } from '../../../pageObjects'; import { - commonUrl, + commonUrl, ossBigStandaloneConfig, ossStandaloneConfig } from '../../../helpers/conf'; @@ -14,6 +17,9 @@ const myRedisDatabasePage = new MyRedisDatabasePage(); const userAgreementPage = new UserAgreementPage(); const addRedisDatabasePage = new AddRedisDatabasePage(); const monitorPage = new MonitorPage(); +const settingsPage = new SettingsPage(); +const browserPage = new BrowserPage(); +const chance = new Chance(); fixture.only `Monitor` .meta({ type: 'regression' }) @@ -72,3 +78,35 @@ test('Verify that when user clicks on "Clear" button in Monitor, all commands hi //Check that monitor has start screen await t.expect(monitorPage.startMonitorButton.exists).ok('Start monitor button'); }); +test + .before(async t => { + await t.maximizeWindow(); + await userAgreementPage.acceptLicenseTerms(); + await t.expect(addRedisDatabasePage.addDatabaseButton.exists).ok('Add Redis database view', { timeout: 20000 }); + await addNewStandaloneDatabase(ossBigStandaloneConfig); + await t.click(myRedisDatabasePage.settingsButton); + await t.click(settingsPage.accordionAdvancedSettings); + await settingsPage.changeKeysToScanValue('20000000'); + await t.click(myRedisDatabasePage.myRedisDBButton); + await myRedisDatabasePage.clickOnDBByName(ossBigStandaloneConfig.databaseName); + }) + .after(async t => { + await t.click(myRedisDatabasePage.settingsButton); + await t.click(settingsPage.accordionAdvancedSettings); + await settingsPage.changeKeysToScanValue('10000'); + await t.click(myRedisDatabasePage.myRedisDBButton); + await myRedisDatabasePage.deleteDatabaseByName(ossBigStandaloneConfig.databaseName); + }) + ('Verify that user can see monitor results in high DB load', async t => { + //Run monitor + await monitorPage.startMonitor(); + //Search by not existed key pattern + await browserPage.searchByKeyName(`${chance.string({ length:10 })}*`); + //Check that the last child is updated + for (let i = 0; i <= 10; i++) { + const previousTimestamp = await monitorPage.monitorCommandLineTimestamp.nth(-1).textContent; + await t.wait(5500); + const nextTimestamp = await monitorPage.monitorCommandLineTimestamp.nth(-1).textContent; + await t.expect(previousTimestamp).notEql(nextTimestamp); + } + }); diff --git a/tests/e2e/yarn.lock b/tests/e2e/yarn.lock index 5bc2a9b1a3..d80bc2eef2 100644 --- a/tests/e2e/yarn.lock +++ b/tests/e2e/yarn.lock @@ -1034,7 +1034,7 @@ "@nodelib/fs.scandir" "2.1.4" fastq "^1.6.0" -"@types/chance@^1.1.3": +"@types/chance@1.1.3": version "1.1.3" resolved "https://registry.yarnpkg.com/@types/chance/-/chance-1.1.3.tgz#d19fe9391288d60fdccd87632bfc9ab2b4523fea" integrity sha512-X6c6ghhe4/sQh4XzcZWSFaTAUOda38GQHmq9BUanYkOE/EO7ZrkazwKmtsj3xzTjkLWmwULE++23g3d3CCWaWw== @@ -1608,7 +1608,7 @@ chalk@^4.1.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chance@^1.1.8: +chance@1.1.8: version "1.1.8" resolved "https://registry.yarnpkg.com/chance/-/chance-1.1.8.tgz#5d6c2b78c9170bf6eb9df7acdda04363085be909" integrity sha512-v7fi5Hj2VbR6dJEGRWLmJBA83LJMS47pkAbmROFxHWd9qmE1esHRZW8Clf1Fhzr3rjxnNZVCjOEv/ivFxeIMtg== From 027a309de9f8aed94874e7aacf8209d7c6668dde Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Tue, 1 Feb 2022 14:25:18 +0300 Subject: [PATCH 8/9] [E2E] Rename Monitor into Profiler in tests --- .../ui/src/components/monitor/Monitor/Monitor.tsx | 2 +- tests/e2e/pageObjects/monitor-page.ts | 2 +- tests/e2e/tests/critical-path/monitor/monitor.e2e.ts | 10 +++++----- tests/e2e/tests/regression/monitor/monitor.e2e.ts | 6 +++--- .../regression/workbench/default-scripts-area.e2e.ts | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx b/redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx index 51c46fe9be..92a2dd0005 100644 --- a/redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx +++ b/redisinsight/ui/src/components/monitor/Monitor/Monitor.tsx @@ -62,7 +62,7 @@ const Monitor = (props: Props) => { /> - + Running Profiler will decrease throughput, avoid running it in production databases diff --git a/tests/e2e/pageObjects/monitor-page.ts b/tests/e2e/pageObjects/monitor-page.ts index e28b02d9ec..a2b24380d4 100644 --- a/tests/e2e/pageObjects/monitor-page.ts +++ b/tests/e2e/pageObjects/monitor-page.ts @@ -71,6 +71,6 @@ export class MonitorPage { */ async stopMonitor(): Promise { await t.click(this.runMonitorToggle); - await t.expect(this.monitorIsStoppedText.exists).ok('Monitor is stopped text'); + await t.expect(this.monitorIsStoppedText.exists).ok('Profiler is stopped text'); } } diff --git a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts index 1698834bcd..fa99f49fac 100644 --- a/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/critical-path/monitor/monitor.e2e.ts @@ -49,14 +49,14 @@ test //Verify that user can open Monitor await t.click(monitorPage.expandMonitor); //Check that monitor is opened - await t.expect(monitorPage.monitorArea.exists).ok('Monitor area'); - await t.expect(monitorPage.startMonitorButton.exists).ok('Start monitor button'); + await t.expect(monitorPage.monitorArea.exists).ok('Profiler area'); + await t.expect(monitorPage.startMonitorButton.exists).ok('Start profiler button'); //Verify that user can see message inside Monitor "Running Monitor will decrease throughput, avoid running it in production databases." when opens it for the first time - await t.expect(monitorPage.monitorWarningMessage.exists).ok('Monitor warning message'); - await monitorPage.monitorWarningMessage.withText('Running Monitor will decrease throughput, avoid running it in production databases'); + await t.expect(monitorPage.monitorWarningMessage.exists).ok('Profiler warning message'); + await monitorPage.monitorWarningMessage.withText('Running Profiler will decrease throughput, avoid running it in production databases'); //Verify that user can run Monitor by clicking "Run" command in the message inside Monitor await t.click(monitorPage.startMonitorButton); - await t.expect(monitorPage.monitorIsStartedText.exists).ok('"Monitor is started" text'); + await t.expect(monitorPage.monitorIsStartedText.innerText).eql('Profiler is started.'); //Verify that user can see run commands in monitor await cliPage.getSuccessCommandResultFromCli(`${command} ${keyName} ${keyValue}`); await monitorPage.checkCommandInMonitorResults(command, [keyName, keyValue]); diff --git a/tests/e2e/tests/regression/monitor/monitor.e2e.ts b/tests/e2e/tests/regression/monitor/monitor.e2e.ts index 86f58c07c4..eeaf905a8d 100644 --- a/tests/e2e/tests/regression/monitor/monitor.e2e.ts +++ b/tests/e2e/tests/regression/monitor/monitor.e2e.ts @@ -41,11 +41,11 @@ test('Verify that when user closes the Monitor by clicking on "Close Monitor" bu //Close Monitor await t.click(monitorPage.closeMonitor); //Verify that monitor is not displayed - await t.expect(monitorPage.monitorArea.visible).notOk('Monitor area'); + await t.expect(monitorPage.monitorArea.visible).notOk('Profiler area'); //Verify that user open monitor again await t.click(monitorPage.expandMonitor); //Verify that when user reopens Monitor history is not displayed - await t.expect(monitorPage.startMonitorButton.visible).ok('Start monitor button'); + await t.expect(monitorPage.startMonitorButton.visible).ok('Start profiler button'); }); test('Verify that Monitor is stopped when user clicks on "Stop" button', async t => { //Run monitor @@ -53,7 +53,7 @@ test('Verify that Monitor is stopped when user clicks on "Stop" button', async t //Click on Stop Monitor button await t.click(monitorPage.runMonitorToggle); //Check for "Monitor is stopped." text - await t.expect(monitorPage.monitorIsStoppedText.visible).ok('Monitor is stopped text'); + await t.expect(monitorPage.monitorIsStoppedText.innerText).eql('Profiler is stopped.'); //Check that no commands are displayed after "Monitor is stopped" text await t.expect(monitorPage.monitorIsStoppedText.nextSibling().exists).notOk('No commands in monitor'); }); diff --git a/tests/e2e/tests/regression/workbench/default-scripts-area.e2e.ts b/tests/e2e/tests/regression/workbench/default-scripts-area.e2e.ts index ccdfd45014..e7e88ac4ce 100644 --- a/tests/e2e/tests/regression/workbench/default-scripts-area.e2e.ts +++ b/tests/e2e/tests/regression/workbench/default-scripts-area.e2e.ts @@ -109,8 +109,8 @@ test('Verify that user can see the siblings menu by clicking on page counter ele await t.expect(workbenchPage.enablementAreaPaginationPopover.visible).ok('The siblings menu is displayed'); const countOfButtons = await workbenchPage.paginationPopoverButtons.count; for (let i = 0; i < countOfButtons; i++) { - let popoverButton = workbenchPage.paginationPopoverButtons.nth(i); - await t.expect(popoverButton.textContent).eql(popoverButtons[i], `The siblings menu button ${popoverButtons[i]} is displayed`); + const popoverButton = workbenchPage.paginationPopoverButtons.nth(i); + await t.expect(popoverButton.textContent).eql(popoverButtons[i], `The siblings menu button ${popoverButtons[i]} is displayed`); } }); test('Verify that user can see the quick navigation section to navigate between siblings under the scrolling content', async t => { From e871621e143037ef2dafd87cb84329bd997b5478 Mon Sep 17 00:00:00 2001 From: Elena Naboko Date: Tue, 1 Feb 2022 14:47:52 +0300 Subject: [PATCH 9/9] [E2E] New oss big standalone is added --- tests/e2e/helpers/conf.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/e2e/helpers/conf.ts b/tests/e2e/helpers/conf.ts index 949cd09ee9..47e5c8d48f 100644 --- a/tests/e2e/helpers/conf.ts +++ b/tests/e2e/helpers/conf.ts @@ -1,3 +1,6 @@ +import { Chance } from 'chance'; +const chance = new Chance(); + // Urls for using in the tests export const commonUrl = process.env.COMMON_URL || 'https://localhost:5000'; @@ -52,3 +55,10 @@ export const invalidOssStandaloneConfig = { databaseUsername: process.env.OSS_STANDALONE_USERNAME, databasePassword: process.env.OSS_STANDALONE_PASSWORD }; +export const ossBigStandaloneConfig = { + host: process.env.OSS_STANDALONE_BIG_HOST || 'oss-standalone-big', + port: process.env.OSS_STANDALONE_BIG_PORT || '6379', + databaseName: process.env.OSS_STANDALONE_BIG_DATABASE_NAME || chance.string({ length: 20 }), + databaseUsername: process.env.OSS_STANDALONE_BIG_USERNAME, + databasePassword: process.env.OSS_STANDALONE_BIG_PASSWORD +};