This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new ebef1393a fix(web): type the send-message result the way the API 
returns it (#4869)
ebef1393a is described below

commit ebef1393a32264bcde2ff23c3b74d7c6edb4b7f6
Author: Wang1rrr <[email protected]>
AuthorDate: Thu Sep 24 10:47:38 2026 +0800

    fix(web): type the send-message result the way the API returns it (#4869)
    
    `POST /api/topics/send` answers with `SendMessageVO.sendTime` as a 
primitive long of epoch millis in all three providers and the AI tool schema 
already publishes it as an integer, while api-spec, the web type and the mock 
data layer all promised an ISO-8601 string — so mock mode and a real cluster 
returned different shapes for the same field and no test pinned either. The 
declarations are aligned with the server (number in the spec field table and 
example, number on `SendTopicMessageR [...]
---
 docs/api-spec.md                                    |  4 ++--
 web/src/api/metadata.test.ts                        |  2 +-
 web/src/api/metadata.ts                             |  3 ++-
 web/src/pages/instance/__tests__/TopicPage.test.tsx |  2 +-
 web/src/services/topicService.test.ts               | 11 +++++++++++
 web/src/services/topicService.ts                    |  2 +-
 6 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/docs/api-spec.md b/docs/api-spec.md
index 8500d60a1..8fc071c0b 100644
--- a/docs/api-spec.md
+++ b/docs/api-spec.md
@@ -892,7 +892,7 @@ POST /api/topics/send
 | 字段 | 类型 | 说明 |
 |------|------|------|
 | `msgId` | `string` | 消息 ID |
-| `sendTime` | `string` | 发送时间 (ISO 8601) |
+| `sendTime` | `number` | 发送时间(Unix 毫秒时间戳) |
 | `offsetMsgId` | `string` | 含偏移量的消息 ID |
 
 **示例:**
@@ -913,7 +913,7 @@ POST /api/topics/send
 // Response
 {
   "msgId": "7F000001234567890000",
-  "sendTime": "2026-07-08T10:30:45.123Z",
+  "sendTime": 1783506645123,
   "offsetMsgId": "7F000001234567890000-0:0:0:0"
 }
 ```
diff --git a/web/src/api/metadata.test.ts b/web/src/api/metadata.test.ts
index e83e19322..03bb2d528 100644
--- a/web/src/api/metadata.test.ts
+++ b/web/src/api/metadata.test.ts
@@ -143,7 +143,7 @@ describe('topic metadata API', () => {
     await expect(deleteTopic(topic.name, 
'instance-1')).resolves.toBeUndefined();
     await expect(
       sendTopicMessage({ topic: topic.name, instanceId: 'instance-1', body: 
'{"id":1}' }),
-    ).resolves.toMatchObject({ msgId: 'msg-1' });
+    ).resolves.toMatchObject({ msgId: 'msg-1', sendTime: 1 });
   });
 
   it('passes consumer group import and export contracts through API 
endpoints', async () => {
diff --git a/web/src/api/metadata.ts b/web/src/api/metadata.ts
index 3dacf4c79..b11ca24ec 100644
--- a/web/src/api/metadata.ts
+++ b/web/src/api/metadata.ts
@@ -286,7 +286,8 @@ export interface SendTopicMessageRequest {
 
 export interface SendTopicMessageResult {
   msgId: string;
-  sendTime: string;
+  /** Epoch milliseconds, mirroring the server's `SendMessageVO.sendTime`. */
+  sendTime: number;
   offsetMsgId: string;
 }
 
diff --git a/web/src/pages/instance/__tests__/TopicPage.test.tsx 
b/web/src/pages/instance/__tests__/TopicPage.test.tsx
index d426ac9a4..530ada3e9 100644
--- a/web/src/pages/instance/__tests__/TopicPage.test.tsx
+++ b/web/src/pages/instance/__tests__/TopicPage.test.tsx
@@ -185,7 +185,7 @@ describe('TopicPage', () => {
     });
     topicServiceMocks.sendTopicMessage.mockResolvedValue({
       msgId: 'MSG-0001',
-      sendTime: '2026-01-02T00:00:00Z',
+      sendTime: Date.parse('2026-01-02T00:00:00Z'),
       offsetMsgId: 'OFFSET-0001',
     });
     instanceServiceMocks.listInstances.mockResolvedValue([
diff --git a/web/src/services/topicService.test.ts 
b/web/src/services/topicService.test.ts
index a4cf95ab1..6f5f063d5 100644
--- a/web/src/services/topicService.test.ts
+++ b/web/src/services/topicService.test.ts
@@ -22,6 +22,7 @@ import {
   getTopicRoutes,
   listAllTopics,
   listTopics,
+  sendTopicMessage,
 } from './topicService';
 
 vi.mock('./dataMode', () => ({ isMockMode: () => true }));
@@ -120,4 +121,14 @@ describe('topic service mock data', () => {
     const after = await listTopics({ search: existing.name });
     expect(after).toEqual(before);
   });
+
+  it('reports the send time as epoch millis, the shape the API returns', async 
() => {
+    const before = Date.now();
+
+    const result = await sendTopicMessage({ topic: 'order-create', body: 
'{"id":1}' });
+
+    expect(typeof result.sendTime).toBe('number');
+    expect(result.sendTime).toBeGreaterThanOrEqual(before);
+    expect(result.sendTime).toBeLessThanOrEqual(Date.now());
+  });
 });
diff --git a/web/src/services/topicService.ts b/web/src/services/topicService.ts
index a5b593eaf..a55bae5d9 100644
--- a/web/src/services/topicService.ts
+++ b/web/src/services/topicService.ts
@@ -238,7 +238,7 @@ export async function sendTopicMessage(
     await new Promise((r) => setTimeout(r, 400));
     return {
       msgId: `7F${Math.random().toString(16).slice(2, 18).toUpperCase()}`,
-      sendTime: new Date().toISOString(),
+      sendTime: Date.now(),
       offsetMsgId: `7F${Math.random().toString(16).slice(2, 
18).toUpperCase()}-0:0:0:0`,
     };
   }

Reply via email to