import Page from "./page"

class Home extends Page {
  get topbar() {
    return browser.$("#topbar")
  }

  get ie11BannerText() {
    const ieBanner = browser.$("#ieBanner")
    ieBanner.waitForExist()
    ieBanner.waitForDisplayed()
    return browser.$("#ieBanner > div:nth-child(2)").getText()
  }

  get securityBanner() {
    const banner = browser.$("#topbar .banner")
    banner.waitForExist()
    banner.waitForDisplayed()
    return banner
  }

  get searchBar() {
    return browser.$("#searchBarInput")
  }

  get homeTilesContainer() {
    return browser.$("fieldset.home-tile-row")
  }

  get pendingMyApprovalOfCount() {
    return browser
      .$('//button[contains(text(), "Reports pending my approval")]')
      .$("h1")
  }

  get submitSearch() {
    return browser.$("#topbar #searchBarSubmit")
  }

  get linksMenuButton() {
    return browser.$('//a[text()="My Work"]')
  }

  get myOrgLink() {
    return browser.$("#my-organization")
  }

  get myTasksLink() {
    return browser.$("#my-tasks-nav")
  }

  get myCounterpartsLink() {
    return browser.$('//a//span[text()="My Counterparts"]')
  }

  get myCounterpartsNotifications() {
    return this.myCounterpartsLink.$("span:last-child")
  }

  get myTasksNotifications() {
    return this.myTasksLink.$("span:last-child")
  }

  get onboardingPopover() {
    return browser.$(".hopscotch-bubble-container")
  }

  waitForSecurityBannerValue(value) {
    this.securityBanner.waitForExist()
    this.securityBanner.waitForDisplayed()
    return browser.waitUntil(
      () => {
        return this.securityBanner.getText() === value
      },
      { timeout: 5000, timeoutMsg: "Expected different banner text after 5s" }
    )
  }
}

export default new Home()

@@ -938,14 +938,31 @@
 r.$(
-%22#my-o
+'//a//span%5Btext()=%22My O
 rgan
@@ -969,16 +969,18 @@
 ization%22
+%5D'
 )%0A  %7D%0A%0A 
@@ -1025,23 +1025,52 @@
 r.$(
-%22#my-tasks-nav%22
+'//a//span%5Btext()=%22My Objective / Efforts%22%5D'
 )%0A  

Fix myTasks tests