Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
processUnsupportedCommand,
processUnrepeatableNumber,
} from 'uiSrc/slices/cli/cli-output'
import { CommandMonitor, CommandPSubscribe, Pages } from 'uiSrc/constants'
import { CommandMonitor, CommandPSubscribe, CommandSubscribe, Pages } from 'uiSrc/constants'
import { getCommandRepeat, isRepeatCountCorrect } from 'uiSrc/utils'
import { ConnectionType } from 'uiSrc/slices/interfaces'
import { ClusterNodeRole } from 'uiSrc/slices/interfaces/cli'
Expand Down Expand Up @@ -107,6 +107,13 @@ const CliBodyWrapper = () => {
return
}

// Flow if SUBSCRIBE command was executed
if (checkUnsupportedCommand([CommandSubscribe.toLowerCase()], commandLine)) {
dispatch(concatToOutput(cliTexts.SUBSCRIBE_COMMAND_CLI(Pages.pubSub(instanceId))))
resetCommand()
return
}

if (unsupportedCommand) {
dispatch(processUnsupportedCommand(commandLine, unsupportedCommand, resetCommand))
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
isRepeatCountCorrect
} from 'uiSrc/utils'
import { cliTexts, SelectCommand } from 'uiSrc/constants/cliOutput'
import { CommandMonitor, CommandPSubscribe, Pages } from 'uiSrc/constants'
import { CommandMonitor, CommandPSubscribe, CommandSubscribe, Pages } from 'uiSrc/constants'
import { CommandExecutionStatus } from 'uiSrc/slices/interfaces/cli'

