Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
403 commits
Select commit Hold shift + click to select a range
d776aa0
make artifacts optional
mgiota Apr 16, 2025
6e24df3
type return value of injectReferencesIntoArtifacts
mgiota Apr 16, 2025
1e191c4
add more tests to transform_rule_attributes_to_rule_domain
mgiota Apr 16, 2025
e606da3
fix type issues
mgiota Apr 16, 2025
68cb0f0
Merge branch 'main' into artifacts_dashboard_schema
elasticmachine Apr 16, 2025
674db1a
return fake artifact along with dashboards
mgiota Apr 16, 2025
0926084
remove the call to the dashboard api
mgiota Apr 16, 2025
ec63b16
Add new `transformRawArtifactsToDomainArtifacts` function.
justinkambic Apr 16, 2025
92486e8
Add tests for `transformRawArtifactsToDomainArtifacts`.
justinkambic Apr 16, 2025
3764712
Merge branch 'artifacts_dashboard_schema' of github.com:mgiota/kibana…
justinkambic Apr 16, 2025
e785bd5
Merge branch 'artifacts_dashboard_schema' into investigation-guide-ba…
justinkambic Apr 16, 2025
6e66bb7
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 16, 2025
e625e73
Make `artifacts` a required parameter of `extractReferences`.
justinkambic Apr 16, 2025
43e0918
Add additional coverage to update artifacts test.
justinkambic Apr 16, 2025
c4efff7
rename isInternal to includeArtifacts
mgiota Apr 16, 2025
5a57446
Merge branch 'main' into artifacts_dashboard_schema
elasticmachine Apr 16, 2025
a88b335
Merge branch 'artifacts_dashboard_schema' into investigation-guide-ba…
justinkambic Apr 16, 2025
adb09e6
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 16, 2025
4e8a8fc
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 16, 2025
ae5de30
Fix i18n.
justinkambic Apr 16, 2025
67f8302
update_rule tests updates
mgiota Apr 17, 2025
4e240fd
find_rules_route unit tests
mgiota Apr 17, 2025
e3f236a
find_internal_rules_route unit tests
mgiota Apr 17, 2025
bb48349
Merge remote-tracking branch 'panagiota/artifacts_dashboard_schema' i…
justinkambic Apr 17, 2025
a248557
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 17, 2025
75d463c
test that artifacts are mapped correctly
mgiota Apr 17, 2025
061777a
Merge branch 'main' into artifacts_dashboard_schema
elasticmachine Apr 17, 2025
51ebefc
import schema from artifacts_schema
mgiota Apr 17, 2025
5696fd7
Fix i18n.
justinkambic Apr 17, 2025
91fbbb3
Merge remote-tracking branch 'panagiota/artifacts_dashboard_schema' i…
justinkambic Apr 18, 2025
a9c1444
Fix unit test.
justinkambic Apr 18, 2025
41c5505
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 18, 2025
c5ba626
Fix tests, change return value to always include dashboards array.
justinkambic Apr 18, 2025
8830c5e
Merge branch 'artifacts_dashboard_schema' of github.com:mgiota/kibana…
justinkambic Apr 18, 2025
6e5ca07
Change a word.
justinkambic Apr 18, 2025
7058cc8
Use lodash `uniqBy` to deduplicate reference list.
justinkambic Apr 18, 2025
848ef13
Merge branch 'artifacts_dashboard_schema' into investigation-guide-ba…
justinkambic Apr 18, 2025
393c4ab
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 18, 2025
21687c0
Revert changes to oas_docs because they seem to be broken on CI.
justinkambic Apr 18, 2025
86e52c1
Update test snapshot where there are duplicate SO ref IDs.
justinkambic Apr 18, 2025
5bc206c
Merge branch 'artifacts_dashboard_schema' into investigation-guide-fr…
justinkambic Apr 18, 2025
0efdf2d
Merge branch 'artifacts_dashboard_schema' into investigation-guide-ba…
justinkambic Apr 18, 2025
87b3e5c
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 18, 2025
26f910f
Fixup.
justinkambic Apr 18, 2025
943cf42
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Apr 18, 2025
7b9fe55
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Apr 18, 2025
3f8cd80
Revert "Update test snapshot where there are duplicate SO ref IDs."
justinkambic Apr 18, 2025
dba5032
Revert "Use lodash `uniqBy` to deduplicate reference list."
justinkambic Apr 18, 2025
e83c655
Merge branch 'artifacts_dashboard_schema' into investigation-guide-ba…
justinkambic Apr 18, 2025
99b386d
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 18, 2025
0b94e26
Merge branch 'investigation-guide-frontend' of github.com:justinkambi…
justinkambic Apr 18, 2025
9aede2f
Merge branch 'main' into artifacts_dashboard_schema
elasticmachine Apr 22, 2025
e57875e
move injectReferencesIntoArtifacts after hasLegacyActions
mgiota Apr 22, 2025
feeb68c
Merge branch 'main' into artifacts_dashboard_schema
elasticmachine Apr 22, 2025
9b44f70
make artifacts required
mgiota Apr 22, 2025
bf4a511
Merge remote-tracking branch 'panagiota/artifacts_dashboard_schema' i…
justinkambic Apr 22, 2025
9d78881
Fix types.
justinkambic Apr 22, 2025
80e4817
Fix unit tests.
justinkambic Apr 22, 2025
3c55b26
Fix more unit tests.
justinkambic Apr 22, 2025
78efbb7
Fix more unit tests.
justinkambic Apr 22, 2025
f3ec10b
fix lint error
mgiota Apr 22, 2025
a84329b
Merge branch 'main' into artifacts_dashboard_schema
elasticmachine Apr 22, 2025
8c2e505
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 22, 2025
4795010
Fix some API tests.
justinkambic Apr 22, 2025
b159a0b
do not mock denormalizeArtifacts
mgiota Apr 22, 2025
678a3df
Merge branch 'main' into artifacts_dashboard_schema
elasticmachine Apr 22, 2025
9423e7f
Merge remote-tracking branch 'panagiota/artifacts_dashboard_schema' i…
justinkambic Apr 22, 2025
0956a35
Merge branch 'investigation-guide-backend' of github.com:justinkambic…
justinkambic Apr 22, 2025
de115d2
Fix one more test 🤞.
justinkambic Apr 23, 2025
0533aac
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 23, 2025
f11c7c1
Update schema to v6 for new `investigation_guide` fields.
justinkambic Apr 23, 2025
12263fe
Fix types/imports.
justinkambic Apr 23, 2025
40a5612
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 23, 2025
7208972
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Apr 23, 2025
edaa369
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Apr 23, 2025
c30f7e0
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 23, 2025
980c7b1
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 23, 2025
8950be9
Merge branch 'main' into investigation-guide-backend
justinkambic Apr 23, 2025
197b7ad
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 23, 2025
3d76ad7
Merge branch 'investigation-guide-frontend' of github.com:justinkambi…
justinkambic Apr 28, 2025
318ae25
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 28, 2025
3120b59
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 28, 2025
9944587
TEMP
justinkambic Apr 28, 2025
a16fb49
Implement new test for PR feedback.
justinkambic Apr 28, 2025
5ee4cd2
Merge branch 'investigation-guide-backend' of github.com:justinkambic…
justinkambic Apr 28, 2025
c0214d1
Include unit test for rule update with new investigation_guide text.
justinkambic Apr 28, 2025
ccfdb7e
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 28, 2025
c9e5bac
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Apr 28, 2025
49b1251
Update raw rule schema definitions based on PR feedback.
justinkambic Apr 28, 2025
5d6248a
Add check for updated IG text in API test.
justinkambic Apr 28, 2025
9459dc2
Merge branch 'investigation-guide-backend' of github.com:justinkambic…
justinkambic Apr 28, 2025
f98bb9e
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 28, 2025
e73dae2
PR feedback.
justinkambic Apr 28, 2025
713548b
Add limits for `investigation_guide` size and `dashboards` length.
justinkambic Apr 28, 2025
592fba0
Specify `investigation_guide` as an indexed field for model/root mapp…
justinkambic Apr 28, 2025
2a32804
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Apr 28, 2025
e03d4db
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Apr 28, 2025
b4d1d37
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Apr 28, 2025
669179f
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Apr 28, 2025
f0b0ea9
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 29, 2025
d36ae48
Update API artifacts test to use `investigation_guide` as well.
justinkambic Apr 29, 2025
7cc23c2
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 29, 2025
14ce40d
Remove unneeded properties per PR feedback.
justinkambic Apr 29, 2025
70c970b
Merge branch 'investigation-guide-backend' of github.com:justinkambic…
justinkambic Apr 29, 2025
c8eaca2
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic Apr 29, 2025
c5adc44
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Apr 29, 2025
b246e7f
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Apr 29, 2025
8f0397b
Add meta description for investigation guide blob field.
justinkambic Apr 30, 2025
2714689
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic Apr 30, 2025
b2018e5
Merge branch 'investigation-guide-backend' of github.com:justinkambic…
justinkambic Apr 30, 2025
7cb500b
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Apr 30, 2025
8ddc483
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Apr 30, 2025
88cb045
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 30, 2025
9ece936
Fix some API tests
justinkambic May 1, 2025
27d8865
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 1, 2025
88207ee
Merge branch 'investigation-guide-backend' of github.com:justinkambic…
justinkambic May 1, 2025
a8092cb
Merge branch 'investigation-guide-backend' into investigation-guide-f…
justinkambic May 1, 2025
12c37c2
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 2, 2025
4d33985
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 2, 2025
b7d42ed
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 2, 2025
6143fb1
Fix form submit for edit rule.
justinkambic May 2, 2025
b07bd23
Merge branch 'investigation-guide-frontend' of github.com:justinkambi…
justinkambic May 2, 2025
415aa9e
Remove console.log
justinkambic May 2, 2025
df6afe3
Add test file for investigation guide editor.
justinkambic May 2, 2025
0ea9927
Rename investigation guide editor file.
justinkambic May 2, 2025
4649abe
Rename test file.
justinkambic May 2, 2025
0f5d71a
Remove console.log.
justinkambic May 2, 2025
8509436
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 2, 2025
5951d66
Merge branch 'main' into investigation-guide-frontend
justinkambic May 5, 2025
00ed85f
Explicitly remove artifacts when flag specifies.
justinkambic May 5, 2025
86b156e
Update test snapshot.
justinkambic May 5, 2025
a68e3d2
Make `update` transform exclude artifacts if flag is passed.
justinkambic May 5, 2025
5c6d6c5
Fix some tests.
justinkambic May 5, 2025
4731415
Exclude artifacts from `bulk_delete` route response.
justinkambic May 5, 2025
c02c46f
Fix unit test and types.
justinkambic May 6, 2025
a68871e
Skip functional test for now.
justinkambic May 6, 2025
4f6e7cf
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 6, 2025
0294f6f
Remove beta badge.
justinkambic May 6, 2025
fb3850d
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 7, 2025
7cb1862
Do not leak artifacts in bulk_enable.
justinkambic May 7, 2025
e4bddf6
Revert superfluous change to transform function.
justinkambic May 7, 2025
04cb844
Remove unneccesary async.
justinkambic May 7, 2025
5cf88b9
Perform a review pass and delete unneeded code.
justinkambic May 7, 2025
9d900f5
More sanitizing.
justinkambic May 7, 2025
4f23ea9
Fixup.
justinkambic May 7, 2025
2a02e58
Merge branch 'main' into investigation-guide-frontend
justinkambic May 7, 2025
f6bdc6d
Merge branch 'main' into investigation-guide-frontend
justinkambic May 7, 2025
f5a7e2f
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 8, 2025
7436061
Translate icon tip.
justinkambic May 8, 2025
0c58a69
Merge branch 'investigation-guide-frontend' of github.com:justinkambi…
justinkambic May 8, 2025
e3b1b48
Move `InvestigationGuide` to Details tab.
justinkambic May 8, 2025
fbf5bf5
Remove unneeded field.
justinkambic May 8, 2025
12e8a2e
Remove unneeded field.
justinkambic May 8, 2025
3f4f627
Destroy `any`.
justinkambic May 8, 2025
7d714c4
Simplify.
justinkambic May 8, 2025
e32f971
TEMP.
justinkambic May 9, 2025
1e376c7
Impelement design changes for rule create form details update.
justinkambic May 9, 2025
de7480b
Make row/column direction responsive.
justinkambic May 9, 2025
5350afc
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 9, 2025
e0e8e83
Fix a unit test
justinkambic May 9, 2025
3ce7023
Revert "TEMP."
justinkambic May 9, 2025
9379593
Fixup.
justinkambic May 9, 2025
a7b6742
Fix outdated snapshot.
justinkambic May 9, 2025
a9fd750
Merge branch 'response-ops_rule-create-form-design-updates' into inve…
justinkambic May 9, 2025
e52dcd0
i18n fixup.
justinkambic May 9, 2025
cd94913
Simplify.
justinkambic May 9, 2025
ceca146
Merge remote-tracking branch 'upstream/main' into response-ops_rule-c…
justinkambic May 9, 2025
8e5751b
Merge branch 'response-ops_rule-create-form-design-updates' into inve…
justinkambic May 9, 2025
9ab2009
Impelement design changes for rule create form details update.
justinkambic May 9, 2025
4bf1f39
Make row/column direction responsive.
justinkambic May 9, 2025
664751b
i18n fixup.
justinkambic May 9, 2025
dd0a60a
Simplify.
justinkambic May 9, 2025
f2780d2
Remove obsolete code.
justinkambic May 19, 2025
b1223d3
Fix unit tests file.
justinkambic May 19, 2025
332901d
Delete unneeded code.
justinkambic May 19, 2025
21e60a2
Merge branch 'response-ops_rule-create-form-design-updates' into inve…
justinkambic May 19, 2025
17261ac
Add translation to file.
justinkambic May 19, 2025
464d968
Impelement design changes for rule create form details update.
justinkambic May 9, 2025
53c70d8
Make row/column direction responsive.
justinkambic May 9, 2025
6e85a61
i18n fixup.
justinkambic May 9, 2025
1b69b91
Simplify.
justinkambic May 9, 2025
c309105
Remove obsolete code.
justinkambic May 19, 2025
7e9b291
Fix unit tests file.
justinkambic May 19, 2025
cfdf28b
Delete unneeded code.
justinkambic May 19, 2025
9a8c834
Simplify.
justinkambic May 19, 2025
bd04cb0
Merge branch 'response-ops_rule-create-form-design-updates' into inve…
justinkambic May 19, 2025
b697d47
Impelement design changes for rule create form details update.
justinkambic May 9, 2025
0d5ad80
Make row/column direction responsive.
justinkambic May 9, 2025
57ada23
i18n fixup.
justinkambic May 9, 2025
f789ab9
Simplify.
justinkambic May 9, 2025
aa06700
Remove obsolete code.
justinkambic May 19, 2025
0ed5c5c
Fix unit tests file.
justinkambic May 19, 2025
5f85969
Delete unneeded code.
justinkambic May 19, 2025
574f00b
Simplify.
justinkambic May 19, 2025
44f121e
Merge branch 'response-ops_rule-create-form-design-updates' into inve…
justinkambic May 20, 2025
b2af692
Move a test.
justinkambic May 20, 2025
3ba1888
Impelement design changes for rule create form details update.
justinkambic May 9, 2025
07f071b
Make row/column direction responsive.
justinkambic May 9, 2025
5b589f7
i18n fixup.
justinkambic May 9, 2025
abdfaf2
Simplify.
justinkambic May 9, 2025
00dca54
Remove obsolete code.
justinkambic May 19, 2025
3dc4013
Fix unit tests file.
justinkambic May 19, 2025
be94853
Delete unneeded code.
justinkambic May 19, 2025
2a4570a
Simplify.
justinkambic May 19, 2025
4681951
Fix weird FTR failure.
justinkambic May 20, 2025
766c926
Merge branch 'response-ops_rule-create-form-design-updates' into inve…
justinkambic May 20, 2025
60cc3e5
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 20, 2025
9c791a5
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 21, 2025
087ef26
Merge branch 'main' into investigation-guide-frontend
justinkambic May 23, 2025
1e1ff6f
Fix unit test mock and delete unneeded test code.
justinkambic May 23, 2025
6b15ebb
Copy fix.
justinkambic May 23, 2025
6120ad3
Copy fix.
justinkambic May 23, 2025
145809c
Make Investigation Guide tab remain highlighted on refresh.
justinkambic May 23, 2025
cb881ea
Specify `word-wrap` for markdown visualizers to keep words within the…
justinkambic May 23, 2025
abe2697
Add an icon tip to the Investigation Guide.
justinkambic May 23, 2025
cb384b2
Fixup.
justinkambic May 23, 2025
de4a98d
Fixup.
justinkambic May 23, 2025
8506ec9
Implement form validation for investigation guide.
justinkambic May 23, 2025
b3e874a
Fix i18n.
justinkambic May 23, 2025
90b86a9
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 24, 2025
59736db
Merge branch 'main' into investigation-guide-frontend
justinkambic May 24, 2025
0d76d68
Merge branch 'main' into investigation-guide-frontend
justinkambic May 26, 2025
79ae43b
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 26, 2025
c40f74d
Merge branch 'main' into investigation-guide-frontend
elasticmachine May 26, 2025
ef77fe7
Merge branch 'investigation-guide-frontend' of github.com:justinkambi…
justinkambic May 27, 2025
09af9c8
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 27, 2025
2f9ce4e
Move investigation guide editor component to the rule details directory.
justinkambic May 27, 2025
9801a1f
Revert UI changes to troubleshoot CI failure.
justinkambic May 27, 2025
6beb46f
Revert "Revert UI changes to troubleshoot CI failure."
justinkambic May 27, 2025
6a72013
Reduce scope of UI change reversion to eliminate surface area of issue.
justinkambic May 27, 2025
8596777
Revert "Reduce scope of UI change reversion to eliminate surface area…
justinkambic May 27, 2025
8874115
Is event handler causing this not to pass?
justinkambic May 27, 2025
86da740
fix type error and temporarily remove onSetArtifacts
mgiota May 27, 2025
fe2fed8
Expand removed code to find bug.
justinkambic May 28, 2025
65547be
Improve translation key name.
justinkambic May 28, 2025
9657386
fix failing unit tests
mgiota May 28, 2025
5f18245
Revert "fix failing unit tests"
mgiota May 28, 2025
d8114d0
remove markdown validation
mgiota May 28, 2025
ea0cf7b
Revert "remove markdown validation"
mgiota May 28, 2025
baeb37d
fix failing test
mgiota May 28, 2025
a7dbeb2
Further isolate in search of CI failure.
justinkambic May 28, 2025
9e7d0da
Merge branch 'investigation-guide-frontend' of github.com:justinkambi…
justinkambic May 28, 2025
30121fb
Be lazy.
justinkambic May 28, 2025
abbe8ce
add placeholder back to fix failing unit tests
mgiota May 28, 2025
c210459
Revert "Be lazy."
justinkambic May 28, 2025
4086ef4
Re-introduce full code.
justinkambic May 28, 2025
016e52f
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 28, 2025
80cc137
Merge branch 'investigation-guide-frontend' of github.com:justinkambi…
justinkambic May 28, 2025
da8c669
Merge remote-tracking branch 'upstream/main' into investigation-guide…
justinkambic May 28, 2025
fb57d60
Fix imports.
justinkambic May 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ export enum RuleFormStepId {
ACTIONS = 'rule-actions',
DETAILS = 'rule-details',
}

