apache / apache/rocketmq-dashboard
Add regression coverage for optional credentials on metrics data-source queries
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 683
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 58
Description
## Problem
The current test suite does not cover optional credentials on metrics data-source queries.
## Expected behavior
- A focused Vitest case locks the existing behavior.
- The targeted test file passes and fails if the covered behavior regresses.
## Scope
Only add regression coverage for $(@{Slug=metrics-datasource-credentials; Focus=optional credentials on metrics data-source queries; PrTitle=test(metrics): cover optional data-source query credentials; TestFile=web/src/api/metrics.test.ts; Mode=existing; Append=describe('metrics data-source query optional credentials', () => {
it('omits optional credential fields when none are supplied', async () => {
const result = { resultType: 'matrix', series: [], warnings: [] };
const query = { metric: 'up', start: 1, end: 2, step: '1m' };
mock.onPost('/metrics/query/datasource').reply((config) => {
const body = JSON.parse(config.data);
expect(body.query).toEqual(query);
expect(body.username).toBeUndefined();
expect(body.password).toBeUndefined();
expect(body.bearerToken).toBeUndefined();
return [200, { code: 200, data: result }];
});
await expect(
queryByDataSource({ key: 'ds-prom-1', query }),
).resolves.toEqual(result);
});
});}.TestFile). No runtime behavior changes.
## Acceptance criteria
- [ ] The targeted Vitest file passes.
- [ ] git diff --check is clean.
Contributor guide
No contributing guide indexed for this repository
Research direction
Work in web/src/api/metrics.test.ts, following the existing Vitest tests and the queryByDataSource entry point. Run the targeted test file first, then verify the optional-credentials case omits username, password, and bearerToken while returning the expected result. Finish with a passing targeted test and a clean git diff --check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 92/100