|
| 1 | +import { Selector } from 'testcafe'; |
| 2 | +import { MyRedisDatabasePage, CliPage, OverviewPage, WorkbenchPage } from '../../../pageObjects'; |
| 3 | +import { rte } from '../../../helpers/constants'; |
| 4 | +import { acceptLicenseTermsAndAddOSSClusterDatabase } from '../../../helpers/database'; |
| 5 | +import { commonUrl, ossClusterConfig } from '../../../helpers/conf'; |
| 6 | +import { deleteOSSClusterDatabaseApi, getClusterNodesApi } from '../../../helpers/api/api-database'; |
| 7 | +import { Common } from '../../../helpers/common'; |
| 8 | + |
| 9 | +const overviewPage = new OverviewPage(); |
| 10 | +const myRedisDatabasePage = new MyRedisDatabasePage(); |
| 11 | +const common = new Common(); |
| 12 | +const cliPage = new CliPage(); |
| 13 | +const workbenchPage = new WorkbenchPage(); |
| 14 | + |
| 15 | +const headerColumns = { |
| 16 | + 'Type': 'OSS Cluster', |
| 17 | + 'Version': '7.0.0', |
| 18 | + 'User': 'Default' |
| 19 | +}; |
| 20 | +const keyName = common.generateWord(10); |
| 21 | +const commandToAddKey = `set ${keyName} test`; |
| 22 | + |
| 23 | +fixture `Overview` |
| 24 | + .meta({ type: 'critical_path', rte: rte.ossCluster }) |
| 25 | + .page(commonUrl) |
| 26 | + .beforeEach(async t => { |
| 27 | + await acceptLicenseTermsAndAddOSSClusterDatabase(ossClusterConfig, ossClusterConfig.ossClusterDatabaseName); |
| 28 | + // Go to Analysis Tools page |
| 29 | + await t.click(myRedisDatabasePage.analysisPageButton); |
| 30 | + }) |
| 31 | + .afterEach(async() => { |
| 32 | + await deleteOSSClusterDatabaseApi(ossClusterConfig); |
| 33 | + }); |
| 34 | +test('Overview tab header for OSS Cluster', async t => { |
| 35 | + const uptime = /[1-9][0-9]\s|[0-9]\smin|[1-9][0-9]\smin|[0-9]\sh/; |
| 36 | + // Verify that user see "Overview" tab by default for OSS Cluster |
| 37 | + await t.expect(overviewPage.overviewTab.withAttribute('aria-selected', 'true').exists).ok('The Overview tab not opened'); |
| 38 | + // Verify that user see "Overview" header with OSS Cluster info |
| 39 | + for (const key in headerColumns) { |
| 40 | + const columnSelector = Selector(`[data-testid=cluster-details-item-${key}]`); |
| 41 | + await t.expect(columnSelector.textContent).contains(`${headerColumns[key]}`, `Cluster detail ${key} is incorrect`); |
| 42 | + } |
| 43 | + // Verify that Uptime is displayed as time in seconds or minutes from start |
| 44 | + await t.expect(overviewPage.clusterDetailsUptime.textContent).match(uptime, 'Uptime value is not correct'); |
| 45 | +}); |
| 46 | +test |
| 47 | + .after(async() => { |
| 48 | + //Clear database and delete |
| 49 | + await cliPage.sendCommandInCli(`DEL ${keyName}`); |
| 50 | + await cliPage.sendCommandInCli('FT.DROPINDEX idx:schools DD'); |
| 51 | + await deleteOSSClusterDatabaseApi(ossClusterConfig); |
| 52 | + })('Primary node statistics table displaying', async t => { |
| 53 | + // Remember initial table values |
| 54 | + const initialValues: number[] = []; |
| 55 | + const nodes = (await getClusterNodesApi(ossClusterConfig)).sort(); |
| 56 | + const columns = ['Commands/s', 'Clients', 'Total Keys', 'Network Input', 'Network Output', 'Total Memory']; |
| 57 | + for (const column in columns) { |
| 58 | + initialValues.push(await overviewPage.getTotalValueByColumnName(column)); |
| 59 | + } |
| 60 | + const nodesNumberInHeader = parseInt((await overviewPage.tableHeaderCell.nth(0).textContent).match(/\d+/)![0]); |
| 61 | + |
| 62 | + // Add key from CLI |
| 63 | + await t.click(cliPage.cliExpandButton); |
| 64 | + await t.typeText(cliPage.cliCommandInput, commandToAddKey); |
| 65 | + await t.pressKey('enter'); |
| 66 | + await t.click(cliPage.cliCollapseButton); |
| 67 | + // Verify nodes in header column equal to rows |
| 68 | + await t.expect(await overviewPage.getPrimaryNodesCount()).eql(nodesNumberInHeader, 'Primary nodes in table are not displayed'); |
| 69 | + // Verify that all nodes from BE response are displayed in table |
| 70 | + for (const node of nodes) { |
| 71 | + await t.expect(overviewPage.tableRow.nth(nodes.indexOf(node)).textContent).contains(node, `Node ${node} is not displayed in table`); |
| 72 | + } |
| 73 | + // Go to Workbench page |
| 74 | + await t.click(myRedisDatabasePage.workbenchButton); |
| 75 | + //Run Create hash index command to load network and memory |
| 76 | + await t.click(workbenchPage.documentButtonInQuickGuides); |
| 77 | + await t.click(workbenchPage.internalLinkWorkingWithHashes); |
| 78 | + await t.click(workbenchPage.preselectCreateHashIndex); |
| 79 | + await t.click(workbenchPage.submitCommandButton); |
| 80 | + // Go to Analysis Tools page |
| 81 | + await t.click(myRedisDatabasePage.analysisPageButton); |
| 82 | + // Verify that values in table are dynamic |
| 83 | + for (const column in columns) { |
| 84 | + await t.expect(await overviewPage.getTotalValueByColumnName(column)).notEql(initialValues[columns.indexOf(column)], `${column} not dynamic`); |
| 85 | + } |
| 86 | + }); |
0 commit comments