Skip to content

Commit 2fea132

Browse files
committed
Update .circleci and refactor code
1 parent d59cb28 commit 2fea132

File tree

4 files changed

+51
-20
lines changed

4 files changed

+51
-20
lines changed
Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
1-
import {t} from 'testcafe';
1+
import {t, Selector} from 'testcafe';
22
import { WorkbenchPage } from '../pageObjects';
33

44
const workbenchPage = new WorkbenchPage();
55

66
export class WorkbenchActions {
7-
/*
7+
/**
88
Verify after client list command columns are visible
9+
@param columns List of columns to verify
910
*/
10-
async verifyClientListColumnsAreVisible(): Promise<void> {
11-
await t.expect(workbenchPage.clientListTableHeaderCellId.visible).ok('id column is not visible');
12-
await t.expect(workbenchPage.clientListTableHeaderCellAddr.visible).ok('addr column is not visible');
13-
await t.expect(workbenchPage.clientListTableHeaderCellName.visible).ok('name column is not visible');
14-
await t.expect(workbenchPage.clientListTableHeaderCellUser.visible).ok('user column is not visible');
11+
async verifyClientListColumnsAreVisible(columns: string[]): Promise<void> {
12+
await t.switchToIframe(workbenchPage.iframe);
13+
for (const column of columns) {
14+
const columnSelector = Selector(`[data-test-subj^=tableHeaderCell_${column}_]`);
15+
await t.expect(columnSelector.visible).ok(`${column} column is not visible`);
16+
}
17+
await t.switchToMainWindow();
18+
}
19+
/**
20+
Verify after `client list` command table rows are expected count
21+
*/
22+
async verifyClientListTableViewRowCount(): Promise<void>{
23+
await t.click(workbenchPage.selectViewType)
24+
.click(workbenchPage.viewTypeOptionsText);
25+
// get number of rows from text view
26+
const numberOfRowsInTextView = await Selector('[data-testid^=row-]').count - 1;
27+
// select client list table view
28+
await t.click(workbenchPage.selectViewType)
29+
.click(workbenchPage.viewTypeOptionClientList);
30+
await t.switchToIframe(workbenchPage.iframe);
31+
await t.expect(Selector('tbody tr').count).eql(numberOfRowsInTextView);
32+
}
33+
/**
34+
Verify error message after `client list` command if there is no permission to run
35+
*/
36+
async verifyClientListErrorMessage(): Promise<void>{
37+
await t.switchToIframe(workbenchPage.iframe);
38+
await t.expect(Selector('div').withText('NOPERM this user has no permissions to run the \'client\' command or its subcommand').visible)
39+
.ok('NOPERM error message is not displayed');
40+
await t.switchToMainWindow();
1541
}
1642
}

tests/e2e/pageObjects/workbench-page.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ export class WorkbenchPage {
141141
tableViewTypeOption = Selector('[data-test-subj^=view-type-option-Plugin]');
142142
graphViewTypeOption = Selector('[data-test-subj^=view-type-option-Plugin-graph]');
143143
typeSelectedClientsList = Selector('[data-testid=view-type-selected-Plugin-client-list__clients-list]');
144-
clientListTableHeaderCellId = Selector('[data-test-subj]').withAttribute('data-test-subj', /^tableHeaderCell_id_/);
145-
clientListTableHeaderCellAddr = Selector('[data-test-subj]').withAttribute('data-test-subj', /^tableHeaderCell_addr_/);
146-
clientListTableHeaderCellName = Selector('[data-test-subj]').withAttribute('data-test-subj', /^tableHeaderCell_name_/);
147-
clientListTableHeaderCellUser = Selector('[data-test-subj]').withAttribute('data-test-subj', /^tableHeaderCell_user_/);
144+
viewTypeOptionClientList = Selector('[data-test-subj=view-type-option-Plugin-client-list__clients-list]');
145+
viewTypeOptionsText = Selector('[data-test-subj=view-type-option-Text-default__Text]');
148146
/**
149147
* Get card container by command
150148
* @param command The command

tests/e2e/tests/regression/monitor/monitor.e2e.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
MonitorPage,
66
SettingsPage,
77
BrowserPage,
8-
CliPage
8+
CliPage, WorkbenchPage
99
} from '../../../pageObjects';
1010
import {
1111
commonUrl,
@@ -16,6 +16,7 @@ import {
1616
import { rte } from '../../../helpers/constants';
1717
import { addNewStandaloneDatabaseApi, deleteStandaloneDatabaseApi, deleteStandaloneDatabasesApi } from '../../../helpers/api/api-database';
1818
import { Common } from '../../../helpers/common';
19+
import {WorkbenchActions} from '../../../common-actions/workbench-actions';
1920

2021
const myRedisDatabasePage = new MyRedisDatabasePage();
2122
const monitorPage = new MonitorPage();
@@ -24,6 +25,8 @@ const browserPage = new BrowserPage();
2425
const cliPage = new CliPage();
2526
const chance = new Chance();
2627
const common = new Common();
28+
const workbenchPage = new WorkbenchPage();
29+
const workbencActions = new WorkbenchActions();
2730

2831
fixture `Monitor`
2932
.meta({ type: 'regression', rte: rte.standalone })
@@ -115,11 +118,11 @@ test
115118
await t.expect(previousTimestamp).notEql(nextTimestamp, 'Monitor results not correct');
116119
}
117120
});
118-
// Skipped due to redis issue https://redislabs.atlassian.net/browse/RI-4111
121+
// Skipped due to redis issue https://redislabs.atlassian.net/browse/RI-4111
119122
test.skip
120123
.before(async t => {
121124
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName);
122-
await cliPage.sendCommandInCli('acl setuser noperm nopass on +@all ~* -monitor');
125+
await cliPage.sendCommandInCli('acl setuser noperm nopass on +@all ~* -monitor -client');
123126
// Check command result in CLI
124127
await t.click(cliPage.cliExpandButton);
125128
await t.expect(cliPage.cliOutputResponseSuccess.textContent).eql('"OK"', 'Command from autocomplete was not found & executed');
@@ -137,6 +140,7 @@ test.skip
137140
// Delete database
138141
await deleteStandaloneDatabasesApi([ossStandaloneConfig, ossStandaloneNoPermissionsConfig]);
139142
})('Verify that if user doesn\'t have permissions to run monitor, user can see error message', async t => {
143+
const command = 'CLIENT LIST';
140144
// Expand the Profiler
141145
await t.click(monitorPage.expandMonitor);
142146
// Click on run monitor button
@@ -147,4 +151,8 @@ test.skip
147151
await t.expect(monitorPage.monitorNoPermissionsMessage.innerText).eql('The Profiler cannot be started. This user has no permissions to run the \'monitor\' command', 'No Permissions message not found');
148152
// Verify that if user doesn't have permissions to run monitor, run monitor button is not available
149153
await t.expect(monitorPage.runMonitorToggle.withAttribute('disabled').exists).ok('No permissions run icon not found');
154+
await t.click(myRedisDatabasePage.workbenchButton);
155+
await workbenchPage.sendCommandInWorkbench(command);
156+
// Verify that user have the following error when there is no permission to run the CLIENT LIST: "NOPERM this user has no permissions to run the 'CLIENT LIST' command or its subcommand"
157+
await workbencActions.verifyClientListErrorMessage();
150158
});

tests/e2e/tests/regression/workbench/command-results.e2e.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,18 @@ test('Big output in workbench is visible in virtualized table', async t => {
119119
await t.expect(lastExpectedItem.visible).ok('Final execution time message not displayed');
120120
});
121121

122-
test.before(async t => {
122+
test.only.before(async t => {
123123
await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneRedisearch, ossStandaloneRedisearch.databaseName);
124-
// Add index and data
125124
await t.click(myRedisDatabasePage.workbenchButton);
126125
}).after(async t => {
127126
await t.switchToMainWindow();
128127
await deleteStandaloneDatabaseApi(ossStandaloneRedisearch);
129-
})('verify client list plugin shows table', async t => {
128+
})('Verify that user can see the client List visualization available for all users', async t => {
130129
const command = 'CLIENT LIST';
131130
// Send command in workbench to view client list
132131
await workbenchPage.sendCommandInWorkbench(command);
133132
await t.expect(workbenchPage.typeSelectedClientsList.visible).ok('client list view button is not visible');
134-
await t.switchToIframe(workbenchPage.iframe);
135-
// Verify that I can see the client List visualization available for all users.
136-
await workBenchActions.verifyClientListColumnsAreVisible();
133+
await workBenchActions.verifyClientListColumnsAreVisible(['id', 'addr', 'name', 'user']);
134+
// verify table view row count match with text view after client list command
135+
await workBenchActions.verifyClientListTableViewRowCount();
137136
});

0 commit comments

Comments
 (0)