Skip to content

Commit c92474e

Browse files
kibanamachinesemd
andauthored
[8.19] [Security Solution][Auto migrations] Adapt cypress tests to 9.1 features (#224857) (#225336)
# Backport This will backport the following commits from `main` to `8.19`: - [[Security Solution][Auto migrations] Adapt cypress tests to 9.1 features (#224857)](#224857) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Sergi Massaneda","email":"sergi.massaneda@elastic.co"},"sourceCommit":{"committedDate":"2025-06-25T16:25:22Z","message":"[Security Solution][Auto migrations] Adapt cypress tests to 9.1 features (#224857)\n\n## Summary\n\nAdapted cypress tests to:\n\n- Run cypress tests within the Threat Hunting Investigations team bundle\nin the CI.\n- Fixed failing onboarding test.\n- Added test cases for migration rename functionality to the onboarding\ntest.\n\n## Screenshots\n\n![CI\nexec](https://github.com/user-attachments/assets/81801b00-7ff5-4020-8de3-186fd9f23714)","sha":"51b1cd734487ee67712b0586994921285dec297e","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Threat Hunting","backport:version","v9.1.0","v8.19.0"],"title":"[Security Solution][Auto migrations] Adapt cypress tests to 9.1 features","number":224857,"url":"https://github.com/elastic/kibana/pull/224857","mergeCommit":{"message":"[Security Solution][Auto migrations] Adapt cypress tests to 9.1 features (#224857)\n\n## Summary\n\nAdapted cypress tests to:\n\n- Run cypress tests within the Threat Hunting Investigations team bundle\nin the CI.\n- Fixed failing onboarding test.\n- Added test cases for migration rename functionality to the onboarding\ntest.\n\n## Screenshots\n\n![CI\nexec](https://github.com/user-attachments/assets/81801b00-7ff5-4020-8de3-186fd9f23714)","sha":"51b1cd734487ee67712b0586994921285dec297e"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224857","number":224857,"mergeCommit":{"message":"[Security Solution][Auto migrations] Adapt cypress tests to 9.1 features (#224857)\n\n## Summary\n\nAdapted cypress tests to:\n\n- Run cypress tests within the Threat Hunting Investigations team bundle\nin the CI.\n- Fixed failing onboarding test.\n- Added test cases for migration rename functionality to the onboarding\ntest.\n\n## Screenshots\n\n![CI\nexec](https://github.com/user-attachments/assets/81801b00-7ff5-4020-8de3-186fd9f23714)","sha":"51b1cd734487ee67712b0586994921285dec297e"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Sergi Massaneda <sergi.massaneda@elastic.co>
1 parent caa7be6 commit c92474e

10 files changed

Lines changed: 63 additions & 21 deletions

File tree

x-pack/solutions/security/packages/connectors/src/connector_selector.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('ConnectorSelector', () => {
3636
);
3737

3838
fireEvent.click(getByTestId(testSubj));
39-
fireEvent.click(getByTestId('1'));
39+
fireEvent.click(getByTestId('connector-option-Connector One'));
4040

4141
expect(mockOnChange).toHaveBeenCalledWith('1');
4242
});

