[8.x] Attempt to fix custom_threshold_preview_chart flaky test (#212028) (#213778)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Attempt to fix custom_threshold_preview_chart flaky test
(#212028)](https://github.com/elastic/kibana/pull/212028)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Maryam
Saeidi","email":"maryam.saeidi@elastic.co"},"sourceCommit":{"committedDate":"2025-02-27T10:48:14Z","message":"Attempt
to fix custom_threshold_preview_chart flaky test (#212028)\n\nFixes
#209317\n\n## Summary\n\nSummary
of\n[Slack](https://elastic.slack.com/archives/C04HT4P1YS3/p1740054800086779)\ndiscussion:\n\nAs
shown below, we check if the `Create rule` button exists and then
we\ntry to click it:\n```\nconst clickCreateRuleButton = async () => {\n
await testSubjects.existOrFail('createRuleButton');\n const
createRuleButton = await testSubjects.find('createRuleButton');\n return
await createRuleButton.click();\n };\n```\n\nIt seems something goes
wrong during click in this case and even after 2\nmins, we don't see the
modal:\n```\n[00:03:11] │ debg --- retry.tryForTime error:
[data-test-subj=\"ruleTypeModal\"] is not displayed\n...\n[00:05:09] └-
✖ fail: ObservabilityApp Custom threshold preview chart does render the
empty chart only once at bootstrap\n```\n\n@dmlemeshko pointed to the
implementation that we have for the button\nand the fact that we need to
first check if the user is authorized to\nsee this button, and something
might have caused the click not to be\nsuccessful even though there is
no error reported by WebDriver.\n\n```\nuseEffect(() => {\n
setHeaderActions?.([\n ...(authorizedToCreateAnyRules ?
[<CreateRuleButton openFlyout={openRuleTypeModal} />] : []),\n
<RulesSettingsLink />,\n <RulesListDocLink />,\n ]);\n },
[authorizedToCreateAnyRules]);\n```\n\nLong story short, we will add
waiting for the global spinner to\nhopefully make this test less flaky
🤞🏻\n\n---------\n\nCo-authored-by: Dominique Clarke
<dominique.clarke@elastic.co>","sha":"2f0bad7d39319c315597be0e464b6d41fb4c25ef","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0"],"title":"Attempt
to fix custom_threshold_preview_chart flaky
test","number":212028,"url":"https://github.com/elastic/kibana/pull/212028","mergeCommit":{"message":"Attempt
to fix custom_threshold_preview_chart flaky test (#212028)\n\nFixes
#209317\n\n## Summary\n\nSummary
of\n[Slack](https://elastic.slack.com/archives/C04HT4P1YS3/p1740054800086779)\ndiscussion:\n\nAs
shown below, we check if the `Create rule` button exists and then
we\ntry to click it:\n```\nconst clickCreateRuleButton = async () => {\n
await testSubjects.existOrFail('createRuleButton');\n const
createRuleButton = await testSubjects.find('createRuleButton');\n return
await createRuleButton.click();\n };\n```\n\nIt seems something goes
wrong during click in this case and even after 2\nmins, we don't see the
modal:\n```\n[00:03:11] │ debg --- retry.tryForTime error:
[data-test-subj=\"ruleTypeModal\"] is not displayed\n...\n[00:05:09] └-
✖ fail: ObservabilityApp Custom threshold preview chart does render the
empty chart only once at bootstrap\n```\n\n@dmlemeshko pointed to the
implementation that we have for the button\nand the fact that we need to
first check if the user is authorized to\nsee this button, and something
might have caused the click not to be\nsuccessful even though there is
no error reported by WebDriver.\n\n```\nuseEffect(() => {\n
setHeaderActions?.([\n ...(authorizedToCreateAnyRules ?
[<CreateRuleButton openFlyout={openRuleTypeModal} />] : []),\n
<RulesSettingsLink />,\n <RulesListDocLink />,\n ]);\n },
[authorizedToCreateAnyRules]);\n```\n\nLong story short, we will add
waiting for the global spinner to\nhopefully make this test less flaky
🤞🏻\n\n---------\n\nCo-authored-by: Dominique Clarke
<dominique.clarke@elastic.co>","sha":"2f0bad7d39319c315597be0e464b6d41fb4c25ef"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212028","number":212028,"mergeCommit":{"message":"Attempt
to fix custom_threshold_preview_chart flaky test (#212028)\n\nFixes
#209317\n\n## Summary\n\nSummary
of\n[Slack](https://elastic.slack.com/archives/C04HT4P1YS3/p1740054800086779)\ndiscussion:\n\nAs
shown below, we check if the `Create rule` button exists and then
we\ntry to click it:\n```\nconst clickCreateRuleButton = async () => {\n
await testSubjects.existOrFail('createRuleButton');\n const
createRuleButton = await testSubjects.find('createRuleButton');\n return
await createRuleButton.click();\n };\n```\n\nIt seems something goes
wrong during click in this case and even after 2\nmins, we don't see the
modal:\n```\n[00:03:11] │ debg --- retry.tryForTime error:
[data-test-subj=\"ruleTypeModal\"] is not displayed\n...\n[00:05:09] └-
✖ fail: ObservabilityApp Custom threshold preview chart does render the
empty chart only once at bootstrap\n```\n\n@dmlemeshko pointed to the
implementation that we have for the button\nand the fact that we need to
first check if the user is authorized to\nsee this button, and something
might have caused the click not to be\nsuccessful even though there is
no error reported by WebDriver.\n\n```\nuseEffect(() => {\n
setHeaderActions?.([\n ...(authorizedToCreateAnyRules ?
[<CreateRuleButton openFlyout={openRuleTypeModal} />] : []),\n
<RulesSettingsLink />,\n <RulesListDocLink />,\n ]);\n },
[authorizedToCreateAnyRules]);\n```\n\nLong story short, we will add
waiting for the global spinner to\nhopefully make this test less flaky
🤞🏻\n\n---------\n\nCo-authored-by: Dominique Clarke
<dominique.clarke@elastic.co>","sha":"2f0bad7d39319c315597be0e464b6d41fb4c25ef"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Maryam Saeidi <maryam.saeidi@elastic.co>
This commit is contained in:
Kibana Machine 2025-03-11 05:23:49 +11:00 committed by GitHub
parent 9d54690a42
commit 66a2c1aa56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View file

@ -12,6 +12,7 @@ const CUSTOM_THRESHOLD_RULE_TYPE_SELECTOR = 'observability.rules.custom_threshol
export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const find = getService('find');
const log = getService('log');
const getManageRulesPageHref = async () => {
const manageRulesPageButton = await testSubjects.find('manageRulesPageButton');
@ -21,6 +22,7 @@ export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderCont
const clickCreateRuleButton = async () => {
await testSubjects.existOrFail('createRuleButton');
const createRuleButton = await testSubjects.find('createRuleButton');
log.debug(`clicking on ${await createRuleButton.getAttribute('innerText')}`);
return await createRuleButton.click();
};

View file

@ -18,7 +18,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
const logger = getService('log');
const retry = getService('retry');
const toasts = getService('toasts');
const PageObjects = getPageObjects(['header']);
const pageObjects = getPageObjects(['header']);
describe('Custom threshold rule', function () {
this.tags('includeFirefox');
@ -49,6 +49,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
logger,
});
await observability.alerts.common.navigateToRulesPage();
await pageObjects.header.waitUntilLoadingHasFinished();
});
after(async () => {
@ -59,7 +60,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
it('shows the custom threshold rule in the observability section', async () => {
await observability.alerts.rulesPage.clickCreateRuleButton();
await PageObjects.header.waitUntilLoadingHasFinished();
await pageObjects.header.waitUntilLoadingHasFinished();
await observability.alerts.rulesPage.clickOnObservabilityCategory();
await observability.alerts.rulesPage.clickOnCustomThresholdRule();
});

View file

@ -8,8 +8,7 @@
import expect from 'expect';
import { FtrProviderContext } from '../../../../ftr_provider_context';
export default ({ getService, getPageObject }: FtrProviderContext) => {
const common = getPageObject('common');
export default ({ getService, getPageObjects }: FtrProviderContext) => {
const esArchiver = getService('esArchiver');
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
@ -17,6 +16,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => {
const find = getService('find');
const logger = getService('log');
const retry = getService('retry');
const pageObjects = getPageObjects(['common', 'header']);
describe('Custom threshold preview chart', () => {
const observability = getService('observability');
@ -34,6 +34,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => {
logger,
});
await observability.alerts.common.navigateToRulesPage();
await pageObjects.header.waitUntilLoadingHasFinished();
});
after(async () => {
@ -46,7 +47,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => {
await observability.alerts.rulesPage.clickCreateRuleButton();
await observability.alerts.rulesPage.clickOnObservabilityCategory();
await observability.alerts.rulesPage.clickOnCustomThresholdRule();
await common.sleep(1000);
await pageObjects.common.sleep(1000);
expect(await find.existsByCssSelector('[data-rendering-count="2"]')).toBe(true);
});