-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
405 additions
and
141 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...tion/public/detection_engine/rule_creation_ui/components/select_rule_type/test_helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { act, fireEvent, within, screen } from '@testing-library/react'; | ||
import type { Type as RuleType } from '@kbn/securitysolution-io-ts-alerting-types'; | ||
|
||
export async function selectRuleType(ruleType: RuleType): Promise<void> { | ||
const testId = RULE_TYPE_TEST_ID_MAP[ruleType]; | ||
|
||
await act(async () => fireEvent.click(screen.getByTestId(testId))); | ||
|
||
expect(within(screen.getByTestId(testId)).getByRole('switch')).toBeChecked(); | ||
} | ||
|
||
const RULE_TYPE_TEST_ID_MAP = { | ||
query: 'customRuleType', | ||
saved_query: 'customRuleType', | ||
eql: 'eqlRuleType', | ||
machine_learning: 'machineLearningRuleType', | ||
threshold: 'thresholdRuleType', | ||
threat_match: 'threatMatchRuleType', | ||
new_terms: 'newTermsRuleType', | ||
esql: 'esqlRuleType', | ||
}; |
Oops, something went wrong.