x-pack/solutions/security/packages/connectors/src/connector_selector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const ConnectorSelector = React.memo<ConnectorSelectorProps>(
8888

8989
const mappedConnectorOptions = connectors.map((connector) => ({
9090
value: connector.id,
91-
'data-test-subj': connector.id,
91+
'data-test-subj': `connector-option-${connector.name}`,
9292
inputDisplay: (
9393
<EuiText
9494
css={styles?.optionDisplay}
@@ -101,7 +101,7 @@ export const ConnectorSelector = React.memo<ConnectorSelectorProps>(
101101
dropdownDisplay: (
102102
<React.Fragment key={connector.id}>
103103
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="none" alignItems="center">
104-
<EuiFlexItem grow={false} data-test-subj={`connector-option-${connector.name}`}>
104+
<EuiFlexItem grow={false}>
105105
<strong>{connector.name}</strong>
106106
<EuiText size="xs" color="subdued">
107107
<p>{connector.description}</p>

x-pack/solutions/security/plugins/security_solution/public/siem_migrations/rules/components/data_input_flyout/steps/rules/sub_steps/migration_name/migration_name_input.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const MigrationNameInput = React.memo<MigrationNameInputProps>(
6363
onKeyDown={onEnter}
6464
fullWidth
6565
autoFocus
66+
data-test-subj="migrationNameInput"
6667
/>
6768
</EuiFormRow>
6869
</EuiForm>

x-pack/solutions/security/plugins/security_solution/public/siem_migrations/rules/components/migration_status_panels/migration_panel_title.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const MigrationPanelTitle = React.memo<MigrationPanelTitleProps>(({ migra
109109
) : (
110110
<>
111111
<EuiFlexItem grow={false}>
112-
<PanelText size="s" semiBold>
112+
<PanelText size="s" semiBold data-test-subj="migrationPanelTitleName">
113113
<p>{name}</p>
114114
</PanelText>
115115
</EuiFlexItem>

x-pack/test/security_solution_cypress/cypress/e2e/siem_migrations/rules/onboarding.cy.ts renamed to x-pack/test/security_solution_cypress/cypress/e2e/investigations/siem_migrations/rules/onboarding.cy.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,27 @@
55
* 2.0.
66
*/
77
import {
8+
MIGRATION_PANEL_NAME,
89
ONBOARDING_RULE_MIGRATIONS_LIST,
910
ONBOARDING_TRANSLATIONS_RESULT_TABLE,
1011
RULE_MIGRATIONS_GROUP_PANEL,
1112
RULE_MIGRATION_PROGRESS_BAR,
12-
} from '../../../screens/siem_migrations';
13-
import { deleteConnectors } from '../../../tasks/api_calls/common';
14-
import { createBedrockConnector } from '../../../tasks/api_calls/connectors';
15-
import { cleanMigrationData } from '../../../tasks/api_calls/siem_migrations';
16-
import { login } from '../../../tasks/login';
17-
import { visit } from '../../../tasks/navigation';
13+
} from '../../../../screens/siem_migrations';
14+
import { deleteConnectors } from '../../../../tasks/api_calls/common';
15+
import { createBedrockConnector } from '../../../../tasks/api_calls/connectors';
16+
import { cleanMigrationData } from '../../../../tasks/api_calls/siem_migrations';
17+
import { login } from '../../../../tasks/login';
18+
import { visit } from '../../../../tasks/navigation';
1819
import {
1920
openUploadRulesFlyout,
2021
selectMigrationConnector,
2122
startMigrationFromFlyout,
2223
uploadRules,
2324
toggleMigrateRulesCard,
24-
} from '../../../tasks/siem_migrations';
25-
import { GET_STARTED_URL } from '../../../urls/navigation';
25+
saveDefaultMigrationName,
26+
renameMigration,
27+
} from '../../../../tasks/siem_migrations';
28+
import { GET_STARTED_URL } from '../../../../urls/navigation';
2629

2730
export const SPLUNK_TEST_RULES = [
2831
{
@@ -106,6 +109,7 @@ describe(
106109
it('should be able to create migrations', () => {
107110
selectMigrationConnector();
108111
openUploadRulesFlyout();
112+
saveDefaultMigrationName();
109113
uploadRules(SPLUNK_TEST_RULES);
110114
cy.intercept({
111115
url: '**/start',
@@ -123,9 +127,12 @@ describe(
123127

124128
context('On Successful Translation', () => {
125129
context('Migration Results', () => {
126-
it('should be able to see the result of the completed migration', () => {
130+
beforeEach(() => {
127131
selectMigrationConnector();
128132
toggleMigrateRulesCard();
133+
});
134+
135+
it('should be able to see the result of the completed migration', () => {
129136
cy.get(RULE_MIGRATIONS_GROUP_PANEL).within(() => {
130137
cy.get(ONBOARDING_RULE_MIGRATIONS_LIST).should('have.length', 1);
131138
cy.get(ONBOARDING_TRANSLATIONS_RESULT_TABLE.TRANSLATION_STATUS_COUNT('Failed')).should(
@@ -140,6 +147,12 @@ describe(
140147
).should('have.text', 1);
141148
});
142149
});
150+
151+
it('should be able to rename the migration', () => {
152+
cy.get(ONBOARDING_RULE_MIGRATIONS_LIST).should('have.length', 1);
153+
renameMigration('New Migration Name');
154+
cy.get(MIGRATION_PANEL_NAME).should('have.text', 'New Migration Name');
155+
});
143156
});
144157
});
145158
}

x-pack/test/security_solution_cypress/cypress/e2e/siem_migrations/rules/translated_rules_page.cy.ts renamed to x-pack/test/security_solution_cypress/cypress/e2e/investigations/siem_migrations/rules/translated_rules_page.cy.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {
1212
TRANSLATED_RULE_QUERY_VIEWER,
1313
TRANSLATED_RULE_RESULT_BADGE,
1414
TRANSLATED_RULES_RESULT_TABLE,
15-
} from '../../../screens/siem_migrations';
16-
import { deleteConnectors } from '../../../tasks/api_calls/common';
17-
import { createBedrockConnector } from '../../../tasks/api_calls/connectors';
18-
import { login } from '../../../tasks/login';
19-
import { visit } from '../../../tasks/navigation';
15+
} from '../../../../screens/siem_migrations';
16+
import { deleteConnectors } from '../../../../tasks/api_calls/common';
17+
import { createBedrockConnector } from '../../../../tasks/api_calls/connectors';
18+
import { login } from '../../../../tasks/login';
19+
import { visit } from '../../../../tasks/navigation';
2020
import {
2121
editTranslatedRuleByRow,
2222
saveUpdatedTranslatedRuleQuery,
@@ -25,8 +25,8 @@ import {
2525
navigateToTranslatedRulesPage,
2626
openReprocessDialog,
2727
reprocessWithoutPrebuiltRulesMatching,
28-
} from '../../../tasks/siem_migrations';
29-
import { GET_STARTED_URL } from '../../../urls/navigation';
28+
} from '../../../../tasks/siem_migrations';
29+
import { GET_STARTED_URL } from '../../../../urls/navigation';
3030

3131
describe(
3232
'Rule Migrations - Translated Rules Page',

x-pack/test/security_solution_cypress/cypress/screens/siem_migrations.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ export const UPLOAD_RULES_BTN = getDataTestSubjectSelector('startMigrationUpload
2020
export const UPLOAD_RULES_FLYOUT = getDataTestSubjectSelector('uploadRulesFlyout');
2121
export const UPLOAD_RULES_FILE_PICKER = getDataTestSubjectSelector('rulesFilePicker');
2222
export const UPLOAD_RULES_FILE_BTN = getDataTestSubjectSelector('uploadFileButton');
23+
export const MIGRATION_NAME_INPUT = getDataTestSubjectSelector('migrationNameInput');
24+
export const MIGRATION_PANEL_NAME = getDataTestSubjectSelector('migrationPanelTitleName');
2325

2426
export const START_MIGRATION_FROM_FLYOUT_BTN = getDataTestSubjectSelector('startMigrationButton');
2527

2628
export const RULE_MIGRATIONS_GROUP_PANEL = getDataTestSubjectSelector('ruleMigrationPanelGroup');
2729
export const ONBOARDING_RULE_MIGRATIONS_LIST = getDataTestSubjectSelectorStartWith('migration-');
30+
2831
export const ONBOARDING_TRANSLATIONS_RESULT_TABLE = {
2932
TABLE: getDataTestSubjectSelector('translationsResults'),
3033
TRANSLATION_STATUS: (status: string) => getDataTestSubjectSelector(`translationStatus-${status}`),
@@ -63,7 +66,7 @@ export const RULE_MIGRATION_PROGRESS_BAR_TEXT = `${RULE_MIGRATION_PROGRESS_BAR}
6366
export const REPROCESS_FAILED_RULES_BTN = getDataTestSubjectSelector('reprocessFailedRulesButton');
6467

6568
export const FAKE_BEDROCK_SELECTOR = getDataTestSubjectSelector(
66-
`connector-${bedrockConnectorAPIPayload.name}`
69+
`connector-option-${bedrockConnectorAPIPayload.name}`
6770
);
6871

6972
const START_MIGRATION_MODAL_PREFIX = 'startMigrationModal';
@@ -77,3 +80,10 @@ export const START_MIGRATION_MODAL = {
7780
),
7881
START_MIGRATION_BTN: getDataTestSubjectSelector(`${START_MIGRATION_MODAL_PREFIX}-Translate`),
7982
};
83+
84+
export const ONBOARDING_MIGRATION_ACTIONS = {
85+
OPEN_ACTIONS_MENU: getDataTestSubjectSelector('openMigrationOptionsButton'),
86+
RENAME_BTN: getDataTestSubjectSelector('renameMigrationItem'),
87+
RENAME_INPUT: getDataTestSubjectSelector('euiInlineEditModeInput'),
88+
RENAME_CONFIRM: getDataTestSubjectSelector('euiInlineEditModeSaveButton'),
89+
};

x-pack/test/security_solution_cypress/cypress/tasks/siem_migrations.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export const openUploadRulesFlyout = () => {
5252
cy.get(SELECTORS.UPLOAD_RULES_FLYOUT).should('exist');
5353
};
5454

55+
export const saveDefaultMigrationName = () => {
56+
cy.get(SELECTORS.MIGRATION_NAME_INPUT).should('exist');
57+
cy.get(SELECTORS.MIGRATION_NAME_INPUT).blur();
58+
};
59+
5560
export const uploadRules = (splunkRulesJSON: object) => {
5661
cy.get(SELECTORS.UPLOAD_RULES_FILE_PICKER).selectFile({
5762
contents: Cypress.Buffer.from(JSON.stringify(splunkRulesJSON)),
@@ -108,3 +113,12 @@ export const reprocessWithoutPrebuiltRulesMatching = () => {
108113
);
109114
cy.get(SELECTORS.START_MIGRATION_MODAL.START_MIGRATION_BTN).click();
110115
};
116+
117+
export const renameMigration = (newName: string) => {
118+
cy.get(SELECTORS.ONBOARDING_MIGRATION_ACTIONS.OPEN_ACTIONS_MENU).click();
119+
cy.get(SELECTORS.ONBOARDING_MIGRATION_ACTIONS.RENAME_BTN).click();
120+
cy.get(SELECTORS.ONBOARDING_MIGRATION_ACTIONS.RENAME_INPUT).should('be.visible');
121+
cy.get(SELECTORS.ONBOARDING_MIGRATION_ACTIONS.RENAME_INPUT).clear();
122+
cy.get(SELECTORS.ONBOARDING_MIGRATION_ACTIONS.RENAME_INPUT).type(newName);
123+
cy.get(SELECTORS.ONBOARDING_MIGRATION_ACTIONS.RENAME_CONFIRM).click();
124+
};

x-pack/test/security_solution_cypress/es_archives/siem_migrations/rule_migrations/data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"id": "0e5effd1-f355-469e-8614-74e82ca23f42",
55
"index": ".kibana-siem-rule-migrations-migrations-default",
66
"source": {
7+
"name": "Test automatic rule migration 1",
78
"created_by": "u_mGBROF_q5bmFCATbLXAcCwKa0k8JvONAwSruelyKA5E_0",
89
"created_at": "2025-05-06T07:53:47.560Z"
910
}

x-pack/test/security_solution_cypress/es_archives/siem_migrations/rule_migrations/mappings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
}
1313
},
1414
"properties": {
15+
"name": {
16+
"type": "keyword"
17+
},
1518
"created_at": {
1619
"type": "date"
1720
},

0 commit comments

Comments
 (0)