import { cliSettingsSelector } from 'uiSrc/slices/cli/cli-settings'
Expand All @@ -30,6 +30,10 @@ const CommonErrorResponse = (id: string, command = '', result?: any) => {
if (checkUnsupportedCommand([CommandMonitor.toLowerCase()], commandLine)) {
return cliTexts.MONITOR_COMMAND(() => { dispatch(showMonitor()) })
}
// Flow if SUBSCRIBE command was executed
if (checkUnsupportedCommand([CommandSubscribe.toLowerCase()], commandLine)) {
return cliTexts.SUBSCRIBE_COMMAND(Pages.pubSub(instanceId))
}
// Flow if PSUBSCRIBE command was executed
if (checkUnsupportedCommand([CommandPSubscribe.toLowerCase()], commandLine)) {
return cliTexts.PSUBSCRIBE_COMMAND(Pages.pubSub(instanceId))
Expand Down
15 changes: 15 additions & 0 deletions redisinsight/ui/src/constants/cliOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,27 @@ export const cliTexts = {
{' to see the messages published to all channels in your database.'}
</EuiTextColor>
),
SUBSCRIBE_COMMAND: (path: string = '') => (
<EuiTextColor color="danger" key={Date.now()}>
{'Use '}
<EuiLink {...getRouterLinkProps(path)} color="text" data-test-subj="pubsub-page-btn">
Pub/Sub
</EuiLink>
{' tool to subscribe to channels.'}
</EuiTextColor>
),
PSUBSCRIBE_COMMAND_CLI: (path: string = '') => (
[
cliTexts.PSUBSCRIBE_COMMAND(path),
'\n',
]
),
SUBSCRIBE_COMMAND_CLI: (path: string = '') => (
[
cliTexts.SUBSCRIBE_COMMAND(path),
'\n',
]
),
MONITOR_COMMAND: (onClick: () => void) => (
<EuiTextColor color="danger" key={Date.now()}>
{'Use '}
Expand Down
1 change: 1 addition & 0 deletions redisinsight/ui/src/constants/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export enum CommandPrefix {

export const CommandMonitor = 'MONITOR'
export const CommandPSubscribe = 'PSUBSCRIBE'
export const CommandSubscribe = 'SUBSCRIBE'

export enum CommandRediSearch {
Search = 'FT.SEARCH',
Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/pageObjects/components/bottom-panel/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,14 @@ export class Cli {

await this.sendCommandsInCli(scripts);
}

/**
* Get warning message text by command
* @param command command name
*/
async getWarningMessageText(command: string): Promise<string> {

const executedCommand = await this.cliCommandExecuted.withExactText(command);
return await executedCommand.nextSibling(0).textContent;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { acceptLicenseTermsAndAddDatabaseApi, acceptLicenseTerms } from '../../../helpers/database';
import { MyRedisDatabasePage, PubSubPage } from '../../../pageObjects';
import { MyRedisDatabasePage, PubSubPage, WorkbenchPage } from '../../../pageObjects';
import { commonUrl, ossStandaloneConfig, ossStandaloneV5Config } from '../../../helpers/conf';
import { env, rte } from '../../../helpers/constants';
import { verifyMessageDisplayingInPubSub } from '../../../helpers/pub-sub';
import { addNewStandaloneDatabaseApi, deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database';

const myRedisDatabasePage = new MyRedisDatabasePage();
const pubSubPage = new PubSubPage();
const workbenchPage = new WorkbenchPage();

fixture `Subscribe/Unsubscribe from a channel`
.meta({ env: env.web, rte: rte.standalone, type: 'critical_path' })
Expand Down Expand Up @@ -90,17 +91,38 @@ test
await verifyMessageDisplayingInPubSub('message', false);
await t.expect(pubSubPage.totalMessagesCount.exists).notOk('Total counter is still displayed');
});
test('Verify that user can see a internal link to pubsub window under word “Pub/Sub” when he try to run PSUBSCRIBE command in CLI or Workbench', async t => {
test('Verify that user can see a internal link to pubsub window under word “Pub/Sub” when he tries to run PSUBSCRIBE or SUBSCRIBE commands in CLI or Workbench', async t => {
const commandFirst = 'PSUBSCRIBE';
const commandSecond = 'SUBSCRIBE';

// Go to Browser Page
await t.click(myRedisDatabasePage.NavigationPanel.browserButton);
// Verify that user can see a custom message when he try to run PSUBSCRIBE command in CLI or Workbench: “Use Pub/Sub to see the messages published to all channels in your database”
await pubSubPage.Cli.sendCommandInCli('PSUBSCRIBE');
// Verify that user can see a custom message when he tries to run PSUBSCRIBE command in CLI or Workbench: “Use Pub/Sub to see the messages published to all channels in your database”
await pubSubPage.Cli.sendCommandInCli(commandFirst);
await t.click(pubSubPage.Cli.cliExpandButton);
await t.expect(pubSubPage.Cli.cliWarningMessage.textContent).eql('Use Pub/Sub to see the messages published to all channels in your database.', 'Message is not displayed', { timeout: 10000 });
await t.expect(await pubSubPage.Cli.getWarningMessageText(commandFirst)).eql('Use Pub/Sub to see the messages published to all channels in your database.', 'Message is not displayed', { timeout: 10000 });

// Verify internal link to pubsub page in CLI
await t.expect(pubSubPage.Cli.cliLinkToPubSub.exists).ok('Link to pubsub page is not displayed');
await t.click(pubSubPage.Cli.cliLinkToPubSub);
await t.expect(pubSubPage.pubSubPageContainer.exists).ok('Pubsub page is opened');

// Verify that user can see a custom message when he tries to run SUBSCRIBE command in CLI: “Use Pub/Sub tool to subscribe to channels.”
await t.click(pubSubPage.Cli.cliCollapseButton);
await pubSubPage.Cli.sendCommandInCli(commandSecond);
await t.click(pubSubPage.Cli.cliExpandButton);
await t.expect(await pubSubPage.Cli.getWarningMessageText(commandSecond)).eql('Use Pub/Sub tool to subscribe to channels.', 'Message is not displayed', { timeout: 10000 });

// Verify internal link to pubsub page in CLI
await t.expect(pubSubPage.Cli.cliLinkToPubSub.exists).ok('Link to pubsub page is not displayed');
await t.click(pubSubPage.Cli.cliLinkToPubSub);
await t.expect(pubSubPage.pubSubPageContainer.exists).ok('Pubsub page is opened');

// Verify that user can see a custom message when he tries to run SUBSCRIBE command in Workbench: “Use Pub/Sub tool to subscribe to channels.”
await t.click(pubSubPage.NavigationPanel.workbenchButton);
await workbenchPage.sendCommandInWorkbench(commandSecond);
await t.expect(await workbenchPage.commandExecutionResult.textContent).eql('Use Pub/Sub tool to subscribe to channels.', 'Message is not displayed', { timeout: 10000 });

});
test('Verify that the Message field input is preserved until user Publish a message', async t => {
// Fill in Channel and Message inputs
Expand Down