Copilot commented on code in PR #3459:
URL:
https://github.com/apache/rocketmq-dashboard/pull/3459#discussion_r3941249250
##########
web/src/components/__tests__/QueueBrowser.test.tsx:
##########
@@ -216,3 +246,76 @@ describe('QueueBrowser request ownership', () => {
await act(async () => queues.resolve([queue('broker-a')]));
});
});
+
+describe('QueueBrowserResults navigation', () => {
+ const queues: QueueOffset[] = [
+ { brokerName: 'broker-a', queueId: 0, minOffset: 0, maxOffset: 12 },
+ { brokerName: 'broker-a', queueId: 1, minOffset: 4, maxOffset: 4 },
+ { brokerName: 'broker-b', queueId: 2, minOffset: 1, maxOffset: 20 },
+ ];
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ beforeAll(() => {
+ Object.defineProperty(window, 'matchMedia', {
+ writable: true,
+ value: vi.fn().mockImplementation(() => ({
+ matches: false,
+ addListener: vi.fn(),
+ removeListener: vi.fn(),
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
+ dispatchEvent: vi.fn(),
+ })),
+ });
+ });
+
+ const renderLoaded = async () => {
+ vi.mocked(getQueueOffsets).mockResolvedValue(queues);
+ const user = userEvent.setup();
+ render(<QueueBrowserViewProbe />);
+ await user.click(screen.getByRole('button', { name: 'topic-a' }));
+ await user.click(screen.getByRole('button', { name: 'load' }));
+ await screen.findByText('broker-b');
+ return user;
+ };
+
+ it('filters queues by broker or queue id while keeping topic-wide totals',
async () => {
+ const user = await renderLoaded();
+
+ await user.type(screen.getByPlaceholderText('搜索 Broker 或 Queue'),
'broker-b');
+
+ expect(screen.getByText('broker-b')).toBeInTheDocument();
+ expect(screen.queryByText('broker-a')).not.toBeInTheDocument();
+ expect(screen.getByTestId('queue-browser-summary')).toHaveTextContent(
+ '显示 1 / 3 个队列,Topic 总消息量 31 条',
+ );
+ });
+
+ it('hides empty queues and shows the displayed count separately', async ()
=> {
+ const user = await renderLoaded();
+
+ await user.click(screen.getByRole('button', { name: '仅显示非空队列' }));
+
+ expect(screen.getByText('broker-a')).toBeInTheDocument();
+ expect(screen.getByText('broker-b')).toBeInTheDocument();
+ expect(screen.queryByText('broker-a-1')).not.toBeInTheDocument();
Review Comment:
This assertion doesn't verify that the empty queue row is hidden: the UI
doesn't render the combined key `broker-a-1` as text, so
`queryByText('broker-a-1')` will always be null even if the row is still
present.
##########
web/src/components/__tests__/QueueBrowser.test.tsx:
##########
@@ -17,10 +17,12 @@
import { act, fireEvent, render, screen, waitFor } from
'@testing-library/react';
import userEvent from '@testing-library/user-event';
+import { App } from 'antd';
import { beforeEach, describe, expect, it, vi } from 'vitest';
Review Comment:
`beforeAll` is used below to install a `matchMedia` mock, but it is not
imported from `vitest`, so this test file will fail to compile/run.
##########
web/src/utils/queueBrowserBacklog.ts:
##########
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
Review Comment:
This new file's ASF license header is missing the standard Apache 2.0
disclaimer lines ("Unless required by applicable law..." through "limitations
under the License.") that are present in other `web/src/utils/*.ts` files.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]