<commit_before>utils                = require '../utils/utils.js'
helpers              = require '../helpers/helpers.js'
ideHelpers           = require '../helpers/idehelpers.js'
collaborationHelpers = require '../helpers/collaborationhelpers.js'
terminalHelpers      = require '../helpers/terminalhelpers.js'
assert               = require 'assert'


module.exports =


  before: (browser) ->

    hostBrowser = process.env.__NIGHTWATCH_ENV_KEY is 'host_1'

    if hostBrowser
      utils.getUser()


  inviteUserAndRejectInvitation: (browser) ->

    host                   = utils.getUser no, 0
    hostBrowser            = process.env.__NIGHTWATCH_ENV_KEY is 'host_1'
    participant            = utils.getUser no, 1
    secondUserName         = participant.username
    secondUserAvatar       = ".avatars .avatarview[href='/#{secondUserName}']"
    secondUserOnlineAvatar = secondUserAvatar + '.online'

    browser.pause 2500, -> # wait for user.json creation
      if hostBrowser
        collaborationHelpers.startSessionAndInviteUser(browser, host, participant, no)
        browser
          .waitForElementNotPresent secondUserAvatar, 60000
          .waitForElementNotPresent secondUserOnlineAvatar, 50000 # Assertion

        collaborationHelpers.endSessionFromStatusBar(browser)
      else
        collaborationHelpers.rejectInvitation(browser)

      browser.end()


  leaveSessionFromChat: (browser) ->

    host        = utils.getUser no, 0
    hostBrowser = process.env.__NIGHTWATCH_ENV_KEY is 'host_1'
    participant = utils.getUser no, 1
    chatBox     = '.chat-view'
    chatHeads   = "#{chatBox} .chat-heads .ParticipantHeads [href='/#{participant.username}']"

    if hostBrowser
      collaborationHelpers.startSessionAndInviteUser(browser, host, participant)
      browser.waitForElementNotPresent chatHeads, 50000
      collaborationHelpers.waitParticipantLeaveAndEndSession(browser)
      browser.end()
    else
      collaborationHelpers.joinSession(browser, host, participant)
      collaborationHelpers.closeChatPage(browser)
      collaborationHelpers.leaveSessionFromChat(browser)
      browser.end()


  leaveSessionFromSidebar: (browser) ->

    host        = utils.getUser no, 0
    hostBrowser = process.env.__NIGHTWATCH_ENV_KEY is 'host_1'
    participant = utils.getUser no, 1
    chatBox     = '.chat-view'
    chatHeads   = "#{chatBox} .chat-heads .ParticipantHeads [href='/#{participant.username}']"

    if hostBrowser
      collaborationHelpers.startSessionAndInviteUser(browser, host, participant)
      browser.waitForElementNotPresent chatHeads, 50000
      collaborationHelpers.waitParticipantLeaveAndEndSession(browser)
      browser.end()
    else
      collaborationHelpers.joinSession(browser, host, participant)
      collaborationHelpers.closeChatPage(browser)
      collaborationHelpers.leaveSessionFromSidebar(browser)
      browser.end()
<commit_msg>Test case: Reject collaboration invitation<commit_after>utils                = require '../utils/utils.js'
helpers              = require '../helpers/helpers.js'
ideHelpers           = require '../helpers/idehelpers.js'
collaborationHelpers = require '../helpers/collaborationhelpers.js'
terminalHelpers      = require '../helpers/terminalhelpers.js'
assert               = require 'assert'


module.exports =


  before: (browser) ->

    hostBrowser = process.env.__NIGHTWATCH_ENV_KEY is 'host_1'

    if hostBrowser
      utils.getUser()


  rejectInvitation: (browser) ->

    host            = utils.getUser no, 0
    hostBrowser     = process.env.__NIGHTWATCH_ENV_KEY is 'host_1'
    participant     = utils.getUser no, 1
    secondUserName  = participant.username
    chatHeads       = ".chat-view .chat-heads .ParticipantHeads [href='/#{participant.username}']"

    browser.pause 2500, -> # wait for user.json creation
      if hostBrowser
        collaborationHelpers.startSessionAndInviteUser(browser, host, participant, no)
        browser.waitForElementNotPresent(chatHeads, 60000)
        collaborationHelpers.endSessionFromStatusBar(browser)
        browser.end()
      else
        collaborationHelpers.rejectInvitation(browser)
        browser.pause 5000
        browser.end()


  leaveSessionFromChat: (browser) ->

    host        = utils.getUser no, 0
    hostBrowser = process.env.__NIGHTWATCH_ENV_KEY is 'host_1'
    participant = utils.getUser no, 1
    chatBox     = '.chat-view'
    chatHeads   = "#{chatBox} .chat-heads .ParticipantHeads [href='/#{participant.username}']"

    if hostBrowser
      collaborationHelpers.startSessionAndInviteUser(browser, host, participant)
      browser.waitForElementNotPresent chatHeads, 50000
      collaborationHelpers.waitParticipantLeaveAndEndSession(browser)
      browser.end()
    else
      collaborationHelpers.joinSession(browser, host, participant)
      collaborationHelpers.closeChatPage(browser)
      collaborationHelpers.leaveSessionFromChat(browser)
      browser.end()


  leaveSessionFromSidebar: (browser) ->

    host        = utils.getUser no, 0
    hostBrowser = process.env.__NIGHTWATCH_ENV_KEY is 'host_1'
    participant = utils.getUser no, 1
    chatBox     = '.chat-view'
    chatHeads   = "#{chatBox} .chat-heads .ParticipantHeads [href='/#{participant.username}']"

    if hostBrowser
      collaborationHelpers.startSessionAndInviteUser(browser, host, participant)
      browser.waitForElementNotPresent chatHeads, 50000
      collaborationHelpers.waitParticipantLeaveAndEndSession(browser)
      browser.end()
    else
      collaborationHelpers.joinSession(browser, host, participant)
      collaborationHelpers.closeChatPage(browser)
      collaborationHelpers.leaveSessionFromSidebar(browser)
      browser.end()

{'fraction_non_alphanumeric': 0.09079776067179846, 'fraction_numerical': 0.01172148355493352, 'mean_word_length': 3.185212298682284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6268969', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1649, 'n_words': 300}