<commit_before>helpers          = require '../helpers/helpers.js'
activitySelector = '[testpath=activity-list] section:nth-of-type(1) [testpath=ActivityListItemView]:first-child'

module.exports =

  # searchActivity: (browser) ->

  #   post     = helpers.postActivity(browser)
  #   selector = '[testpath=activity-list] [testpath=ActivityListItemView]:first-child'
  #   word     = post.split(' ')[0]

  #   browser
  #     .setValue                 '.kdtabhandlecontainer .search-input', word + '\n'
  #     .waitForElementVisible    '.kdtabpaneview.search', 25000
  #     .waitForElementVisible    selector, 25000
  #     .pause                    25000
  #     .assert.containsText      selector, word # Assertion
  #     .end()


  showMoreCommentLink: (browser) ->

    helpers.postComment(browser)
    helpers.postComment(browser, no, no)  for i in [1..4]

    browser
      .refresh()
      .pause 2000  # an unfortunate fix for the wsod
      .refresh()
      .waitForElementVisible  "#{activitySelector} [testpath=list-previous-link]", 25000
      .end()


  sendHashtagActivity: (browser) ->

    helpers.beginTest(browser)

    helpers.sendHashtagActivity(browser)
    browser.end()


  searchTopicInChannelList: (browser) ->

    helpers.beginTest(browser)

    channelSelector = '.activity-sidebar .followed .sidebar-title'
    searchSelector  = '.kdmodal-inner .kdmodal-content input.search-input'

    hashtag = helpers.sendHashtagActivity(browser)

    browser
      .waitForElementVisible  channelSelector, 20000
      .click                  channelSelector
      .waitForElementVisible  '.more-channels', 20000
      .waitForElementVisible  searchSelector, 20000
      .setValue               searchSelector, hashtag + '\n'
      .waitForElementVisible  ".listview-wrapper [testpath=\"public-feed-link/Activity/Topic/#{hashtag.replace '#', ''}\"]", 20000 # Assertion
      .end()


  followTopic: (browser) ->

    helpers.beginTest(browser)

    helpers.doFollowTopic(browser)
    browser.end()


  unfollowTopic: (browser) ->

    helpers.beginTest(browser)

    hashtag        = helpers.doFollowTopic(browser)
    publicSelector = '#main-sidebar [testpath="public-feed-link/Activity/Topic/public"]'
    topicSelector  = "#main-sidebar [testpath=\"public-feed-link/Activity/Topic/#{hashtag.replace '#', ''}\"]"
    recentSelector = "[testpath=\"ActivityTabHandle-/Activity/Public/Recent\"]"

    browser
      .click                     '[testpath=channel-title] .following'
      .waitForElementNotVisible  topicSelector, 25000
      .waitForElementVisible     publicSelector, 25000
      .click                     publicSelector
      .waitForElementVisible     recentSelector, 25000
      .refresh()
      .pause 2000  # an unfortunate fix for the wsod
      .refresh()
      .waitForElementVisible     publicSelector, 25000
      .assert.elementNotPresent  topicSelector
      .end()


  changeMostLikedMostRecentTab: (browser) ->

    user             = helpers.beginTest(browser)
    postSelector     = "#{activitySelector} .activity-content-wrapper"
    mostLikeSelector = '.kdtabhandlecontainer [testpath="ActivityTabHandle-/Activity/Public/Liked"]'
    mostLikedPostSelector = '.most-liked [testpath=ActivityListItemView]'

    post = helpers.likePost(browser, user)

    browser
      .refresh()
      .click                   '[testpath="public-feed-link/Activity/Topic/public"]'
      .waitForElementVisible   '[testpath=ActivityInputView]', 10000
      .waitForElementVisible   mostLikeSelector, 20000
      .click                   mostLikeSelector
      .waitForElementVisible   mostLikedPostSelector, 20000
      .assert.containsText     '.kdtabpaneview.most-liked', post # Assertion
      .end()


  switchBetweenChannels: (browser) ->

    helpers.beginTest(browser)

    firstHashtag  = helpers.doFollowTopic(browser)
    secondHashtag = helpers.doFollowTopic(browser)

    firstHashtag  = firstHashtag.replace '#', ''
    secondHashtag = secondHashtag.replace '#', ''

    channelTitle          = '[testpath=channel-title]'
    firstHashtagSelector  = ".followed.topics [testpath='public-feed-link/Activity/Topic/#{firstHashtag}']"
    secondHashtagSelector = ".followed.topics [testpath='public-feed-link/Activity/Topic/#{secondHashtag}']"

    browser
      .waitForElementVisible  firstHashtagSelector, 20000
      .click                  firstHashtagSelector
      .assert.containsText    channelTitle, firstHashtag # Assertion
      .waitForElementVisible  secondHashtagSelector,20000
      .click                  secondHashtagSelector
      .assert.containsText    channelTitle, secondHashtag # Assertion
      .end()
<commit_msg>Tests: Activity: Others: Improvement for searchTopicInChannelList test.<commit_after>helpers          = require '../helpers/helpers.js'
activitySelector = '[testpath=activity-list] section:nth-of-type(1) [testpath=ActivityListItemView]:first-child'

