Skip to content

Commit 2f0bad7

Browse files
Attempt to fix custom_threshold_preview_chart flaky test (#212028)
Fixes #209317 ## Summary Summary of [Slack](https://elastic.slack.com/archives/C04HT4P1YS3/p1740054800086779) discussion: As shown below, we check if the `Create rule` button exists and then we try to click it: ``` const clickCreateRuleButton = async () => { await testSubjects.existOrFail('createRuleButton'); const createRuleButton = await testSubjects.find('createRuleButton'); return await createRuleButton.click(); }; ``` It seems something goes wrong during click in this case and even after 2 mins, we don't see the modal: ``` [00:03:11] │ debg --- retry.tryForTime error: [data-test-subj="ruleTypeModal"] is not displayed ... [00:05:09] └- ✖ fail: ObservabilityApp Custom threshold preview chart does render the empty chart only once at bootstrap ``` @dmlemeshko pointed to the implementation that we have for the button and the fact that we need to first check if the user is authorized to see this button, and something might have caused the click not to be successful even though there is no error reported by WebDriver. ``` useEffect(() => { setHeaderActions?.([ ...(authorizedToCreateAnyRules ? [<CreateRuleButton openFlyout={openRuleTypeModal} />] : []), <RulesSettingsLink />, <RulesListDocLink />, ]); }, [authorizedToCreateAnyRules]); ``` Long story short, we will add waiting for the global spinner to hopefully make this test less flaky 🤞🏻 --------- Co-authored-by: Dominique Clarke <[email protected]>
1 parent 7a381af commit 2f0bad7

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

x-pack/test/functional/services/observability/alerts/rules_page.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const CUSTOM_THRESHOLD_RULE_TYPE_SELECTOR = 'observability.rules.custom_threshol
1212
export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderContext) {
1313
const testSubjects = getService('testSubjects');
1414
const find = getService('find');
15+
const log = getService('log');
1516

1617
const getManageRulesPageHref = async () => {
1718
const manageRulesPageButton = await testSubjects.find('manageRulesPageButton');
@@ -21,6 +22,7 @@ export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderCont
2122
const clickCreateRuleButton = async () => {
2223
await testSubjects.existOrFail('createRuleButton');
2324
const createRuleButton = await testSubjects.find('createRuleButton');
25+
log.debug(`clicking on ${await createRuleButton.getAttribute('innerText')}`);
2426
return await createRuleButton.click();
2527
};
2628

x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
1818
const logger = getService('log');
1919
const retry = getService('retry');
2020
const toasts = getService('toasts');
21-
const PageObjects = getPageObjects(['header']);
21+
const pageObjects = getPageObjects(['header']);
2222

2323
describe('Custom threshold rule', function () {
2424
this.tags('includeFirefox');
@@ -49,6 +49,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
4949
logger,
5050
});
5151
await observability.alerts.common.navigateToRulesPage();
52+
await pageObjects.header.waitUntilLoadingHasFinished();
5253
});
5354

5455
after(async () => {
@@ -59,7 +60,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
5960

6061
it('shows the custom threshold rule in the observability section', async () => {
6162
await observability.alerts.rulesPage.clickCreateRuleButton();
62-
await PageObjects.header.waitUntilLoadingHasFinished();
63+
await pageObjects.header.waitUntilLoadingHasFinished();
6364
await observability.alerts.rulesPage.clickOnObservabilityCategory();
6465
await observability.alerts.rulesPage.clickOnCustomThresholdRule();
6566
});

x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
import expect from 'expect';
99
import { FtrProviderContext } from '../../../../ftr_provider_context';
1010

11-
export default ({ getService, getPageObject }: FtrProviderContext) => {
12-
const common = getPageObject('common');
11+
export default ({ getService, getPageObjects }: FtrProviderContext) => {
1312
const esArchiver = getService('esArchiver');
1413
const testSubjects = getService('testSubjects');
1514
const kibanaServer = getService('kibanaServer');
1615
const supertest = getService('supertest');
1716
const find = getService('find');
1817
const logger = getService('log');
1918
const retry = getService('retry');
19+
const pageObjects = getPageObjects(['common', 'header']);
2020

2121
describe('Custom threshold preview chart', () => {
2222
const observability = getService('observability');
@@ -34,6 +34,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => {
3434
logger,
3535
});
3636
await observability.alerts.common.navigateToRulesPage();
37+
await pageObjects.header.waitUntilLoadingHasFinished();
3738
});
3839

3940
after(async () => {
@@ -46,7 +47,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => {
4647
await observability.alerts.rulesPage.clickCreateRuleButton();
4748
await observability.alerts.rulesPage.clickOnObservabilityCategory();
4849
await observability.alerts.rulesPage.clickOnCustomThresholdRule();
49-
await common.sleep(1000);
50+
await pageObjects.common.sleep(1000);
5051
expect(await find.existsByCssSelector('[data-rendering-count="2"]')).toBe(true);
5152
});
5253

0 commit comments

Comments
 (0)