Skip to content

Commit 8ecefc0

Browse files
committed
fix: cpqsettings wait
1 parent 43028f5 commit 8ecefc0

File tree

1 file changed

+7
-8
lines changed
  • src/commands/texei/cpqsettings

1 file changed

+7
-8
lines changed

src/commands/texei/cpqsettings/set.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ export default class Set extends SfCommand<CpqSettingsSetResult> {
7373
});
7474
const page = await browser.newPage();
7575

76+
const waitForNavigationOptions: puppeteer.WaitForOptions = { waitUntil: ['domcontentloaded', 'networkidle2'] };
77+
7678
this.log(`Logging in to instance ${instanceUrl}`);
77-
await page.goto(frontdoorUrl, { waitUntil: ['domcontentloaded', 'networkidle0'] });
78-
const navigationPromise = page.waitForNavigation();
79+
await page.goto(frontdoorUrl, waitForNavigationOptions);
7980

8081
this.log(`Navigating to CPQ Settings Page ${cpqSettingsUrl}`);
81-
await page.goto(`${cpqSettingsUrl}`);
82-
await navigationPromise;
82+
await page.goto(`${cpqSettingsUrl}`, waitForNavigationOptions);
8383

8484
// Looking for all elements to update
8585
// Iterating on tabs
@@ -94,7 +94,6 @@ export default class Set extends SfCommand<CpqSettingsSetResult> {
9494
// Clicking on tab
9595
const tab = tabs[0].asElement() as ElementHandle<Element>;
9696
await tab.click();
97-
await navigationPromise;
9897

9998
// For all fields on tab
10099
for (const key of Object.keys(cpqSettings[tabKey])) {
@@ -130,7 +129,7 @@ export default class Set extends SfCommand<CpqSettingsSetResult> {
130129
);
131130

132131
await targetInput?.click();
133-
await navigationPromise;
132+
await page.waitForNavigation();
134133

135134
this.spinner.stop(`Checkbox Value updated from ${currentValue} to ${cpqSettings[tabKey][key]}`);
136135
} else {
@@ -195,8 +194,8 @@ export default class Set extends SfCommand<CpqSettingsSetResult> {
195194
this.spinner.start('Saving changes', undefined, { stdout: true });
196195
const saveButton = await page.$("#page\\:form input[value='Save']");
197196
await saveButton?.click();
198-
await navigationPromise;
199-
// Timeout to wait for save, there should be a better way to do it
197+
await page.waitForNavigation();
198+
200199
await new Promise((r) => setTimeout(r, 3000));
201200

202201
// Look for errors

0 commit comments

Comments
 (0)