module.exports =

  # searchActivity: (browser) ->

  #   post     = helpers.postActivity(browser)
  #   selector = '[testpath=activity-list] [testpath=ActivityListItemView]:first-child'
  #   word     = post.split(' ')[0]

  #   browser
  #     .setValue                 '.kdtabhandlecontainer .search-input', word + '\n'
  #     .waitForElementVisible    '.kdtabpaneview.search', 25000
  #     .waitForElementVisible    selector, 25000
  #     .pause                    25000
  #     .assert.containsText      selector, word # Assertion
  #     .end()


  showMoreCommentLink: (browser) ->

    helpers.postComment(browser)
    helpers.postComment(browser, no, no)  for i in [1..4]

    browser
      .refresh()
      .pause 2000  # an unfortunate fix for the wsod
      .refresh()
      .waitForElementVisible  "#{activitySelector} [testpath=list-previous-link]", 25000
      .end()


  sendHashtagActivity: (browser) ->

    helpers.beginTest(browser)

    helpers.sendHashtagActivity(browser)
    browser.end()


  searchTopicInChannelList: (browser) ->

    helpers.beginTest(browser)

    titleSelector  = '.activity-sidebar .followed .sidebar-title'
    plusSelector   = "#{titleSelector} .add-icon"
    modalSelector  = '.kdmodal-inner .kdmodal-content'
    searchSelector = "#{modalSelector} input.search-input"
    loaderSelector = "#{modalSelector} .lazy-loader"

    hashtag = helpers.sendHashtagActivity(browser)

    browser
      .waitForElementVisible     titleSelector, 20000
      .moveToElement             titleSelector, 5, 10
      .waitForElementVisible     plusSelector, 20000
      .click                     plusSelector
      .waitForElementVisible     '.topic-search', 20000
      .waitForElementVisible     searchSelector, 20000
      .waitForElementNotVisible  loaderSelector, 25000
      .setValue                  searchSelector, hashtag + '\n'
      .waitForElementVisible     ".listview-wrapper [testpath=\"public-feed-link/Activity/Topic/#{hashtag.replace '#', ''}\"]", 20000 # Assertion
      .end()


  followTopic: (browser) ->

    helpers.beginTest(browser)

    helpers.doFollowTopic(browser)
    browser.end()


  unfollowTopic: (browser) ->

    helpers.beginTest(browser)

    hashtag        = helpers.doFollowTopic(browser)
    publicSelector = '#main-sidebar [testpath="public-feed-link/Activity/Topic/public"]'
    topicSelector  = "#main-sidebar [testpath=\"public-feed-link/Activity/Topic/#{hashtag.replace '#', ''}\"]"
    recentSelector = "[testpath=\"ActivityTabHandle-/Activity/Public/Recent\"]"

    browser
      .click                     '[testpath=channel-title] .following'
      .waitForElementNotVisible  topicSelector, 25000
      .waitForElementVisible     publicSelector, 25000
      .click                     publicSelector
      .waitForElementVisible     recentSelector, 25000
      .refresh()
      .pause 2000  # an unfortunate fix for the wsod
      .refresh()
      .waitForElementVisible     publicSelector, 25000
      .assert.elementNotPresent  topicSelector
      .end()


  changeMostLikedMostRecentTab: (browser) ->

    user             = helpers.beginTest(browser)
    postSelector     = "#{activitySelector} .activity-content-wrapper"
    mostLikeSelector = '.kdtabhandlecontainer [testpath="ActivityTabHandle-/Activity/Public/Liked"]'
    mostLikedPostSelector = '.most-liked [testpath=ActivityListItemView]'

    post = helpers.likePost(browser, user)

    browser
      .refresh()
      .click                   '[testpath="public-feed-link/Activity/Topic/public"]'
      .waitForElementVisible   '[testpath=ActivityInputView]', 10000
      .waitForElementVisible   mostLikeSelector, 20000
      .click                   mostLikeSelector
      .waitForElementVisible   mostLikedPostSelector, 20000
      .assert.containsText     '.kdtabpaneview.most-liked', post # Assertion
      .end()


  switchBetweenChannels: (browser) ->

    helpers.beginTest(browser)

    firstHashtag  = helpers.doFollowTopic(browser)
    secondHashtag = helpers.doFollowTopic(browser)

    firstHashtag  = firstHashtag.replace '#', ''
    secondHashtag = secondHashtag.replace '#', ''

    channelTitle          = '[testpath=channel-title]'
    firstHashtagSelector  = ".followed.topics [testpath='public-feed-link/Activity/Topic/#{firstHashtag}']"
    secondHashtagSelector = ".followed.topics [testpath='public-feed-link/Activity/Topic/#{secondHashtag}']"

    browser
      .waitForElementVisible  firstHashtagSelector, 20000
      .click                  firstHashtagSelector
      .assert.containsText    channelTitle, firstHashtag # Assertion
      .waitForElementVisible  secondHashtagSelector,20000
      .click                  secondHashtagSelector
      .assert.containsText    channelTitle, secondHashtag # Assertion
      .end()

{'fraction_non_alphanumeric': 0.1096045197740113, 'fraction_numerical': 0.021263482280431432, 'mean_word_length': 2.8180392156862744, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3417352', 'n_tokens_mistral': 3043, 'n_tokens_neox': 2773, 'n_words': 476}