export const MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH = 1000;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import React, { type ReactNode } from 'react';
import { fireEvent, render as rtlRender, screen } from '@testing-library/react';

import type { ChartsPluginSetup } from '@kbn/charts-plugin/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
Expand Down Expand Up @@ -112,6 +112,8 @@ const { useRuleFormState, useRuleFormDispatch } = jest.requireMock('../hooks');

const mockOnChange = jest.fn();

const render = (toRender: ReactNode) => rtlRender(toRender, { wrapper: IntlProvider });
Comment thread
justinkambic marked this conversation as resolved.

describe('Rule Definition', () => {
beforeEach(() => {
useRuleFormDispatch.mockReturnValue(mockOnChange);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@
*/

import React from 'react';
import { fireEvent, render, screen, within } from '@testing-library/react';
import { fireEvent, render as rtlRender, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import type { ContentManagementPublicStart } from '@kbn/content-management-plugin/public';
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
import { RuleDetails } from './rule_details';

const mockOnChange = jest.fn();

jest.mock('../hooks', () => ({
useRuleFormState: jest.fn(),
useRuleFormDispatch: jest.fn(),
}));

const { useRuleFormState, useRuleFormDispatch } = jest.requireMock('../hooks');

const render = (toRender: React.ReactElement) =>
rtlRender(toRender, {
wrapper: ({ children }) => <IntlProvider>{children}</IntlProvider>,
});

const mockOnChange = jest.fn();

describe('RuleDetails', () => {
beforeEach(() => {
useRuleFormState.mockReturnValue({
Expand Down Expand Up @@ -88,4 +94,57 @@ describe('RuleDetails', () => {
expect(screen.getByText('name is invalid')).toBeInTheDocument();
expect(screen.getByText('tags is invalid')).toBeInTheDocument();
});

test('should call dispatch with artifacts object when investigation guide is added', async () => {
useRuleFormState.mockReturnValue({
plugins: {
contentManagement: {} as ContentManagementPublicStart,
},
formData: {
id: 'test-id',
params: {},
schedule: {
interval: '1m',
},
alertDelay: {
active: 5,
},
notifyWhen: null,
consumer: 'stackAlerts',
ruleTypeId: '.es-query',
},
canShowConsumerSelection: true,
validConsumers: ['logs', 'stackAlerts'],
});
render(<RuleDetails />);

const investigationGuideEditor = screen.getByTestId('investigationGuideEditor');
const investigationGuideTextArea = screen.getByLabelText(
'Add guidelines for addressing alerts created by this rule'
);
expect(investigationGuideEditor).toBeInTheDocument();
expect(investigationGuideEditor).toBeVisible();
expect(
screen.getByPlaceholderText('Add guidelines for addressing alerts created by this rule')
);

fireEvent.change(investigationGuideTextArea, {
target: {
value: '# Example investigation guide',
},
});

expect(mockOnChange).toHaveBeenCalledWith({
type: 'setRuleProperty',
payload: {
property: 'artifacts',
value: {
investigation_guide: {
blob: '# Example investigation guide',
},
},
},
});
expect(mockOnChange).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,24 @@ import {
EuiComboBoxOptionOption,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
EuiIconTip,
} from '@elastic/eui';
import { RULE_NAME_INPUT_TITLE, RULE_TAG_INPUT_TITLE, RULE_TAG_PLACEHOLDER } from '../translations';
import { i18n } from '@kbn/i18n';

import {
RULE_INVESTIGATION_GUIDE_LABEL,
RULE_NAME_INPUT_TITLE,
RULE_TAG_INPUT_TITLE,
RULE_TAG_PLACEHOLDER,
} from '../translations';
import { useRuleFormState, useRuleFormDispatch } from '../hooks';
import { OptionalFieldLabel } from '../optional_field_label';
import { InvestigationGuideEditor } from './rule_investigation_guide_editor';
import { RuleDashboards } from './rule_dashboards';
import { MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH } from '../constants';

export const RULE_DETAIL_MIN_ROW_WIDTH = 600;

export const RuleDetails = () => {
const { formData, baseErrors, plugins } = useRuleFormState();
Expand Down Expand Up @@ -72,6 +85,19 @@ export const RuleDetails = () => {
}
}, [dispatch, tags]);

const onSetArtifacts = useCallback(
(value: object) => {
dispatch({
type: 'setRuleProperty',
payload: {
property: 'artifacts',
value: formData.artifacts ? { ...formData.artifacts, ...value } : value,
},
});
},
[dispatch, formData.artifacts]
);

return (
<>
<EuiFlexGroup>
Expand Down Expand Up @@ -113,7 +139,43 @@ export const RuleDetails = () => {
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="l" />
<EuiFormRow
fullWidth
label={
<EuiFlexGroup gutterSize="xs" alignItems="center">
<EuiFlexItem grow={false}>{RULE_INVESTIGATION_GUIDE_LABEL}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIconTip
type="questionInCircle"
content={
<p>
{i18n.translate(
'responseOpsRuleForm.ruleDetails.investigationGuideFormRow.toolTip.content',
{
defaultMessage:
'These details will be included in a new tab on the alert details page for every alert triggered by this rule.',
}
)}
</p>
}
/>
</EuiFlexItem>
</EuiFlexGroup>
}
labelAppend={OptionalFieldLabel}
isInvalid={
(formData.artifacts?.investigation_guide?.blob?.length ?? 0) >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
}
>
<InvestigationGuideEditor
setRuleParams={onSetArtifacts}
value={formData.artifacts?.investigation_guide?.blob ?? ''}
/>
</EuiFormRow>
{contentManagement && <RuleDashboards contentManagement={contentManagement} />}
<EuiSpacer size="xxl" />
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React from 'react';
import { render as rtlRender, screen } from '@testing-library/react';
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
import { InvestigationGuideEditor } from './rule_investigation_guide_editor';
import { userEvent } from '@testing-library/user-event';

const render = (toRender: any) => rtlRender(toRender, { wrapper: IntlProvider });

describe('RuleInvestigationGuide', () => {
it('should render the investigation guide when provided', () => {
const setRuleParams = jest.fn();
render(<InvestigationGuideEditor setRuleParams={setRuleParams} value="123" />);
const editorElement = screen.getByLabelText(
'Add guidelines for addressing alerts created by this rule'
);
expect(editorElement).toBeInTheDocument();
});

it('should call setRuleParams when the value changes', async () => {
const setRuleParams = jest.fn();
render(<InvestigationGuideEditor setRuleParams={setRuleParams} value="# Markdown Summary" />);
const editorElement = screen.getByLabelText(
'Add guidelines for addressing alerts created by this rule'
);
expect(editorElement).toBeInTheDocument();
expect(editorElement).toHaveValue('# Markdown Summary');
expect(setRuleParams).toHaveBeenCalledTimes(0);

await userEvent.type(editorElement!, '!');

expect(setRuleParams).toHaveBeenCalled();
expect(setRuleParams.mock.calls[0]).toHaveLength(1);
expect(setRuleParams.mock.calls[0][0]).toEqual({
investigation_guide: { blob: '# Markdown Summary!' },
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { EuiMarkdownAstNode, EuiMarkdownEditor, EuiMarkdownParseError } from '@elastic/eui';
import { css } from '@emotion/react';
import { i18n } from '@kbn/i18n';
import React, { useCallback } from 'react';
import { MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH } from '../constants';

interface Props {
setRuleParams: (v: { investigation_guide: { blob: string } }) => void;
value: string;
}

export function InvestigationGuideEditor({ setRuleParams, value }: Props) {
const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
const onParse = useCallback(
(_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
const length = ast.position?.end.offset ?? 0;
if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
setErrorMessages([
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
defaultMessage:
'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
}),
]);
} else if (errorMessages.length) {
setErrorMessages([]);
}
},
[errorMessages]
);
return (
<EuiMarkdownEditor
aria-label={i18n.translate(
'responseOpsRuleForm.ruleDetails.investigationGuide.editor.ariaLabel',
{
defaultMessage: 'Add guidelines for addressing alerts created by this rule',
}
)}
placeholder={i18n.translate(
'responseOpsRuleForm.ruleDetails.investigationGuide.editor.placeholder',
{
defaultMessage: 'Add guidelines for addressing alerts created by this rule',
}
)}
css={css`
.euiMarkdownFormat {
word-wrap: break-word;
}
`}
value={value}
onChange={(blob) => setRuleParams({ investigation_guide: { blob } })}
onParse={onParse}
errors={errorMessages}
height={200}
data-test-subj="investigationGuideEditor"
initialViewMode="editing"
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ export const RULE_ALERT_DELAY_BELOW_MINIMUM_TEXT = i18n.translate(
}
);

export const RULE_INVESTIGATION_GUIDE_TOO_LONG_TEXT = (length: number, maxLength: number) =>
i18n.translate('responseOpsRuleForm.ruleForm.error.investigationGuideTooLongText', {
defaultMessage:
'Investigation guide is too long. Current length: {length}. Max length: {maxLength}.',
values: { length, maxLength },
});

export const INTERVAL_MINIMUM_TEXT = (minimum: string) =>
i18n.translate('responseOpsRuleForm.ruleForm.error.belowMinimumText', {
defaultMessage: 'Interval must be at least {minimum}.',
Expand Down Expand Up @@ -297,6 +304,13 @@ export const RULE_TAG_PLACEHOLDER = i18n.translate(
}
);

export const RULE_INVESTIGATION_GUIDE_LABEL = i18n.translate(
'responseOpsRuleForm.ruleForm.ruleDetails.investigationGuide.editor.title',
{
defaultMessage: 'Investigation guide',
}
);

export const RULE_NAME_ARIA_LABEL_TEXT = i18n.translate(
'responseOpsRuleForm.ruleForm.rulePage.ruleNameAriaLabelText',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
INTERVAL_REQUIRED_TEXT,
INTERVAL_MINIMUM_TEXT,
RULE_ALERT_DELAY_BELOW_MINIMUM_TEXT,
RULE_INVESTIGATION_GUIDE_TOO_LONG_TEXT,
} from '../translations';
import type {
MinimumScheduleInterval,
Expand All @@ -27,6 +28,7 @@ import type {
RuleTypeModel,
RuleUiAction,
} from '../common';
import { MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH } from '../constants';

export const validateAction = ({ action }: { action: RuleUiAction }): RuleFormActionsErrors => {
const errors = {
Expand Down Expand Up @@ -64,6 +66,7 @@ export function validateRuleBase({
actionConnectors: new Array<string>(),
alertDelay: new Array<string>(),
tags: new Array<string>(),
artifacts: new Array<string>(),
};

if (!formData.name) {
Expand Down Expand Up @@ -94,6 +97,16 @@ export function validateRuleBase({
errors.alertDelay.push(RULE_ALERT_DELAY_BELOW_MINIMUM_TEXT);
}

const investigationGuideLength = formData.artifacts?.investigation_guide?.blob.length ?? 0;
if (investigationGuideLength > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
errors.artifacts.push(
RULE_INVESTIGATION_GUIDE_TOO_LONG_TEXT(
investigationGuideLength,
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
)
);
}

return errors;
}

Expand Down
Loading