|
| 1 | +import { Chance } from 'chance'; |
| 2 | +import { Selector } from 'testcafe'; |
| 3 | +import { MyRedisDatabasePage, MemoryEfficiencyPage, BrowserPage, CliPage } from '../../../pageObjects'; |
| 4 | +import { rte } from '../../../helpers/constants'; |
| 5 | +import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database'; |
| 6 | +import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf'; |
| 7 | +import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database'; |
| 8 | +import { populateDBWithHashes } from '../../../helpers/keys'; |
| 9 | + |
| 10 | +const memoryEfficiencyPage = new MemoryEfficiencyPage(); |
| 11 | +const myRedisDatabasePage = new MyRedisDatabasePage(); |
| 12 | +const browserPage = new BrowserPage(); |
| 13 | +const cliPage = new CliPage(); |
| 14 | +const chance = new Chance(); |
| 15 | + |
| 16 | +const keyToAddParameters = { keysCount: 13, keyNameStartWith: 'hashKey'}; |
| 17 | +const members = [...Array(100).keys()].toString().replace(/,/g, ' '); // The smallest key |
| 18 | +const keyNamesMemory = ['string', 'list', 'bloom', 'set']; |
| 19 | +const keyNamesLength = ['string', 'set', 'list']; |
| 20 | +const mbloomCommand = 'bf.add bloom 1'; |
| 21 | +const listCommand = `rpush list ${members.slice(0, -3)}`; |
| 22 | +const stringCommand = `set string "${chance.paragraph({ sentences: 100 })}"`; // The biggest key |
| 23 | +const setCommand = `sadd set ${members}`; // Middle key |
| 24 | + |
| 25 | +fixture `Memory Efficiency Top Keys Table` |
| 26 | + .meta({ type: 'critical_path', rte: rte.standalone }) |
| 27 | + .page(commonUrl); |
| 28 | +test |
| 29 | + .before(async t => { |
| 30 | + await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName); |
| 31 | + // Create keys |
| 32 | + await populateDBWithHashes(ossStandaloneConfig.host, ossStandaloneConfig.port, keyToAddParameters); |
| 33 | + // Go to Analysis Tools page |
| 34 | + await t.click(myRedisDatabasePage.analysisPageButton); |
| 35 | + }) |
| 36 | + .after(async() => { |
| 37 | + await cliPage.sendCommandInCli('flushdb'); |
| 38 | + await deleteStandaloneDatabaseApi(ossStandaloneConfig); |
| 39 | + })('Top Keys displaying in Summary of big keys', async t => { |
| 40 | + // Verify that user can see “-” as length for all unsupported data types |
| 41 | + await cliPage.sendCommandInCli(mbloomCommand); |
| 42 | + await t.click(memoryEfficiencyPage.newReportBtn); |
| 43 | + await t.expect(Selector('[data-testid=length-empty-bloom]').textContent).eql('-', 'Length is defined for unknown types'); |
| 44 | + // Verify that user cannot see quantifier if keys are less than 15 |
| 45 | + await t.expect(memoryEfficiencyPage.topKeysTitle.textContent).eql('TOP KEYS', 'Title is not correct'); |
| 46 | + // Verify that top 15 keys are displayed per memory |
| 47 | + await cliPage.sendCommandInCli(listCommand); |
| 48 | + await cliPage.sendCommandInCli(stringCommand); |
| 49 | + await cliPage.sendCommandInCli(setCommand); |
| 50 | + await t.click(memoryEfficiencyPage.newReportBtn); |
| 51 | + await t.expect(memoryEfficiencyPage.topKeysTitle.textContent).eql('TOP 15 KEYS', 'Title is not correct'); |
| 52 | + await t.expect(memoryEfficiencyPage.topKeysKeyName.count).eql(15, 'Number of lines is not 15'); |
| 53 | + // Verify that sorting by Key Size DESC applied by default in by Memory tab |
| 54 | + for (let i = 0; i < 4; i++) { |
| 55 | + await t.expect(memoryEfficiencyPage.topKeysKeyName.nth(i).textContent).eql(keyNamesMemory[i], 'Key name by Memory order is not correct'); |
| 56 | + } |
| 57 | + // Verify that top 15 keys are displayed per length |
| 58 | + await t.click(memoryEfficiencyPage.sortByLength); |
| 59 | + await t.expect(memoryEfficiencyPage.topKeysKeyName.count).eql(15, 'Number of lines is not 15'); |
| 60 | + // Verify that sorting by Length DESC applied by default in by Length tab |
| 61 | + for (let i = 0; i < 3; i++) { |
| 62 | + await t.expect(memoryEfficiencyPage.topKeysKeyName.nth(i).textContent).eql(keyNamesLength[i], 'Key name by Length order is not correct'); |
| 63 | + } |
| 64 | + // Verify that user can click on a key name and see key details in Browser |
| 65 | + await t.click(memoryEfficiencyPage.topKeysKeyName.nth(1).find('button')); |
| 66 | + await t.expect(browserPage.keyNameFormDetails.find('b').textContent).eql(keyNamesLength[1]); |
| 67 | + }); |
0 commit comments