From f7ac19efc8af0f4bdda909ef27e3db7a7b76ea78 Mon Sep 17 00:00:00 2001 From: Matthias Rolke Date: Thu, 5 Dec 2024 16:56:43 +0100 Subject: [PATCH 1/2] test: rename test case --- src/plugins/slack/index.e2e-spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/slack/index.e2e-spec.ts b/src/plugins/slack/index.e2e-spec.ts index 268229c8..23abeb43 100644 --- a/src/plugins/slack/index.e2e-spec.ts +++ b/src/plugins/slack/index.e2e-spec.ts @@ -19,10 +19,10 @@ describe(Slack.name, function () { agreeToTermsAndConditions: false, enableSalesCloudForSlack: false }; - it('should accept terms and conditions', async () => { + it('should accept terms and conditions and enable Sales Cloud for Slack', async () => { await plugin.run(configEnable); }); - it('should already be accepted', async () => { + it('should already be accepted and enabled', async () => { const res = await plugin.run(configEnable); assert.deepStrictEqual(res, { message: 'no action necessary' }); }); From a303550c328c41db105d236b605d5eb09b553fcf Mon Sep 17 00:00:00 2001 From: Matthias Rolke Date: Thu, 5 Dec 2024 16:56:43 +0100 Subject: [PATCH 2/2] refactor: simplify handling of web components without shadow root --- src/browserforce.ts | 6 +++--- src/plugins/density-settings/index.ts | 2 +- src/plugins/high-velocity-sales-settings/page.ts | 8 +++----- src/plugins/lightning-experience-settings/index.ts | 6 +++--- src/plugins/linkedin-sales-navigator-settings/page.ts | 5 +++-- src/plugins/slack/index.ts | 4 ++-- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/browserforce.ts b/src/browserforce.ts index 230fff46..68b662b3 100644 --- a/src/browserforce.ts +++ b/src/browserforce.ts @@ -6,7 +6,7 @@ import { LoginPage } from './pages/login.js'; const ERROR_DIV_SELECTOR = '#errorTitle'; const ERROR_DIVS_SELECTOR = 'div.errorMsg'; -const VF_IFRAME_SELECTOR = 'iframe[name^=vfFrameId]'; +const VF_IFRAME_SELECTOR = 'force-aloha-page iframe[name^=vfFrameId]'; export class Browserforce { public org: Org; @@ -99,8 +99,8 @@ export class Browserforce { // Wait for either the selector in the page or in the iframe. // returns the page or the frame public async waitForSelectorInFrameOrPage(page: Page, selector: string): Promise { - await page.waitForSelector(`pierce/${VF_IFRAME_SELECTOR}, ${selector}`); - const frameElementHandle = await page.$(`pierce/${VF_IFRAME_SELECTOR}`); + await page.waitForSelector(`${selector}, ${VF_IFRAME_SELECTOR}`); + const frameElementHandle = await page.$(VF_IFRAME_SELECTOR); let frameOrPage: Page | Frame = page; if (frameElementHandle) { const frame = await page.waitForFrame( diff --git a/src/plugins/density-settings/index.ts b/src/plugins/density-settings/index.ts index 7d4a2f43..acd96bb2 100644 --- a/src/plugins/density-settings/index.ts +++ b/src/plugins/density-settings/index.ts @@ -6,7 +6,7 @@ const PATHS = { }; const SELECTORS = { - PICKER_ITEMS: 'pierce/one-density-visual-picker one-density-visual-picker-item input' + PICKER_ITEMS: 'one-density-visual-picker one-density-visual-picker-item input' }; type Config = { diff --git a/src/plugins/high-velocity-sales-settings/page.ts b/src/plugins/high-velocity-sales-settings/page.ts index b701ecf1..401024ba 100644 --- a/src/plugins/high-velocity-sales-settings/page.ts +++ b/src/plugins/high-velocity-sales-settings/page.ts @@ -3,7 +3,7 @@ import { throwPageErrors } from '../../browserforce.js'; const SET_UP_AND_ENABLE_HVS_BUTTON = 'button.setupAndEnableButton'; const ENABLE_TOGGLE = '#toggleHighVelocitySalesPref'; -const AUTOMATION_TAB_ITEM = 'pierce/#automationTab__item'; +const AUTOMATION_TAB_ITEM = 'lightning-tab-bar li[data-tab-value="automationTab"]'; export class HighVelocitySalesSetupPage { private page: Page; @@ -17,14 +17,12 @@ export class HighVelocitySalesSetupPage { } public async setUpAndEnable(): Promise { - // starting Winter 24 (v59.0) there is a new tab bar and the item is located in the "Automation" tab - // wait for tab item or the button directly - await this.page.waitForSelector(`${AUTOMATION_TAB_ITEM}, ${SET_UP_AND_ENABLE_HVS_BUTTON}`, { timeout: 60_000 }); + await this.page.waitForSelector(AUTOMATION_TAB_ITEM); const tab = await this.page.$(AUTOMATION_TAB_ITEM); if (tab) { await this.page.evaluate((e: HTMLElement) => e.click(), tab); } - await this.page.waitForSelector(SET_UP_AND_ENABLE_HVS_BUTTON, { timeout: 60_000 }); + await this.page.waitForSelector(SET_UP_AND_ENABLE_HVS_BUTTON); const enableButton = await this.page.$(SET_UP_AND_ENABLE_HVS_BUTTON); await Promise.all([ this.page.waitForSelector(ENABLE_TOGGLE, { timeout: 60_000 }), diff --git a/src/plugins/lightning-experience-settings/index.ts b/src/plugins/lightning-experience-settings/index.ts index b28b79d8..d4128f1d 100644 --- a/src/plugins/lightning-experience-settings/index.ts +++ b/src/plugins/lightning-experience-settings/index.ts @@ -5,7 +5,7 @@ const PATHS = { BASE: 'lightning/setup/ThemingAndBranding/home' }; -const THEME_ROW_SELECTOR = 'pierce/#setupComponent lightning-datatable table > tbody > tr'; +const THEME_ROW_SELECTOR = '#setupComponent lightning-datatable table > tbody > tr'; const SELECTORS = { DEVELOPER_NAMES: `${THEME_ROW_SELECTOR} > td:nth-child(2) > lightning-primitive-cell-factory lightning-base-formatted-text`, STATES: `${THEME_ROW_SELECTOR} > td:nth-child(6) > lightning-primitive-cell-factory` @@ -71,13 +71,13 @@ export class LightningExperienceSettings extends BrowserforcePlugin { visible: true }); const menuButton = await newActiveThemeRowElementHandle.$( - 'pierce/td lightning-primitive-cell-factory lightning-primitive-cell-actions lightning-button-menu' + 'td lightning-primitive-cell-factory lightning-primitive-cell-actions lightning-button-menu' ); await page.evaluate((e: HTMLElement) => e.click(), menuButton); await page.waitForSelector(`${THEME_ROW_SELECTOR} lightning-button-menu slot lightning-menu-item`, { visible: true }); - const menuItems = await menuButton!.$$('pierce/slot lightning-menu-item'); + const menuItems = await menuButton!.$$('slot lightning-menu-item'); // second last item: [show, activate, preview] const activateMenuItem = menuItems[menuItems.length - 2]; await Promise.all([page.waitForNavigation(), page.evaluate((e: HTMLElement) => e.click(), activateMenuItem)]); diff --git a/src/plugins/linkedin-sales-navigator-settings/page.ts b/src/plugins/linkedin-sales-navigator-settings/page.ts index b417187d..fa720ed4 100644 --- a/src/plugins/linkedin-sales-navigator-settings/page.ts +++ b/src/plugins/linkedin-sales-navigator-settings/page.ts @@ -3,7 +3,7 @@ import { throwPageErrors } from '../../browserforce.js'; const ENABLE_TOGGLE = 'div[data-aura-class="setup_sales_linkedinLinkedInSetupRow"] input[type="checkbox"]'; const CONFIRM_CHECKBOX = - 'pierce/lightning-primitive-input-checkbox input[name="LinkedIn Sales Navigator Integration Acceptance Checkbox"]'; + 'lightning-input lightning-primitive-input-checkbox input[name="LinkedIn Sales Navigator Integration Acceptance Checkbox"]'; const ACCEPT_BUTTON = 'section[data-aura-class="setup_sales_linkedinLinkedInSetupAcceptTermsModal"] div div button:not(:disabled):nth-child(2)'; @@ -27,7 +27,8 @@ export class LinkedInSalesNavigatorPage { public async setStatus(enable: boolean): Promise { await this.page.waitForSelector(ENABLE_TOGGLE, { visible: true }); - await this.page.click(ENABLE_TOGGLE); + const toggle = await this.page.$(ENABLE_TOGGLE); + await toggle?.evaluate((input: HTMLInputElement) => input.click()); if (enable) { await this.page.waitForSelector(CONFIRM_CHECKBOX, { visible: true }); diff --git a/src/plugins/slack/index.ts b/src/plugins/slack/index.ts index 79a141bd..e79bc651 100644 --- a/src/plugins/slack/index.ts +++ b/src/plugins/slack/index.ts @@ -5,9 +5,9 @@ const PATHS = { }; const SELECTORS = { TOS_LIGHTNING_INPUT: - 'pierce/setup_service-slack-setup-assistant-container setup_service-slack-agree-to-terms lightning-input', + 'setup_service-slack-setup-assistant-container setup_service-slack-agree-to-terms lightning-input', SALES_CLOUD_FOR_SLACK_TOGGLE: - 'pierce/setup_service-slack-setup-assistant-container setup_service-stage setup_service-steps setup_service-step lightning-input:has(lightning-primitive-input-toggle input[name="SlkSetupStepSalesCloudForSlack"])', + 'setup_service-slack-setup-assistant-container setup_service-stage setup_service-steps setup_service-step lightning-input:has(lightning-primitive-input-toggle input[name="SlkSetupStepSalesCloudForSlack"])', TOAST_MESSAGE: 'div[id^="toastDescription"]' };