Skip to content

Commit 38446ca

Browse files
committed
review: address code-review findings on rule create gating
Signed-off-by: Ashish Agrawal <ashisagr@amazon.com>
1 parent 496768f commit 38446ca

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

public/components/alerting/__tests__/monitors_table.test.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,35 @@ describe('MonitorsTable', () => {
244244
expect(onCreateMonitor).toHaveBeenCalledWith('metrics');
245245
});
246246

247+
// Logs symmetric counterpart of the metrics test above, and the case that
248+
// actually distinguishes the fix from the pre-fix behaviour: an OpenSearch
249+
// datasource EXISTS but is not in the facet selection (only a Prometheus DS
250+
// is selected). The old selection-keyed logic disabled Logs create here
251+
// (every selected DS was Prometheus); the fix keeps it enabled because the
252+
// capability follows the available datasources, not the browse filter.
253+
it('keeps logs creation enabled when an OpenSearch datasource exists but is not selected', () => {
254+
const onCreateMonitor = jest.fn();
255+
render(
256+
<MonitorsTable
257+
{...defaultProps}
258+
datasources={
259+
[
260+
{ id: 'os-1', name: 'cluster1', type: 'opensearch' },
261+
{ id: 'prom-1', name: 'prom1', type: 'prometheus' },
262+
] as unknown as Datasource[]
263+
}
264+
selectedDsIds={['prom-1']}
265+
onCreateMonitor={onCreateMonitor}
266+
/>
267+
);
268+
269+
fireEvent.click(screen.getByTestId('alertManagerCreateResourceButton'));
270+
fireEvent.click(screen.getByText('Logs alert rule'));
271+
expect(onCreateMonitor).toHaveBeenCalledWith('logs');
272+
});
273+
274+
// Disable direction still holds: with no OpenSearch datasource available at
275+
// all, Logs create is greyed out (the wizard would have no valid target).
247276
it('disables logs creation when no OpenSearch datasource exists', () => {
248277
const onCreateMonitor = jest.fn();
249278
render(

0 commit comments

Comments
 (0)