Skip to content

Commit 5f27adc

Browse files
Merge pull request #2144 from RedisInsight/fe/feature/RI-4541_subscribe_command_error_message
#RI-4541 - add subscribe error message
2 parents 0edfd23 + e70ef85 commit 5f27adc

File tree

6 files changed

+66
-7
lines changed

6 files changed

+66
-7
lines changed

redisinsight/ui/src/components/cli/components/cli-body/CliBodyWrapper.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
processUnsupportedCommand,
2020
processUnrepeatableNumber,
2121
} from 'uiSrc/slices/cli/cli-output'
22-
import { CommandMonitor, CommandPSubscribe, Pages } from 'uiSrc/constants'
22+
import { CommandMonitor, CommandPSubscribe, CommandSubscribe, Pages } from 'uiSrc/constants'
2323
import { getCommandRepeat, isRepeatCountCorrect } from 'uiSrc/utils'
2424
import { ConnectionType } from 'uiSrc/slices/interfaces'
2525
import { ClusterNodeRole } from 'uiSrc/slices/interfaces/cli'
@@ -107,6 +107,13 @@ const CliBodyWrapper = () => {
107107
return
108108
}
109109

110+
// Flow if SUBSCRIBE command was executed
111+
if (checkUnsupportedCommand([CommandSubscribe.toLowerCase()], commandLine)) {
112+
dispatch(concatToOutput(cliTexts.SUBSCRIBE_COMMAND_CLI(Pages.pubSub(instanceId))))
113+
resetCommand()
114+
return
115+
}
116+
110117
if (unsupportedCommand) {
111118
dispatch(processUnsupportedCommand(commandLine, unsupportedCommand, resetCommand))
112119
return

redisinsight/ui/src/components/query-card/QueryCardCommonResult/components/CommonErrorResponse/CommonErrorResponse.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
isRepeatCountCorrect
1111
} from 'uiSrc/utils'
1212
import { cliTexts, SelectCommand } from 'uiSrc/constants/cliOutput'
13-
import { CommandMonitor, CommandPSubscribe, Pages } from 'uiSrc/constants'
13+
import { CommandMonitor, CommandPSubscribe, CommandSubscribe, Pages } from 'uiSrc/constants'
1414
import { CommandExecutionStatus } from 'uiSrc/slices/interfaces/cli'
1515

