From 3d9089673cf724bec97cdd27aea0f89b3c666349 Mon Sep 17 00:00:00 2001 From: Matthias Rolke Date: Thu, 5 Dec 2024 15:54:15 +0100 Subject: [PATCH] fix: improve waiting for opportunity splits to be disabled --- src/plugins/opportunity-splits/index.e2e-spec.ts | 1 + src/plugins/opportunity-splits/index.ts | 4 ++-- src/plugins/opportunity-splits/pages/overview.ts | 8 +------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/plugins/opportunity-splits/index.e2e-spec.ts b/src/plugins/opportunity-splits/index.e2e-spec.ts index 55d9c6ca..656eb3af 100644 --- a/src/plugins/opportunity-splits/index.e2e-spec.ts +++ b/src/plugins/opportunity-splits/index.e2e-spec.ts @@ -7,6 +7,7 @@ import { OpportunitySplits } from './index.js'; const __dirname = fileURLToPath(new URL('.', import.meta.url)); describe(OpportunitySplits.name, function () { + this.timeout('10m'); let plugin: OpportunitySplits; before(() => { plugin = new OpportunitySplits(global.bf); diff --git a/src/plugins/opportunity-splits/index.ts b/src/plugins/opportunity-splits/index.ts index 280f930b..88b889f7 100644 --- a/src/plugins/opportunity-splits/index.ts +++ b/src/plugins/opportunity-splits/index.ts @@ -25,12 +25,12 @@ export class OpportunitySplits extends BrowserforcePlugin { const setupPage = new SetupPage(page); const layoutSelectionPage = await setupPage.enable(); const overviewPage = await layoutSelectionPage.choose(); - await overviewPage.waitUntilEnabled(); + await overviewPage.waitUntilCompleted(); } else { page = await this.browserforce.openPage(OverviewPage.PATH); const overviewPage = new OverviewPage(page); await overviewPage.disable(); - await overviewPage.waitUntilDisabled(); + await overviewPage.waitUntilCompleted(); } await page.close(); } diff --git a/src/plugins/opportunity-splits/pages/overview.ts b/src/plugins/opportunity-splits/pages/overview.ts index c2875c6d..17b426e6 100644 --- a/src/plugins/opportunity-splits/pages/overview.ts +++ b/src/plugins/opportunity-splits/pages/overview.ts @@ -1,6 +1,5 @@ import { Page } from 'puppeteer'; -const IN_PRGOGRESS = '#enablingInProgress'; const COMPLETED = '#prefSettingSucceeded'; const DISABLE_LINK = 'div[id*=":disable_form:"] a'; const DISABLE_CONFIRM_CHECKBOX = 'input#dis_confirm'; @@ -18,8 +17,7 @@ export class OverviewPage { return (await this.page.$(DISABLE_LINK)) !== null; } - public async waitUntilEnabled(): Promise { - await this.page.waitForSelector(IN_PRGOGRESS); + public async waitUntilCompleted(): Promise { // 10 minutes await this.page.waitForSelector(COMPLETED, { timeout: 10 * 60 * 1000 }); } @@ -33,8 +31,4 @@ export class OverviewPage { await Promise.all([this.page.waitForNavigation(), this.page.click(DISABLE_CONFIRM_BUTTON)]); return this; } - - public async waitUntilDisabled(): Promise { - await this.page.waitForSelector(COMPLETED); - } }