Skip to content

Commit

Permalink
fix: improve waiting for opportunity splits to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
amtrack committed Dec 5, 2024
1 parent 829c7c2 commit 3d90896
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/plugins/opportunity-splits/index.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/opportunity-splits/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/opportunity-splits/pages/overview.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,8 +17,7 @@ export class OverviewPage {
return (await this.page.$(DISABLE_LINK)) !== null;
}

public async waitUntilEnabled(): Promise<void> {
await this.page.waitForSelector(IN_PRGOGRESS);
public async waitUntilCompleted(): Promise<void> {
// 10 minutes
await this.page.waitForSelector(COMPLETED, { timeout: 10 * 60 * 1000 });
}
Expand All @@ -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<void> {
await this.page.waitForSelector(COMPLETED);
}
}

0 comments on commit 3d90896

Please sign in to comment.