Skip to content

fix(web): show topic test message send failures - #866

Closed
Aias00 wants to merge 2 commits into
apache:rocketmq-studiofrom
Aias00:fix/studio-topic-send-error-865
Closed

fix(web): show topic test message send failures#866
Aias00 wants to merge 2 commits into
apache:rocketmq-studiofrom
Aias00:fix/studio-topic-send-error-865

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • separate Topic send-message form validation from the send API call
  • keep validation failures local to the form
  • show an explicit error when sendTopicMessage(...) rejects
  • add regression coverage for failed test-message sends

Related Issue

Fixes #865

Tests

  • npm test -- --run src/pages/instance/__tests__/TopicPage.test.tsx
  • npm run lint -- src/pages/instance/topic.tsx src/pages/instance/__tests__/TopicPage.test.tsx (passes with existing fast-refresh warnings)

Copilot AI review requested due to automatic review settings August 3, 2026 14:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR ensures Topic “test message” sends surface API failures to the user while keeping form-validation errors local, and adds a regression test for the failure case (Fixes #865).

Changes:

  • Separates sendForm.validateFields() from the send API call so validation failures don’t get treated as send failures.
  • Adds a user-visible error toast when sendTopicMessage(...) rejects.
  • Adds a Vitest regression test asserting the error toast is shown and the modal remains open on send failure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
web/src/pages/instance/topic.tsx Refactors send handler to isolate validation and show an explicit error on API rejection.
web/src/pages/instance/tests/TopicPage.test.tsx Adds coverage for the “send test message failed” path by asserting message.error is called.
Suppressed comments (1)

web/src/pages/instance/topic.tsx:1

  • The catch block swallows the actual error, which makes debugging/observability harder (no logging, no error details). Consider capturing the error (catch (err)) and at least logging it (or sending to your app’s telemetry) while still showing the user-friendly toast, so failures can be diagnosed in production.
/*

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sendForm.resetFields();
} catch {
// validation error, do nothing
message.error('发送测试消息失败,请稍后重试');

it('shows an error when sending a test message fails', async () => {
const user = userEvent.setup();
const errorSpy = vi.spyOn(message, 'error').mockImplementation(vi.fn());
await waitFor(() => expect(topicServiceMocks.sendTopicMessage).toHaveBeenCalledTimes(1));
expect(errorSpy).toHaveBeenCalledWith('发送测试消息失败,请稍后重试');
expect(dialogTitle).toBeInTheDocument();
errorSpy.mockRestore();
Signed-off-by: liuhy <liuhongyu@apache.org>
@lizhimins

Copy link
Copy Markdown
Member

感谢贡献。发送测试消息失败时的错误提示已由主干的实例持久化改造(#951)覆盖:当前 handleSend 在 catch 中已展示错误提示,且支持 props 文本/键值双模式、连续发送时保留弹窗,功能上已包含本 PR 的诉求,因此关闭。


Thanks for the contribution. Showing topic test-message send failures is already covered by the trunk's instance-persistence work (#951): handleSend now surfaces an error message in the catch branch, and additionally supports both text/KV property modes and keeps the dialog open for consecutive sends. The intent of this PR is already included, so closing accordingly.

@lizhimins lizhimins closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants