How to use the ringcentral-integration/lib/sleep function in ringcentral-integration

To help you get started, weā€™ve selected a few ringcentral-integration examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ringcentral / ringcentral-js-widgets / packages / ringcentral-e2e-test / src / steps / office / addMeeting.js View on Github external
static async checkVideoLocaExist(context){
    console.log('==========check video location==========');
    const page = context.page;

    // close the native dialogs
    page.on('dialog',async dialog => {
      dialog.dismiss()
    });
    await sleep(3000);

    const text = await page.evaluate(()=>{
      var a = document.getElementById('MeetingCompose.LocationInputLabel');
      return a && a.parentElement.innerHTML;
    });
    const brand = context.options.tag.brands;
    const result = video_zoom_reg[brand].test(text);
    return result;
  }
github ringcentral / ringcentral-js-widgets / packages / ringcentral-e2e-test / src / features / Office365 / contacts / index.js View on Github external
async function testContacts(contactsNames) {
      for (let contactName of contactsNames) {
        console.log(`Seaching ${contactName} in CTI...`);
        const searchBar = await page.$(searchBarSelector);
        expect(searchBar).toBeTruthy();
        await searchBar.click();
        await searchBar.focus();
        // click three times to select all
        await searchBar.click({
          clickCount: 3
        });
        await searchBar.press('Backspace');
        await searchBar.type(contactName);
        await sleep(800);
        const contactItemSelector = `div[title="${contactName}"]`;
        const resultLength = await page.evaluate((contactName, contactItemSelector) => (
          Array.prototype.slice.call(document.querySelectorAll(contactItemSelector)).length
        ), contactName, contactItemSelector);
        expect(resultLength).toBeGreaterThanOrEqual(0);
        await $(page).click(contactItemSelector, {
          selector: 'css'
        });
        await sleep(800);
    
        const contactTitleSelector = `span[title="${contactName}"]`;
        const contactTitle = await page.evaluate((contactName, contactTitleSelector) => (
          document.querySelector(contactTitleSelector).innerText
        ), contactName, contactTitleSelector);
        expect(contactTitle).toEqual(contactName);
        await $(page).click(backBtnSelector, {
github ringcentral / ringcentral-js-widgets / packages / ringcentral-e2e-test / src / features / Office365 / contacts / index.js View on Github external
// HACK: get the expand icon selector, seems to be /^_ariaId_\d{3}$/
  const contactFolderExpandIconSelector = `button[aria-labelledby="_ariaId_${+contactFolderId.replace('_ariaId_','') + 1}"]`;

  if (!expanded) {
    console.log('Clicking to expand the contacts section tree.')
    await $(outlookPage).click(contactFolderExpandIconSelector, {
      selector: 'css'
    });
  }

  console.log('Clicking contact entry and waiting for 15s for entry page to laod.')
  await $(outlookPage).click(contactsEntry, {
    selector: 'css'
  });
  await sleep(15000); // wait for loading
  console.log('Get contacts names');

  // get contact names of the first page.
  const officeContactsNames = await outlookPage.evaluate(
    (contactListSelector, ariaLableAttr) => (
      Array.prototype.slice.call(document.querySelectorAll(contactListSelector))
      .map(dom => dom.getAttribute(ariaLableAttr).replace('. Press enter to view more details.', ''))
    ),
    contactListSelector,
    ariaLableAttr,
  );

  console.log(`Close outlook page, got ${officeContactsNames.length} countacts from first page: ${officeContactsNames.join(', ')}.`);
  outlookPage.close();
  // const officeContactsNames = ["AB 100", "AB 1000", "AB 1001", "AB 1002", "AB 1003", "AB 1004", "AB 1005", "AB 1006", "AB 1007", "AB 1008", "AB 1009", "AB 101", "AB 1010", "AB 1011", "AB 1012", "AB 1013", "AB 1014", "AB 1015", "AB 1016", "AB 1017", "AB 1018", "AB 1019", "AB 102", "AB 1020", "AB 1021", "AB 1022", "AB 1023", "AB 1024", "AB 1025", "AB 1026", "AB 1027", "AB 1028", "AB 1029", "AB 103", "AB 1030", "AB 1031", "AB 1032", "AB 1033", "AB 1034", "AB 1035", "AB 1036", "AB 1037", "AB 1038", "AB 1039", "AB 104", "AB 1040", "AB 1041", "AB 1042", "AB 1043", "AB 1044"];
github ringcentral / ringcentral-js-widgets / packages / ringcentral-e2e-test / src / features / Office365 / oauth / index.js View on Github external
// const process = createProcess(
  //   Entry,
  //   Login,
  //   AuthorizeOffice
  // )(context);
  // Authroize Office365
  // await process.exec();
  await detectAuthPanel(true, options);
  /** Click logout and relogin, user still Authorized **/
  await $(page).waitFor('[class*="loginNumber"]', {
    selector: 'css'
  });
  await $(page).click('[class*="loginNumber"]', {
    selector: 'css'
  });
  sleep(2000);
  await Login.login({
    noSkipUserGuide: true
  });
  await detectAuthPanel(true, options);
  /** Click the Unauthorise button **/
  await $(page).click('button[class*="AuthorizeSettingsPanel"]', {
    selector: 'css'
  });
  await detectAuthPanel(false, options);
}
github ringcentral / ringcentral-js-widgets / packages / ringcentral-e2e-test / src / features / Office365 / contacts / index.js View on Github external
return Array.prototype.slice.call(document.querySelectorAll(contactNameSelector)).map(
        dom=>dom.innerText
      ).filter(v => !!v)
    }, contactNameSelector);
    await testContacts(contactsNames.slice(0,1));
  }

  console.log('Reset the filter to all');
  await $(page).click(contactFilterSelector, {
    selector: 'css'
  });
  filterHandlers = await page.$$(contactFilterItemSelector, {
    selector: 'css'
  });
  filterHandlers[0].click();
  await sleep(500);

  console.log('Testing office contacts...');
  await testContacts(officeContactsNames);
}
github ringcentral / ringcentral-js-widgets / packages / ringcentral-widgets / containers / CallCtrlPage / CallCtrlContainer.js View on Github external
async onLastMergingCallEnded() {
    if (this._mounted) {
      await sleep(2000);

      if (this._mounted) {
        this.setState({
          layout: callCtrlLayouts.normalCtrl,
        });
      }

      if (this.props.closeMergingPair) {
        this.props.closeMergingPair();
      }
    }
  }
