<commit_before>helpers = require '../helpers/helpers.js'
assert  = require 'assert'

activitySelector = '[testpath=activity-list] section:nth-of-type(1) [testpath=ActivityListItemView]:first-child'

module.exports =


  postMessageWithCode: (browser) ->

    helpers.beginTest(browser)

    timestamp = Date.now()
    code      = "console.log('#{timestamp}')"
    post      = '```' + code + '```'
    selector  = '[testpath=ActivityListItemView]:first-child .has-markdown code'

    helpers.doPostActivity(browser, post, no)

    browser
      .assert.containsText selector, code # Assertion
      .end()


  postMessageWithImage: (browser) ->

    helpers.beginTest(browser)

    # added 'hello world' bc it first thinks that you type http://placehold.it/
    # and renders it as a link, but if we continue typing it understands that
    # it is an image
    image = 'http://placehold.it/200x100 hello world!'
    selector = activitySelector + ' .activity-content-wrapper .embed-image-view img'

    browser
      .click                  '[testpath="public-feed-link/Activity/Topic/public"]'
      .waitForElementVisible  '[testpath=ActivityInputView]', 25000
      .click                  '[testpath="ActivityTabHandle-/Activity/Public/Recent"]'
      .click                  '[testpath=ActivityInputView]'
      .setValue               '[testpath=ActivityInputView]', image
      .pause                  5000
      .click                  '[testpath=post-activity-button]'
      .waitForElementVisible   selector, 20000 # Assertion
      .end()


  postMessageWithLink: (browser) ->

    helpers.beginTest(browser)

    link = 'http://wikipedia.org/'
    linkSelector = activitySelector + ' .activity-content-wrapper article a'

    helpers.doPostActivity(browser, link, yes, yes)

    browser.getAttribute linkSelector, 'href', (result) ->
      href = result.value
      assert.equal(link, href)

    browser.end()


  postCommentWithCode: (browser) ->

    helpers.beginTest(browser)

    post      = helpers.getFakeText()
    timestamp = Date.now()
    code      = "console.log(#{timestamp})"
    comment   = '```' + code + '```'
    selector  = '[testpath=ActivityListItemView]:first-child .comment-contents .has-markdown code'

    helpers.doPostActivity(browser, post)
    helpers.doPostComment(browser, comment, no)

    browser
      .pause 2000
      .assert.containsText selector, code # Assertion
      .end()


  postCommentWithImage: (browser) ->

    helpers.beginTest(browser)

    post     = helpers.getFakeText()
    image    = 'http://placehold.it/200x100'
    selector = activitySelector + ' .comment-contents .link-embed-box a.embed-image-view'

    helpers.doPostActivity(browser, post)
    helpers.doPostComment(browser, image) # images do not show a preview so we don't pass embeddable flag

    browser.getAttribute selector, 'href', (result) ->
      href = result.value
      assert.equal(image, href)


  postCommentWithLink: (browser) ->

    helpers.beginTest(browser)

    post     = helpers.getFakeText()
    link = 'http://wikipedia.org/'
    linkSelector = activitySelector + ' .comment-contents .comment-body-container .has-markdown a'

    helpers.doPostActivity(browser, post)
    helpers.doPostComment(browser, link, yes, yes)

    browser.getAttribute linkSelector, 'href', (result) ->
      href = result.value
      assert.equal(link, href)

    browser.end()<commit_msg>tests: fixed missing browser.end() and async browser.end()s<commit_after>helpers = require '../helpers/helpers.js'
assert  = require 'assert'

activitySelector = '[testpath=activity-list] section:nth-of-type(1) [testpath=ActivityListItemView]:first-child'

module.exports =


  postMessageWithCode: (browser) ->

    helpers.beginTest(browser)

    timestamp = Date.now()
    code      = "console.log('#{timestamp}')"
    post      = '```' + code + '```'
    selector  = '[testpath=ActivityListItemView]:first-child .has-markdown code'

    helpers.doPostActivity(browser, post, no)

    browser
      .assert.containsText selector, code # Assertion
      .end()


  postMessageWithImage: (browser) ->

    helpers.beginTest(browser)

    # added 'hello world' bc it first thinks that you type http://placehold.it/
    # and renders it as a link, but if we continue typing it understands that
    # it is an image
    image    = 'http://placehold.it/200x100 hello world!'
    selector = activitySelector + ' .activity-content-wrapper .embed-image-view img'

    browser
      .click                  '[testpath="public-feed-link/Activity/Topic/public"]'
      .waitForElementVisible  '[testpath=ActivityInputView]', 25000
      .click                  '[testpath="ActivityTabHandle-/Activity/Public/Recent"]'
      .click                  '[testpath=ActivityInputView]'
      .setValue               '[testpath=ActivityInputView]', image
      .pause                  5000
      .click                  '[testpath=post-activity-button]'
      .waitForElementVisible   selector, 20000 # Assertion
      .end()


  postMessageWithLink: (browser) ->

    helpers.beginTest(browser)

    link         = 'http://wikipedia.org/'
    linkSelector = activitySelector + ' .activity-content-wrapper article a'

    helpers.doPostActivity(browser, link, yes, yes)

    browser.getAttribute linkSelector, 'href', (result) ->
      href = result.value
      assert.equal(link, href)

      browser.end()


  postCommentWithCode: (browser) ->

    helpers.beginTest(browser)

    post      = helpers.getFakeText()
    timestamp = Date.now()
    code      = "console.log(#{timestamp})"
    comment   = '```' + code + '```'
    selector  = '[testpath=ActivityListItemView]:first-child .comment-contents .has-markdown code'

    helpers.doPostActivity(browser, post)
    helpers.doPostComment(browser, comment, no)

    browser
      .pause 2000
      .assert.containsText selector, code # Assertion
      .end()


  postCommentWithImage: (browser) ->

    helpers.beginTest(browser)

    post     = helpers.getFakeText()
    image    = 'http://placehold.it/200x100'
    selector = activitySelector + ' .comment-contents .link-embed-box a.embed-image-view'

    helpers.doPostActivity(browser, post)
    helpers.doPostComment(browser, image) # images do not show a preview so we don't pass embeddable flag

    browser.getAttribute selector, 'href', (result) ->
      href = result.value
      assert.equal(image, href)

      browser.end()


  postCommentWithLink: (browser) ->

    helpers.beginTest(browser)

    post         = helpers.getFakeText()
    link         = 'http://wikipedia.org/'
    linkSelector = activitySelector + ' .comment-contents .comment-body-container .has-markdown a'

    helpers.doPostActivity(browser, post)
    helpers.doPostComment(browser, link, yes, yes)

    browser.getAttribute linkSelector, 'href', (result) ->
      href = result.value
      assert.equal(link, href)

      browser.end()
{'fraction_non_alphanumeric': 0.12247255921432698, 'fraction_numerical': 0.008954361640670132, 'mean_word_length': 2.8196359624931056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1668167', 'n_tokens_mistral': 2119, 'n_tokens_neox': 1987, 'n_words': 430}