Skip to content

Commit a098899

Browse files
committed
address comment
Signed-off-by: Jackie Han <[email protected]>
1 parent cbaf3de commit a098899

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

public/pages/DetectorResults/__tests__/AnomalyResultsTable.test.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('AnomalyResultsTable', () => {
5858

5959
const defaultProps = {
6060
anomalies: mockAnomalies,
61-
detectorIndex: ['test-index'],
61+
detectorIndices: ['test-index', 'followCluster:test-index'],
6262
detectorTimeField: 'timestamp',
6363
};
6464

@@ -151,6 +151,33 @@ describe('AnomalyResultsTable', () => {
151151
}
152152
});
153153

154+
it('creates new index pattern when none exists', async () => {
155+
const mockCreate = jest.fn().mockResolvedValue({ id: 'new-index-pattern-id' });
156+
(getSavedObjectsClient as jest.Mock).mockReturnValue({
157+
find: jest.fn().mockResolvedValue({ savedObjects: [] }),
158+
create: mockCreate,
159+
});
160+
161+
const { container } = renderWithContext(<AnomalyResultsTable {...defaultProps} />);
162+
163+
const discoverButton = container.querySelector('[data-test-subj="discoverIcon"]');
164+
if (discoverButton) {
165+
fireEvent.click(discoverButton);
166+
167+
await waitFor(() => {
168+
expect(mockCreate).toHaveBeenCalledWith('index-pattern', {
169+
title: 'test-index,followCluster:test-index',
170+
timeFieldName: 'timestamp',
171+
});
172+
});
173+
174+
const notifications = getNotifications();
175+
expect(notifications.toasts.addSuccess).toHaveBeenCalledWith(
176+
expect.stringContaining('Created new index pattern: test-index,followCluster:test-index')
177+
);
178+
}
179+
});
180+
154181
describe('mds feature flag', () => {
155182
it('shows Actions column when mds is disabled', () => {
156183
(getDataSourceEnabled as jest.Mock).mockReturnValue({ enabled: false });

public/pages/DetectorResults/containers/AnomalyHistory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ export const AnomalyHistory = (props: AnomalyHistoryProps) => {
990990
isHCDetector={isHCDetector}
991991
isHistorical={props.isHistorical}
992992
selectedHeatmapCell={selectedHeatmapCell}
993-
detectorIndex={props.detector.indices}
993+
detectorIndices={props.detector.indices}
994994
detectorTimeField={props.detector.timeField}
995995
/>
996996
)}

0 commit comments

Comments
 (0)