Skip to content

Commit

Permalink
[Synthetics] Update e2e flaky test !! (elastic#203397)
Browse files Browse the repository at this point in the history
## Summary

Update e2e flaky test !!
  • Loading branch information
shahzad31 authored Dec 10, 2024

Verified

This commit was signed with the committer’s verified signature.
mistic Tiago Costa
1 parent 561eff3 commit 9089dbe
Showing 3 changed files with 97 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -201,7 +201,7 @@ const createMonitorJourney = ({
await syntheticsApp.createMonitor({ monitorConfig, monitorType });
await page.waitForSelector('text=Monitor name already exists');
await syntheticsApp.clickByTestSubj('syntheticsMonitorConfigSubmitButton');
await page.waitForSelector('text=Cancel');
await page.click('text=Cancel');
});

step('delete monitor', async () => {
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
*/

import { before, expect, journey, step } from '@elastic/synthetics';
import { RetryService } from '@kbn/ftr-common-functional-services';
import {
addTestMonitor,
cleanTestMonitors,
@@ -19,6 +20,8 @@ journey('OverviewSorting', async ({ page, params }) => {
const testMonitor2 = 'aCd'; // third alpha, second created
const testMonitor3 = 'Abc'; // first alpha, last created

const retry: RetryService = params.getService('retry');

before(async () => {
await enableMonitorManagedViaApi(params.kibanaUrl);
await cleanTestMonitors(params);
@@ -42,83 +45,91 @@ journey('OverviewSorting', async ({ page, params }) => {
});

step('sort alphabetical asc', async () => {
await page.waitForSelector(`[data-test-subj="syntheticsOverviewGridItem"]`);
await page.click('[data-test-subj="syntheticsOverviewSortButton"]');
await page.click('button:has-text("Alphabetical")');
await page.waitForSelector(`text=${testMonitor1}`);
await page.waitForSelector(`text=${testMonitor2}`);
await page.waitForSelector(`text=${testMonitor3}`);
const gridItems = await page.locator(`[data-test-subj="syntheticsOverviewGridItem"]`);
const first = await gridItems.nth(0);
const second = await gridItems.nth(1);
const third = await gridItems.nth(2);
const correctFirstMonitor = await first.locator(`button:has-text('${testMonitor3}')`);
const correctSecondMonitor = await second.locator(`button:has-text('${testMonitor1}')`);
const correctThirdMonitor = await third.locator(`button:has-text('${testMonitor2}')`);
expect(await correctFirstMonitor.count()).toBe(1);
expect(await correctSecondMonitor.count()).toBe(1);
expect(await correctThirdMonitor.count()).toBe(1);
await retry.try(async () => {
await page.waitForSelector(`[data-test-subj="syntheticsOverviewGridItem"]`);
await page.click('[data-test-subj="syntheticsOverviewSortButton"]');
await page.click('button:has-text("Alphabetical")');
await page.waitForSelector(`text=${testMonitor1}`);
await page.waitForSelector(`text=${testMonitor2}`);
await page.waitForSelector(`text=${testMonitor3}`);
const gridItems = await page.locator(`[data-test-subj="syntheticsOverviewGridItem"]`);
const first = await gridItems.nth(0);
const second = await gridItems.nth(1);
const third = await gridItems.nth(2);
const correctFirstMonitor = await first.locator(`button:has-text('${testMonitor3}')`);
const correctSecondMonitor = await second.locator(`button:has-text('${testMonitor1}')`);
const correctThirdMonitor = await third.locator(`button:has-text('${testMonitor2}')`);
expect(await correctFirstMonitor.count()).toBe(1);
expect(await correctSecondMonitor.count()).toBe(1);
expect(await correctThirdMonitor.count()).toBe(1);
});
});

step('sort alphabetical desc', async () => {
await page.waitForSelector(`[data-test-subj="syntheticsOverviewGridItem"]`);
await page.click('[data-test-subj="syntheticsOverviewSortButton"]');
await page.click('button:has-text("Z -> A")');
await page.waitForSelector(`text=${testMonitor1}`);
await page.waitForSelector(`text=${testMonitor2}`);
await page.waitForSelector(`text=${testMonitor3}`);
const gridItems = await page.locator(`[data-test-subj="syntheticsOverviewGridItem"]`);
const first = await gridItems.nth(0);
const second = await gridItems.nth(1);
const third = await gridItems.nth(2);
const correctFirstMonitor = await first.locator(`button:has-text('${testMonitor2}')`);
const correctSecondMonitor = await second.locator(`button:has-text('${testMonitor1}')`);
const correctThirdMonitor = await third.locator(`button:has-text('${testMonitor3}')`);
expect(await correctFirstMonitor.count()).toBe(1);
expect(await correctSecondMonitor.count()).toBe(1);
expect(await correctThirdMonitor.count()).toBe(1);
await retry.try(async () => {
await page.waitForSelector(`[data-test-subj="syntheticsOverviewGridItem"]`);
await page.click('[data-test-subj="syntheticsOverviewSortButton"]');
await page.click('button:has-text("Z -> A")');
await page.waitForSelector(`text=${testMonitor1}`);
await page.waitForSelector(`text=${testMonitor2}`);
await page.waitForSelector(`text=${testMonitor3}`);
const gridItems = await page.locator(`[data-test-subj="syntheticsOverviewGridItem"]`);
const first = await gridItems.nth(0);
const second = await gridItems.nth(1);
const third = await gridItems.nth(2);
const correctFirstMonitor = await first.locator(`button:has-text('${testMonitor2}')`);
const correctSecondMonitor = await second.locator(`button:has-text('${testMonitor1}')`);
const correctThirdMonitor = await third.locator(`button:has-text('${testMonitor3}')`);
expect(await correctFirstMonitor.count()).toBe(1);
expect(await correctSecondMonitor.count()).toBe(1);
expect(await correctThirdMonitor.count()).toBe(1);
});
});

step('sort last updated asc', async () => {
await page.waitForSelector(`[data-test-subj="syntheticsOverviewGridItem"]`);
await page.click('[data-test-subj="syntheticsOverviewSortButton"]');
await page.click('button:has-text("Last modified")');
await page.waitForSelector(`text=${testMonitor1}`);
await page.waitForSelector(`text=${testMonitor2}`);
await page.waitForSelector(`text=${testMonitor3}`);
const gridItems = await page.locator(`[data-test-subj="syntheticsOverviewGridItem"]`);
const first = await gridItems.nth(0);
const second = await gridItems.nth(1);
const third = await gridItems.nth(2);
const correctFirstMonitor = await first.locator(`button:has-text('${testMonitor3}')`);
const correctSecondMonitor = await second.locator(`button:has-text('${testMonitor2}')`);
const correctThirdMonitor = await third.locator(`button:has-text('${testMonitor1}')`);
expect(await correctFirstMonitor.count()).toBe(1);
expect(await correctSecondMonitor.count()).toBe(1);
expect(await correctThirdMonitor.count()).toBe(1);
await retry.try(async () => {
await page.waitForSelector(`[data-test-subj="syntheticsOverviewGridItem"]`);
await page.click('[data-test-subj="syntheticsOverviewSortButton"]');
await page.click('button:has-text("Last modified")');
await page.waitForSelector(`text=${testMonitor1}`);
await page.waitForSelector(`text=${testMonitor2}`);
await page.waitForSelector(`text=${testMonitor3}`);
const gridItems = await page.locator(`[data-test-subj="syntheticsOverviewGridItem"]`);
const first = await gridItems.nth(0);
const second = await gridItems.nth(1);
const third = await gridItems.nth(2);
const correctFirstMonitor = await first.locator(`button:has-text('${testMonitor3}')`);
const correctSecondMonitor = await second.locator(`button:has-text('${testMonitor2}')`);
const correctThirdMonitor = await third.locator(`button:has-text('${testMonitor1}')`);
expect(await correctFirstMonitor.count()).toBe(1);
expect(await correctSecondMonitor.count()).toBe(1);
expect(await correctThirdMonitor.count()).toBe(1);
});
});

step('sort last updated desc', async () => {
await page.waitForSelector(`[data-test-subj="syntheticsOverviewGridItem"]`);
await page.click('[data-test-subj="syntheticsOverviewSortButton"]');
await page.click('button:has-text("Oldest first")');
await page.waitForSelector(`text=${testMonitor1}`);
await page.waitForSelector(`text=${testMonitor2}`);
await page.waitForSelector(`text=${testMonitor3}`);
const gridItems = await page.locator(`[data-test-subj="syntheticsOverviewGridItem"]`);
const first = await gridItems.nth(0);
const second = await gridItems.nth(1);
const third = await gridItems.nth(2);
const correctFirstMonitor = await first.locator(`button:has-text('${testMonitor1}')`);
const correctSecondMonitor = await second.locator(`button:has-text('${testMonitor2}')`);
const correctThirdMonitor = await third.locator(`button:has-text('${testMonitor3}')`);
expect(await correctFirstMonitor.count()).toBe(1);
expect(await correctSecondMonitor.count()).toBe(1);
expect(await correctThirdMonitor.count()).toBe(1);
await retry.try(async () => {
await page.waitForSelector(`[data-test-subj="syntheticsOverviewGridItem"]`);
await page.click('[data-test-subj="syntheticsOverviewSortButton"]');
await page.click('button:has-text("Oldest first")');
await page.waitForSelector(`text=${testMonitor1}`);
await page.waitForSelector(`text=${testMonitor2}`);
await page.waitForSelector(`text=${testMonitor3}`);
const gridItems = await page.locator(`[data-test-subj="syntheticsOverviewGridItem"]`);
const first = await gridItems.nth(0);
const second = await gridItems.nth(1);
const third = await gridItems.nth(2);
const correctFirstMonitor = await first.locator(`button:has-text('${testMonitor1}')`);
const correctSecondMonitor = await second.locator(`button:has-text('${testMonitor2}')`);
const correctThirdMonitor = await third.locator(`button:has-text('${testMonitor3}')`);
expect(await correctFirstMonitor.count()).toBe(1);
expect(await correctSecondMonitor.count()).toBe(1);
expect(await correctThirdMonitor.count()).toBe(1);
});
});

step('delete monitors', async () => {
await syntheticsApp.navigateToMonitorManagement();
await page.getByTestId('syntheticsMonitorManagementTab').click();
expect(await syntheticsApp.deleteMonitors()).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -128,28 +128,26 @@ export function syntheticsAppPageProvider({
},

async deleteMonitors() {
let isSuccessful: boolean = false;
while (true) {
if (
!(await page.isVisible(this.byTestId('euiCollapsedItemActionsButton'), { timeout: 0 }))
) {
isSuccessful = true;
break;
}
await page.click(this.byTestId('euiCollapsedItemActionsButton'), {
delay: 800,
force: true,
});
await page.click(`.euiContextMenuPanel ${this.byTestId('syntheticsMonitorDeleteAction')}`, {
delay: 800,
});
await page.waitForSelector('[data-test-subj="confirmModalTitleText"]');
await this.clickByTestSubj('confirmModalConfirmButton');
isSuccessful = Boolean(await this.findByTestSubj('uptimeDeleteMonitorSuccess'));
await this.navigateToMonitorManagement();
await page.waitForTimeout(5 * 1000);
if (!page.url().includes('monitors/management')) {
return true;
}
return isSuccessful;
await page.getByTestId('euiCollapsedItemActionsButton').first().click();
await page.click(`.euiContextMenuPanel ${this.byTestId('syntheticsMonitorDeleteAction')}`, {
delay: 800,
});
await page.waitForSelector('[data-test-subj="confirmModalTitleText"]');
await page.getByTestId('confirmModalConfirmButton').click();
await page.getByTestId('uptimeDeleteMonitorSuccess').click();
await page.getByTestId('syntheticsRefreshButtonButton').click();

await page.getByTestId('checkboxSelectAll').click();
await page
.getByTestId('syntheticsBulkOperationPopoverClickMeToLoadAContextMenuButton')
.click();

await page.getByTestId('confirmModalConfirmButton').click();

return true;
},

async navigateToEditMonitor(monitorName: string) {
@@ -387,6 +385,7 @@ export function syntheticsAppPageProvider({
await button?.click();
}
},

async checkIsEnabled() {
await page.waitForTimeout(5 * 1000);
const addMonitorBtn = await this.getAddMonitorButton();

0 comments on commit 9089dbe

Please sign in to comment.