1616
import { cliSettingsSelector } from 'uiSrc/slices/cli/cli-settings'
@@ -30,6 +30,10 @@ const CommonErrorResponse = (id: string, command = '', result?: any) => {
3030
if (checkUnsupportedCommand([CommandMonitor.toLowerCase()], commandLine)) {
3131
return cliTexts.MONITOR_COMMAND(() => { dispatch(showMonitor()) })
3232
}
33+
// Flow if SUBSCRIBE command was executed
34+
if (checkUnsupportedCommand([CommandSubscribe.toLowerCase()], commandLine)) {
35+
return cliTexts.SUBSCRIBE_COMMAND(Pages.pubSub(instanceId))
36+
}
3337
// Flow if PSUBSCRIBE command was executed
3438
if (checkUnsupportedCommand([CommandPSubscribe.toLowerCase()], commandLine)) {
3539
return cliTexts.PSUBSCRIBE_COMMAND(Pages.pubSub(instanceId))

redisinsight/ui/src/constants/cliOutput.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,27 @@ export const cliTexts = {
7070
{' to see the messages published to all channels in your database.'}
7171
</EuiTextColor>
7272
),
73+
SUBSCRIBE_COMMAND: (path: string = '') => (
74+
<EuiTextColor color="danger" key={Date.now()}>
75+
{'Use '}
76+
<EuiLink {...getRouterLinkProps(path)} color="text" data-test-subj="pubsub-page-btn">
77+
Pub/Sub
78+
</EuiLink>
79+
{' tool to subscribe to channels.'}
80+
</EuiTextColor>
81+
),
7382
PSUBSCRIBE_COMMAND_CLI: (path: string = '') => (
7483
[
7584
cliTexts.PSUBSCRIBE_COMMAND(path),
7685
'\n',
7786
]
7887
),
88+
SUBSCRIBE_COMMAND_CLI: (path: string = '') => (
89+
[
90+
cliTexts.SUBSCRIBE_COMMAND(path),
91+
'\n',
92+
]
93+
),
7994
MONITOR_COMMAND: (onClick: () => void) => (
8095
<EuiTextColor color="danger" key={Date.now()}>
8196
{'Use '}

redisinsight/ui/src/constants/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export enum CommandPrefix {
8989

9090
export const CommandMonitor = 'MONITOR'
9191
export const CommandPSubscribe = 'PSUBSCRIBE'
92+
export const CommandSubscribe = 'SUBSCRIBE'
9293

9394
export enum CommandRediSearch {
9495
Search = 'FT.SEARCH',

tests/e2e/pageObjects/components/bottom-panel/cli.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,14 @@ export class Cli {
160160

161161
await this.sendCommandsInCli(scripts);
162162
}
163+
164+
/**
165+
* Get warning message text by command
166+
* @param command command name
167+
*/
168+
async getWarningMessageText(command: string): Promise<string> {
169+
170+
const executedCommand = await this.cliCommandExecuted.withExactText(command);
171+
return await executedCommand.nextSibling(0).textContent;
172+
}
163173
}

tests/e2e/tests/critical-path/pub-sub/subscribe-unsubscribe.e2e.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { acceptLicenseTermsAndAddDatabaseApi, acceptLicenseTerms } from '../../../helpers/database';
2-
import { MyRedisDatabasePage, PubSubPage } from '../../../pageObjects';
2+
import { MyRedisDatabasePage, PubSubPage, WorkbenchPage } from '../../../pageObjects';
33
import { commonUrl, ossStandaloneConfig, ossStandaloneV5Config } from '../../../helpers/conf';
44
import { env, rte } from '../../../helpers/constants';
55
import { verifyMessageDisplayingInPubSub } from '../../../helpers/pub-sub';
66
import { addNewStandaloneDatabaseApi, deleteStandaloneDatabaseApi } from '../../../helpers/api/api-database';
77

88
const myRedisDatabasePage = new MyRedisDatabasePage();
99
const pubSubPage = new PubSubPage();
10+
const workbenchPage = new WorkbenchPage();
1011

1112
fixture `Subscribe/Unsubscribe from a channel`
1213
.meta({ env: env.web, rte: rte.standalone, type: 'critical_path' })
@@ -90,17 +91,38 @@ test
9091
await verifyMessageDisplayingInPubSub('message', false);
9192
await t.expect(pubSubPage.totalMessagesCount.exists).notOk('Total counter is still displayed');
9293
});
93-
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 => {
94+
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 => {
95+
const commandFirst = 'PSUBSCRIBE';
96+
const commandSecond = 'SUBSCRIBE';
97+
9498
// Go to Browser Page
9599
await t.click(myRedisDatabasePage.NavigationPanel.browserButton);
96-
// 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”
97-
await pubSubPage.Cli.sendCommandInCli('PSUBSCRIBE');
100+
// 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”
101+
await pubSubPage.Cli.sendCommandInCli(commandFirst);
98102
await t.click(pubSubPage.Cli.cliExpandButton);
99-
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 });
103+
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 });
104+
100105
// Verify internal link to pubsub page in CLI
101106
await t.expect(pubSubPage.Cli.cliLinkToPubSub.exists).ok('Link to pubsub page is not displayed');
102107
await t.click(pubSubPage.Cli.cliLinkToPubSub);
103108
await t.expect(pubSubPage.pubSubPageContainer.exists).ok('Pubsub page is opened');
109+
110+
// 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.”
111+
await t.click(pubSubPage.Cli.cliCollapseButton);
112+
await pubSubPage.Cli.sendCommandInCli(commandSecond);
113+
await t.click(pubSubPage.Cli.cliExpandButton);
114+
await t.expect(await pubSubPage.Cli.getWarningMessageText(commandSecond)).eql('Use Pub/Sub tool to subscribe to channels.', 'Message is not displayed', { timeout: 10000 });
115+
116+
// Verify internal link to pubsub page in CLI
117+
await t.expect(pubSubPage.Cli.cliLinkToPubSub.exists).ok('Link to pubsub page is not displayed');
118+
await t.click(pubSubPage.Cli.cliLinkToPubSub);
119+
await t.expect(pubSubPage.pubSubPageContainer.exists).ok('Pubsub page is opened');
120+
121+
// 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.”
122+
await t.click(pubSubPage.NavigationPanel.workbenchButton);
123+
await workbenchPage.sendCommandInWorkbench(commandSecond);
124+
await t.expect(await workbenchPage.commandExecutionResult.textContent).eql('Use Pub/Sub tool to subscribe to channels.', 'Message is not displayed', { timeout: 10000 });
125+
104126
});
105127
test('Verify that the Message field input is preserved until user Publish a message', async t => {
106128
// Fill in Channel and Message inputs

0 commit comments

Comments
 (0)