Skip to content

Commit

Permalink
fix: cpqsettings wait
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjaouen committed Oct 17, 2024
1 parent 43028f5 commit 8ecefc0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/commands/texei/cpqsettings/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ export default class Set extends SfCommand<CpqSettingsSetResult> {
});
const page = await browser.newPage();

const waitForNavigationOptions: puppeteer.WaitForOptions = { waitUntil: ['domcontentloaded', 'networkidle2'] };

this.log(`Logging in to instance ${instanceUrl}`);
await page.goto(frontdoorUrl, { waitUntil: ['domcontentloaded', 'networkidle0'] });
const navigationPromise = page.waitForNavigation();
await page.goto(frontdoorUrl, waitForNavigationOptions);

this.log(`Navigating to CPQ Settings Page ${cpqSettingsUrl}`);
await page.goto(`${cpqSettingsUrl}`);
await navigationPromise;
await page.goto(`${cpqSettingsUrl}`, waitForNavigationOptions);

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

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

await targetInput?.click();
await navigationPromise;
await page.waitForNavigation();

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

await new Promise((r) => setTimeout(r, 3000));

// Look for errors
Expand Down

0 comments on commit 8ecefc0

Please sign in to comment.