github ringcentral / ringcentral-embeddable / src / modules / Adapter / index.js View on Github external
async _sendActiveCallNotification(activeCalls) {
    await sleep(CALL_NOTIFY_DELAY);
    const activeCallLogMap = {};
    this._activeCalls.calls.forEach((call) => {
      activeCallLogMap[`${call.sessionId}-${call.direction}`] = call;
    });
    activeCalls.forEach(({ sipData, id, ...call }) => {
      let matchedCallLog = activeCallLogMap[`${call.sessionId}-${call.direction}`];
      if (!matchedCallLog) {
        matchedCallLog = this._lastActiveCallLogMap[`${call.sessionId}-${call.direction}`] || {};
      } else {
        this._lastActiveCallLogMap[`${call.sessionId}-${call.direction}`] = matchedCallLog;
      }
      this._postMessage({
        type: 'rc-active-call-notify',
        call: {
          id: matchedCallLog.id,
          action: matchedCallLog.action,
github ringcentral / ringcentral-js-widgets / src / components / AnimationAlert / index.js View on Github external
if (isAddedMessage) {
            animation = entranceAnimation;
          } else if (isRemovedMessage) {
            animation = exitAnimation;
          }
          return {
            ...message,
            ...animation ? { animation } : {},
            duration,
          };
        });
      const stateWithAnimation = {
        messages,
      };
      this.setState(stateWithAnimation);
      await sleep(duration);

      if (!this.mounted) return;

      const isCurrentEmpty = currentMessagesIDs.length === 0;
      this.setState({
        messages: isCurrentEmpty ? messages : nextProps.messages,
      });
    })();
  }