-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Search][Query Rules UI] FTR tests #223553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e0e0dd4
Initial commit
JoseLuisGJ 78b3bc8
Fixing feature flag enablement
JoseLuisGJ e4062e0
Create ruleset tests
JoseLuisGJ 5b8b5f6
Delete ruleset tests
JoseLuisGJ 5bb890b
Ruleset rule document and criteria tests
JoseLuisGJ 19c4c2b
Merge branch 'main' into query-rules-ftr-tests
elasticmachine 915daad
Fixing linting issues
JoseLuisGJ ebd740e
Removing unnused browser
JoseLuisGJ 6e27abc
Bringing back all feature flag tests
JoseLuisGJ 734c23d
Managing after and before calls
JoseLuisGJ 9f478d3
Removing Query Rules menu entry point by default
JoseLuisGJ 9648b5a
Fixing before after sequence
JoseLuisGJ 133173c
Enabling all FF tests
JoseLuisGJ d9e4acb
Moving after methods to the end
JoseLuisGJ 917ced1
Merge branch 'main' into query-rules-ftr-tests
JoseLuisGJ ceff7d4
Using ComboBox servicce
JoseLuisGJ 58b9607
Merge branch 'main' into query-rules-ftr-tests
elasticmachine 56cab18
Merge branch 'main' into query-rules-ftr-tests
elasticmachine 3fb94ff
Merge branch 'main' of github.com:elastic/kibana into query-rules-ftr…
efegurkan 747c285
Merge branch 'main' of github.com:elastic/kibana into query-rules-ftr…
efegurkan c1ccbe8
Update tests to make them stable
efegurkan c0518e4
Fix linting
efegurkan e86325f
Remove unused variable
efegurkan 0e3865f
Merge branch 'main' into query-rules-ftr-tests
elasticmachine 55d530e
Merge branch 'main' into query-rules-ftr-tests
elasticmachine e934476
Merge branch 'main' of github.com:elastic/kibana into query-rules-ftr…
efegurkan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
260 changes: 260 additions & 0 deletions
260
x-pack/test/functional/page_objects/search_query_rules_page.ts
This file contains hidden or 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,260 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| import { Key } from 'selenium-webdriver'; | ||
| import { FtrProviderContext } from '../ftr_provider_context'; | ||
|
|
||
| export function SearchQueryRulesPageProvider({ getService }: FtrProviderContext) { | ||
| const testSubjects = getService('testSubjects'); | ||
| const find = getService('find'); | ||
| const comboBox = getService('comboBox'); | ||
| const browser = getService('browser'); | ||
|
|
||
| return { | ||
| QueryRulesEmptyPromptPage: { | ||
| TEST_IDS: { | ||
| GET_STARTED_BUTTON: 'searchQueryRulesEmptyPromptGetStartedButton', | ||
| }, | ||
| async expectQueryRulesEmptyPromptPageComponentsToExist() { | ||
| await testSubjects.existOrFail(this.TEST_IDS.GET_STARTED_BUTTON); | ||
| }, | ||
| async clickCreateQueryRulesSetButton() { | ||
| await testSubjects.click(this.TEST_IDS.GET_STARTED_BUTTON); | ||
| }, | ||
| }, | ||
| QueryRulesManagementPage: { | ||
| TEST_IDS: { | ||
| QUERY_RULES_RULESETS_TABLE: 'queryRulesSetTable', | ||
| QUERY_RULES_ITEM_NAME: 'queryRuleSetName', | ||
| QUERY_RULES_ITEM_RULE_COUNT: 'queryRuleSetItemRuleCount', | ||
| QUERY_RULES_ITEM_ACTIONS_DELETE_BUTTON: 'queryRulesSetDeleteButton', | ||
| CREATE_RULESET_BUTTON: 'queryRulesOverviewCreateButton', | ||
| PAGINATION_NEXT_BUTTON: 'pagination-button-next', | ||
| PAGINATION_PREVIOUS_BUTTON: 'pagination-button-previous', | ||
| }, | ||
| async clickCreateQueryRulesRulesetButton() { | ||
| await testSubjects.click(this.TEST_IDS.CREATE_RULESET_BUTTON); | ||
| }, | ||
| async expectQueryRulesTableToExist() { | ||
| await testSubjects.existOrFail(this.TEST_IDS.QUERY_RULES_RULESETS_TABLE); | ||
| }, | ||
| async getQueryRulesRulesetsList() { | ||
| const table = await testSubjects.find(this.TEST_IDS.QUERY_RULES_RULESETS_TABLE); | ||
| const allRows = await table | ||
| .findByTagName('tbody') | ||
| .then((tbody) => tbody.findAllByTagName('tr')); | ||
|
|
||
| return Promise.all( | ||
| allRows.map(async (row) => { | ||
| const $ = await row.parseDomContent(); | ||
| return { | ||
| name: $.findTestSubject(this.TEST_IDS.QUERY_RULES_ITEM_NAME).text().trim(), | ||
| ruleCount: Number( | ||
| $.findTestSubject(this.TEST_IDS.QUERY_RULES_ITEM_RULE_COUNT).text() | ||
| ), | ||
| }; | ||
| }) | ||
| ); | ||
| }, | ||
| async clickRuleset(name: string) { | ||
| // find rulesets with name and click on it | ||
| const table = await testSubjects.findAll(this.TEST_IDS.QUERY_RULES_ITEM_NAME); | ||
| for (const item of table) { | ||
| const text = await item.getVisibleText(); | ||
| if (text === name) { | ||
| await item.click(); | ||
| return; | ||
| } | ||
| } | ||
| throw new Error(`Ruleset with name "${name}" not found`); | ||
| }, | ||
| async clickDeleteRulesetRow(index: number) { | ||
| const table = await testSubjects.find(this.TEST_IDS.QUERY_RULES_RULESETS_TABLE); | ||
| const allRows = await table | ||
| .findByTagName('tbody') | ||
| .then((tbody) => tbody.findAllByTagName('tr')); | ||
| const deleteButton = await allRows[index].findByTestSubject( | ||
| this.TEST_IDS.QUERY_RULES_ITEM_ACTIONS_DELETE_BUTTON | ||
| ); | ||
| await deleteButton.click(); | ||
| }, | ||
| async expectQueryRulesListPageComponentsToExist() { | ||
| await testSubjects.existOrFail(this.TEST_IDS.QUERY_RULES_RULESETS_TABLE); | ||
| await testSubjects.existOrFail(this.TEST_IDS.QUERY_RULES_ITEM_RULE_COUNT); | ||
| }, | ||
| async clickPaginationNext() { | ||
| await testSubjects.click(this.TEST_IDS.PAGINATION_NEXT_BUTTON); | ||
| }, | ||
| async clickPaginationPrevious() { | ||
| await testSubjects.click(this.TEST_IDS.PAGINATION_PREVIOUS_BUTTON); | ||
| }, | ||
| }, | ||
| QueryRulesDetailPage: { | ||
| TEST_IDS: { | ||
| RULESET_DETAILS_PAGE_BACK_BUTTON: 'queryRulesetDetailBackButton', | ||
| RULESET_DETAILS_PAGE_SAVE_BUTTON: 'queryRulesetDetailHeaderSaveButton', | ||
| RULESET_DETAILS_PAGE_HEADER: 'queryRulesetDetailHeader', | ||
| RULESET_DETAILS_PAGE_ACTIONS_BUTTON: 'searchQueryRulesQueryRulesetActionsButton', | ||
| RULESET_DETAILS_PAGE_DELETE_BUTTON: 'queryRulesetDetailDeleteButton', | ||
| RULESET_RULES_CONTAINER: 'searchQueryRulesDroppable', | ||
| RULESET_RULE_ITEM_NAME: 'searchQueryRulesDraggableItem', | ||
| RULESET_RULE_ITEM_ACTIONS_BUTTON: 'searchQueryRulesQueryRulesetDetailButton', | ||
| RULESET_RULE_ITEM_ACTIONS_DELETE_BUTTON: 'searchQueryRulesQueryRulesetDetailDeleteButton', | ||
| RULESET_RULE_ITEM_ACTIONS_EDIT_BUTTON: 'searchQueryRulesQueryRulesetDetailEditButton', | ||
| }, | ||
| async expectQueryRulesDetailPageNavigated(name: string) { | ||
| const h1Element = await find.byCssSelector( | ||
| `main header[data-test-subj="${this.TEST_IDS.RULESET_DETAILS_PAGE_HEADER}"] h1` | ||
| ); | ||
| const text = await h1Element.getVisibleText(); | ||
| if (text !== name) { | ||
| throw new Error(`Expected page title to be "${name}" but got "${text}"`); | ||
| } | ||
| }, | ||
| async expectQueryRulesDetailPageBackButtonToExist() { | ||
| await testSubjects.existOrFail(this.TEST_IDS.RULESET_DETAILS_PAGE_BACK_BUTTON); | ||
| }, | ||
| async expectQueryRulesDetailPageSaveButtonToExist() { | ||
| await testSubjects.existOrFail(this.TEST_IDS.RULESET_DETAILS_PAGE_SAVE_BUTTON); | ||
| }, | ||
| async clickQueryRulesDetailPageSaveButton() { | ||
| await testSubjects.click(this.TEST_IDS.RULESET_DETAILS_PAGE_SAVE_BUTTON); | ||
| }, | ||
| async clickQueryRulesDetailPageActionsButton() { | ||
| await testSubjects.click(this.TEST_IDS.RULESET_DETAILS_PAGE_ACTIONS_BUTTON); | ||
| }, | ||
| async clickQueryRulesDetailPageDeleteButton() { | ||
| await testSubjects.click(this.TEST_IDS.RULESET_DETAILS_PAGE_DELETE_BUTTON); | ||
| }, | ||
| async clickEditRulesetRule(id: number) { | ||
| const items = await testSubjects.findAll(this.TEST_IDS.RULESET_RULE_ITEM_NAME); | ||
| if (items[id]) { | ||
| const actionButton = await items[id].findByTestSubject( | ||
| this.TEST_IDS.RULESET_RULE_ITEM_ACTIONS_BUTTON | ||
| ); | ||
| await actionButton.click(); | ||
| await testSubjects.click(this.TEST_IDS.RULESET_RULE_ITEM_ACTIONS_EDIT_BUTTON); | ||
| } else { | ||
| throw new Error(`Ruleset rule with id "${id}" not found`); | ||
| } | ||
| }, | ||
| }, | ||
| QueryRulesCreateRulesetModal: { | ||
| TEST_IDS: { | ||
| CREATE_QUERY_RULES_SET_MODAL_INPUT: 'searchRulesetCreateRulesetModalFieldText', | ||
| CREATE_QUERY_RULES_SET_MODAL_CREATE_BUTTON: 'searchRulesetCreateRulesetModalCreateButton', | ||
| }, | ||
| async setQueryRulesSetName(name: string) { | ||
| await testSubjects.setValue(this.TEST_IDS.CREATE_QUERY_RULES_SET_MODAL_INPUT, name); | ||
| }, | ||
| async clickSaveButton() { | ||
| await testSubjects.click(this.TEST_IDS.CREATE_QUERY_RULES_SET_MODAL_CREATE_BUTTON); | ||
| }, | ||
| }, | ||
| QueryRulesDeleteRulesetModal: { | ||
| TEST_IDS: { | ||
| DELETE_QUERY_RULES_RULESET_MODAL_DELETE_BUTTON: | ||
| 'searchRulesetDeleteRulesetModalDeleteButton', | ||
| DELETE_QUERY_RULES_RULESET_MODAL_ACKNOWLEDGE_BUTTON: 'confirmDeleteRulesetCheckbox', | ||
| DELETE_QUERY_RULES_RULESET_MODAL_CANCEL_BUTTON: | ||
| 'searchRulesetDeleteRulesetModalCancelButton', | ||
| }, | ||
| async clickDeleteButton() { | ||
| await testSubjects.click(this.TEST_IDS.DELETE_QUERY_RULES_RULESET_MODAL_DELETE_BUTTON); | ||
| }, | ||
| async clickAcknowledgeButton() { | ||
| await testSubjects.click(this.TEST_IDS.DELETE_QUERY_RULES_RULESET_MODAL_ACKNOWLEDGE_BUTTON); | ||
| }, | ||
| async clickCancelButton() { | ||
| await testSubjects.click(this.TEST_IDS.DELETE_QUERY_RULES_RULESET_MODAL_CANCEL_BUTTON); | ||
| }, | ||
| async clickConfirmDeleteModal() { | ||
| await testSubjects.click('confirmModalConfirmButton'); | ||
| }, | ||
| }, | ||
| QueryRulesRuleFlyout: { | ||
| TEST_IDS: { | ||
| RULE_FLYOUT: 'searchQueryRulesQueryRuleFlyout', | ||
| RULE_FLYOUT_UPDATE_BUTTON: 'searchQueryRulesQueryRuleFlyoutUpdateButton', | ||
| RULE_FLYOUT_PIN_MORE_BUTTON: 'searchQueryRulesPinMoreButton', | ||
| RULE_FLYOUT_METADATA_ADD_BUTTON: 'searchQueryRulesQueryRuleMetadataEditorAddCriteriaButton', | ||
| RULE_FLYOUT_DOCUMENT_DRAGGABLE_ID: 'editableResultDocumentId', | ||
| RULE_FLYOUT_DOCUMENT_INDEX: 'editableResultIndexSelector', | ||
| RULE_FLYOUT_ACTION_TYPE_EXCLUDE: 'searchQueryRulesQueryRuleActionTypeExclude', | ||
| RULE_FLYOUT_ACTION_TYPE_PINNED: 'searchQueryRulesQueryRuleActionTypePinned', | ||
| RULE_FLYOUT_CRITERIA_CUSTOM: 'searchQueryRulesQueryRuleCriteriaCustom', | ||
| RULE_FLYOUT_CRITERIA_ALWAYS: 'searchQueryRulesQueryRuleCriteriaAlways', | ||
| RULE_FLYOUT_CRITERIA_METADATA_BLOCK: 'searchQueryRulesQueryRuleMetadataEditor', | ||
| RULE_FLYOUT_CRITERIA_METADATA_BLOCK_FIELD: 'searchQueryRulesQueryRuleMetadataEditorField', | ||
| RULE_FLYOUT_CRITERIA_METADATA_BLOCK_VALUES: 'searchQueryRulesQueryRuleMetadataEditorValues', | ||
| }, | ||
| async expectRuleFlyoutToExist() { | ||
| await testSubjects.existOrFail(this.TEST_IDS.RULE_FLYOUT); | ||
| }, | ||
| async clickUpdateButton() { | ||
| await testSubjects.click(this.TEST_IDS.RULE_FLYOUT_UPDATE_BUTTON); | ||
| }, | ||
| async clickActionTypeExclude() { | ||
| await testSubjects.click(this.TEST_IDS.RULE_FLYOUT_ACTION_TYPE_EXCLUDE); | ||
| }, | ||
| async clickActionTypePinned() { | ||
| await testSubjects.click(this.TEST_IDS.RULE_FLYOUT_ACTION_TYPE_PINNED); | ||
| }, | ||
| async clickCriteriaCustom() { | ||
| await testSubjects.click(this.TEST_IDS.RULE_FLYOUT_CRITERIA_CUSTOM); | ||
| }, | ||
| async clickCriteriaAlways() { | ||
| await testSubjects.click(this.TEST_IDS.RULE_FLYOUT_CRITERIA_ALWAYS); | ||
| }, | ||
| async changeDocumentIdField(id: number, newValue: string = '') { | ||
| const documentFields = await testSubjects.findAll( | ||
| this.TEST_IDS.RULE_FLYOUT_DOCUMENT_DRAGGABLE_ID | ||
| ); | ||
| if (documentFields[id]) { | ||
| const targetField = documentFields[id]; | ||
| await targetField.click(); | ||
| await targetField.type(newValue); | ||
| } else { | ||
| await testSubjects.click(this.TEST_IDS.RULE_FLYOUT_PIN_MORE_BUTTON); | ||
| await this.changeDocumentIdField(id); | ||
| } | ||
| }, | ||
| async changeDocumentIndexField(id: number, newValue: string = '') { | ||
| const comboBoxes = await testSubjects.findAll(this.TEST_IDS.RULE_FLYOUT_DOCUMENT_INDEX); | ||
| if (comboBoxes[id]) { | ||
| const targetComboBox = comboBoxes[id]; | ||
| await targetComboBox.click(); | ||
| await comboBox.setCustom(this.TEST_IDS.RULE_FLYOUT_DOCUMENT_INDEX, newValue); | ||
| // Press tab to ensure the value is set correctly | ||
| await browser.pressKeys(Key.TAB); | ||
| } | ||
| }, | ||
| async changeMetadataField(id: number, newValue: string = '') { | ||
| const metadataFields = await testSubjects.findAll( | ||
| this.TEST_IDS.RULE_FLYOUT_CRITERIA_METADATA_BLOCK | ||
| ); | ||
| if (metadataFields[id]) { | ||
| const targetMetadataBlock = metadataFields[id]; | ||
| const targetField = await targetMetadataBlock.findByTestSubject( | ||
| this.TEST_IDS.RULE_FLYOUT_CRITERIA_METADATA_BLOCK_FIELD | ||
| ); | ||
| await targetField.click(); | ||
| await targetField.type(newValue); | ||
| } else { | ||
| await testSubjects.click(this.TEST_IDS.RULE_FLYOUT_METADATA_ADD_BUTTON); | ||
| await this.changeMetadataField(id); | ||
| } | ||
| }, | ||
| async changeMetadataValues(_: number, newValue: string = '') { | ||
| await comboBox.setCustom( | ||
| this.TEST_IDS.RULE_FLYOUT_CRITERIA_METADATA_BLOCK_VALUES, | ||
| newValue | ||
| ); | ||
| }, | ||
| }, | ||
| }; | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.