Copilot commented on code in PR #4777:
URL:
https://github.com/apache/rocketmq-dashboard/pull/4777#discussion_r4063654980
##########
web/src/pages/instance/__tests__/MessagePage.test.tsx:
##########
@@ -276,6 +277,71 @@ describe('Message page query history', () => {
expect(messageServiceMocks.queryMessages).not.toHaveBeenCalled();
});
+ it.each([
+ ['UnsafeInteger', '{"orderId":9007199254740993}'],
+ ['Int64Max', '{"orderId":9223372036854775807}'],
+ ['SafeInteger', '{\n "orderId": 9007199254740991\n}'],
+ ['QuotedId', '{\n "orderId": "9223372036854775807"\n}'],
+ ['JsonWhitespace', '{\r\n\t"message": "你好", "enabled": true\r\n}\r\n'],
+ ['PlainText', '订单状态: ready\r\n next line\r\n'],
+ ])('preservesOriginal%sBodyWhenDownloadingTest', async (_name, body) => {
+ const user = userEvent.setup();
+ const download = vi.spyOn(downloadUtils,
'downloadBlob').mockImplementation(() => {});
+ const msgId = 'MID-DOWNLOAD';
+ messageServiceMocks.queryMessages.mockResolvedValue([{
...createMessage(msgId), body }]);
+ renderWithProviders(<MessagePage />);
+
+ await user.click(lastElement(screen.getAllByRole('combobox')));
+ await user.click(lastElement(await screen.findAllByText('order-create')));
+ await user.click(screen.getByRole('button', { name: /^search查询$/ }));
+
+ const row = await screen.findByRole('row', { name: new RegExp(msgId) });
+ await user.click(within(row).getByRole('button', { name: /下载/ }));
+
+ expect(download).toHaveBeenCalledTimes(1);
+ const [blob, filename] = download.mock.calls[0];
+ expect(filename).toBe(`${msgId}.json`);
+ expect(blob.type).toBe('application/json');
+ await expect(blob.text()).resolves.toBe(body);
+ });
+
+ it('copiesOriginalBodyFromMessageDetailsTest', async () => {
Review Comment:
The new test names are very long and include a redundant 'Test' suffix,
which makes output harder to scan. Consider renaming them to human-readable
phrases (e.g., 'preserves original %s body when downloading' and 'copies
original body from message details') to align with typical Vitest/Jest naming
conventions.
##########
web/src/pages/instance/__tests__/MessagePage.test.tsx:
##########
@@ -276,6 +277,71 @@ describe('Message page query history', () => {
expect(messageServiceMocks.queryMessages).not.toHaveBeenCalled();
});
+ it.each([
+ ['UnsafeInteger', '{"orderId":9007199254740993}'],
+ ['Int64Max', '{"orderId":9223372036854775807}'],
+ ['SafeInteger', '{\n "orderId": 9007199254740991\n}'],
+ ['QuotedId', '{\n "orderId": "9223372036854775807"\n}'],
+ ['JsonWhitespace', '{\r\n\t"message": "你好", "enabled": true\r\n}\r\n'],
+ ['PlainText', '订单状态: ready\r\n next line\r\n'],
+ ])('preservesOriginal%sBodyWhenDownloadingTest', async (_name, body) => {
Review Comment:
The new test names are very long and include a redundant 'Test' suffix,
which makes output harder to scan. Consider renaming them to human-readable
phrases (e.g., 'preserves original %s body when downloading' and 'copies
original body from message details') to align with typical Vitest/Jest naming
conventions.
##########
web/src/pages/instance/__tests__/MessagePage.test.tsx:
##########
@@ -276,6 +277,71 @@ describe('Message page query history', () => {
expect(messageServiceMocks.queryMessages).not.toHaveBeenCalled();
});
+ it.each([
+ ['UnsafeInteger', '{"orderId":9007199254740993}'],
+ ['Int64Max', '{"orderId":9223372036854775807}'],
+ ['SafeInteger', '{\n "orderId": 9007199254740991\n}'],
+ ['QuotedId', '{\n "orderId": "9223372036854775807"\n}'],
+ ['JsonWhitespace', '{\r\n\t"message": "你好", "enabled": true\r\n}\r\n'],
+ ['PlainText', '订单状态: ready\r\n next line\r\n'],
+ ])('preservesOriginal%sBodyWhenDownloadingTest', async (_name, body) => {
+ const user = userEvent.setup();
+ const download = vi.spyOn(downloadUtils,
'downloadBlob').mockImplementation(() => {});
+ const msgId = 'MID-DOWNLOAD';
+ messageServiceMocks.queryMessages.mockResolvedValue([{
...createMessage(msgId), body }]);
+ renderWithProviders(<MessagePage />);
+
+ await user.click(lastElement(screen.getAllByRole('combobox')));
+ await user.click(lastElement(await screen.findAllByText('order-create')));
+ await user.click(screen.getByRole('button', { name: /^search查询$/ }));
+
+ const row = await screen.findByRole('row', { name: new RegExp(msgId) });
Review Comment:
Using `new RegExp(msgId)` is unnecessary here and can become fragile if
`msgId` ever contains regex metacharacters. Prefer a string matcher (`name:
msgId`) or escape the value before building a regex to keep the test robust.
--
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]