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 929df0a90 fix(mock): enforce global topic name uniqueness (#4338)
929df0a90 is described below
commit 929df0a90b8efcf1fe68edb18ff72777431dd54e
Author: aias00 <[email protected]>
AuthorDate: Wed Sep 16 16:07:16 2026 +0800
fix(mock): enforce global topic name uniqueness (#4338)
Signed-off-by: liuhy <[email protected]>
---
web/src/services/topicService.test.ts | 9 +++++----
web/src/services/topicService.ts | 4 +---
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/web/src/services/topicService.test.ts
b/web/src/services/topicService.test.ts
index 43af8c550..a4cf95ab1 100644
--- a/web/src/services/topicService.test.ts
+++ b/web/src/services/topicService.test.ts
@@ -100,14 +100,15 @@ describe('topic service mock data', () => {
expect(exportedTopics).toEqual(directTopics);
});
- it('rejects duplicate topic creates in the same cluster', async () => {
+ it('rejects duplicate topic creates across mock instances and clusters',
async () => {
const existing = (await listTopics({ search: 'order-create' }))[0];
- const before = await listTopics({ clusterId: existing.clusterId });
+ const before = await listTopics({ search: existing.name });
await expect(
createTopic({
name: existing.name,
- clusterId: existing.clusterId,
+ clusterId: 'another-cluster',
+ instanceId: 'another-instance',
namespace: existing.namespace,
type: existing.type,
writeQueues: existing.writeQueues,
@@ -116,7 +117,7 @@ describe('topic service mock data', () => {
}),
).rejects.toThrow(`Topic already exists: ${existing.name}`);
- const after = await listTopics({ clusterId: existing.clusterId });
+ const after = await listTopics({ search: existing.name });
expect(after).toEqual(before);
});
});
diff --git a/web/src/services/topicService.ts b/web/src/services/topicService.ts
index a82101874..a5b593eaf 100644
--- a/web/src/services/topicService.ts
+++ b/web/src/services/topicService.ts
@@ -106,9 +106,7 @@ export const listAllTopics = async (params: TopicQuery =
{}): Promise<Topic[]> =
export async function createTopic(data: Partial<Topic>): Promise<Topic> {
if (isMockMode()) {
- const duplicate = mockTopics.some(
- (topic) => topic.name === data.name && topic.clusterId ===
data.clusterId,
- );
+ const duplicate = mockTopics.some((topic) => topic.name === data.name);
if (duplicate) throw new Error(`Topic already exists: ${data.name}`);
const topic = {