|
| 1 | +import { Selector } from 'testcafe'; |
| 2 | +import { rte } from '../../../helpers/constants'; |
| 3 | +import { acceptLicenseTermsAndAddDatabaseApi } from '../../../helpers/database'; |
| 4 | +import { MyRedisDatabasePage, WorkbenchPage } from '../../../pageObjects'; |
| 5 | +import { commonUrl, ossStandaloneConfig } from '../../../helpers/conf'; |
| 6 | +import { deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database'; |
| 7 | + |
| 8 | +const myRedisDatabasePage = new MyRedisDatabasePage(); |
| 9 | +const workbenchPage = new WorkbenchPage(); |
| 10 | +const counter = 7; |
| 11 | +const command = 'info'; |
| 12 | +const commands = ['set key test', 'get key', 'del key']; |
| 13 | +const commandsResult = ['OK', 'test', '1']; |
| 14 | +const commandsNumber = commands.length; |
| 15 | +const commandsString = commands.join('\n'); |
| 16 | + |
| 17 | +fixture `Workbench Group Mode` |
| 18 | + .meta({ rte: rte.standalone, type: 'regression' }) |
| 19 | + .page(commonUrl) |
| 20 | + .beforeEach(async t => { |
| 21 | + await acceptLicenseTermsAndAddDatabaseApi(ossStandaloneConfig, ossStandaloneConfig.databaseName); |
| 22 | + //Go to Workbench page |
| 23 | + await t.click(myRedisDatabasePage.workbenchButton); |
| 24 | + }) |
| 25 | + .afterEach(async() => { |
| 26 | + //Delete database |
| 27 | + await deleteStandaloneDatabaseApi(ossStandaloneConfig); |
| 28 | + }); |
| 29 | +test('Verify that user can run the commands from the Editor in the group mode', async t => { |
| 30 | + await t.click(workbenchPage.groupMode); |
| 31 | + // Verify that user can run a command with quantifier and see results in group(10 info) |
| 32 | + await workbenchPage.sendCommandInWorkbench(`${counter} ${command}`); |
| 33 | + // Verify that user can see number of total commands in group, success commands, number of failed commands in header summary in Workbench |
| 34 | + await t.expect(workbenchPage.queryCardCommand.textContent).eql(`${counter} Command(s) - ${counter} success, 0 error(s)`, 'Not valid summary'); |
| 35 | + // Verify that user can see full list of commands with results run in group |
| 36 | + await t.expect(workbenchPage.queryTextResult.find(workbenchPage.cssWorkbenchCommandInHistory).withText(`> ${command}`).count).eql(counter, 'Number of commands is not correct'); |
| 37 | + await t.expect(workbenchPage.queryTextResult.find(workbenchPage.cssWorkbenchCommandResultInHistory).count).eql(counter, 'Number of command result is not correct'); |
| 38 | + // Verify that if the only one command is executed in group, the result will be displayed as for group mode |
| 39 | + await workbenchPage.sendCommandInWorkbench(`${command}`); |
| 40 | + await t.expect(workbenchPage.queryCardCommand.textContent).eql('1 Command(s) - 1 success, 0 error(s)', 'Not valid summary for 1 command'); |
| 41 | + // Verify that user can use keyboard shortcut Ctrl+Shift+G to enable the group mode |
| 42 | + await t.click(workbenchPage.queryInput); |
| 43 | + await t.pressKey('shift+ctrl+g'); |
| 44 | + await workbenchPage.sendCommandInWorkbench(commandsString); |
| 45 | + await t.expect(workbenchPage.queryCardCommand.textContent).notEql(`${commandsNumber} Command(s) - ${commandsNumber} success, 0 error(s)`, 'Commands are sent in groups'); |
| 46 | + for (let i = 0; i++; i < commandsNumber) { |
| 47 | + await workbenchPage.checkWorkbenchCommandResult(command[i], commandsResult[i], i); |
| 48 | + } |
| 49 | +}); |
| 50 | +// Skip due to testcafe doesn't work with clipboard buffer. Need to add client function to check this test |
| 51 | +test.skip('Verify that when user clicks on copy icon for group result, all commands are copied', async t => { |
| 52 | + await t.click(workbenchPage.groupMode); |
| 53 | + await workbenchPage.sendCommandInWorkbench(`${commandsString}`); // 3 commands are sent in group mode |
| 54 | + // Copy commands from group result |
| 55 | + await t.click(workbenchPage.copyCommand); |
| 56 | + await t.rightClick(workbenchPage.queryInputScriptArea); |
| 57 | + await t.click(Selector('span').withAttribute('aria-label', 'Paste')); |
| 58 | + await t.pressKey('ctrl+enter'); |
| 59 | + await t.expect(workbenchPage.queryCardCommand.textContent).eql(`${commandsNumber} Command(s) - ${commandsNumber} success, 0 error(s)`, 'Not valid summary'); |
| 60 | +}); |
| 61 | +test('Verify that user can see group results in full mode', async t => { |
| 62 | + await t.click(workbenchPage.groupMode); |
| 63 | + await workbenchPage.sendCommandInWorkbench(`${commandsString}`); // 3 commands are sent in group mode |
| 64 | + // Open full mode |
| 65 | + await t.click(workbenchPage.fullScreenButton); |
| 66 | + await t.expect(workbenchPage.queryCardCommand.textContent).eql(`${commandsNumber} Command(s) - ${commandsNumber} success, 0 error(s)`, 'Not valid summary'); |
| 67 | + await t.expect(workbenchPage.queryTextResult.find(workbenchPage.cssWorkbenchCommandInHistory).withText('> ').count).eql(commandsNumber, 'Number of commands is not correct'); |
| 68 | + await t.expect(workbenchPage.queryTextResult.find(workbenchPage.cssWorkbenchCommandResultInHistory).count).eql(commandsNumber, 'Number of command result is not correct'); |
| 69 | +}); |
0 commit comments