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

modalSelector = '.machine-settings-modal.AppModal'

module.exports =


  openVmSettingsModal: (browser, vmName, cssSelector) ->

    if not vmName
      vmName = 'koding-vm-0'

    if not cssSelector
      cssSelector = '.general'

    modalSelector = '.machine-settings-modal.AppModal'
    itemSelector  = modalSelector + ' .AppModal-navItem' + cssSelector
    vmSelector    = ".activity-sidebar .sidebar-machine-box.#{vmName} .running"

    browser
      .pause                   5000 # wait for sidebar redraw
      .waitForElementVisible   vmSelector, 20000
      .moveToElement           vmSelector + ' span', 125, 20
      .click                   vmSelector + ' span'
      .waitForElementVisible   modalSelector, 20000 # Assertion
      .pause                   2500
      .waitForElementVisible   itemSelector, 20000
      .click                   itemSelector


  openDiskUsageSettings: (browser, vmName) ->

    @openVmSettingsModal browser, vmName, '.disk-usage'


  openSpecsSettings: (browser, vmName) ->

    @openVmSettingsModal browser, vmName, '.specs'


  openGeneralSettings: (browser,vmName) ->

    @openVmSettingsModal browser, vmName


  openDomainSettings: (browser, vmName) ->

    @openVmSettingsModal browser, vmName, '.domains'

  openAdvancedSettings: (browser, vmName) ->

    @openVmSettingsModal browser, vmName, '.advanced'

  openSnapshotsSettings: (browser,vmName) ->

    @openVmSettingsModal browser, vmName, '.snapshots'

  attemptCreateSnapshot: (browser) ->

    buttonSelector   = '.snapshots .add-button'

    @openSnapshotsSettings(browser)

    browser
      .waitForElementVisible buttonSelector, 20000
      .click                 buttonSelector

  nameSnapshot: (browser) ->
    name            = helpers.getFakeText().split(' ')[0]
    inputSelector   = '.snapshots .text.hitenterview'

    browser
      .waitForElementVisible inputSelector, 20000
      .click                 inputSelector
      .setValue              inputSelector, [name, browser.Keys.RETURN]

    return name


  createSnapshot: (browser) ->

    upgradeSelector = '.kdmodal.computeplan-modal .custom-link-view'

    @attemptCreateSnapshot(browser)

    browser.pause 2000 #Wait for the modal for upgrading to be displayed or not

    browser.isVisible upgradeSelector, (result) ->

      if result.value<commit_msg>Fixed snapshot modal wait time<commit_after>helpers = require './helpers.js'
assert  = require 'assert'

modalSelector = '.machine-settings-modal.AppModal'

module.exports =


  openVmSettingsModal: (browser, vmName, cssSelector) ->

    if not vmName
      vmName = 'koding-vm-0'

    if not cssSelector
      cssSelector = '.general'

    modalSelector = '.machine-settings-modal.AppModal'
    itemSelector  = modalSelector + ' .AppModal-navItem' + cssSelector
    vmSelector    = ".activity-sidebar .sidebar-machine-box.#{vmName} .running"

    browser
      .pause                   5000 # wait for sidebar redraw
      .waitForElementVisible   vmSelector, 20000
      .moveToElement           vmSelector + ' span', 125, 20
      .click                   vmSelector + ' span'
      .waitForElementVisible   modalSelector, 20000 # Assertion
      .pause                   2500
      .waitForElementVisible   itemSelector, 20000
      .click                   itemSelector


  openDiskUsageSettings: (browser, vmName) ->

    @openVmSettingsModal browser, vmName, '.disk-usage'


  openSpecsSettings: (browser, vmName) ->

    @openVmSettingsModal browser, vmName, '.specs'


  openGeneralSettings: (browser,vmName) ->

    @openVmSettingsModal browser, vmName


  openDomainSettings: (browser, vmName) ->

    @openVmSettingsModal browser, vmName, '.domains'

  openAdvancedSettings: (browser, vmName) ->

    @openVmSettingsModal browser, vmName, '.advanced'

  openSnapshotsSettings: (browser,vmName) ->

    @openVmSettingsModal browser, vmName, '.snapshots'

  attemptCreateSnapshot: (browser) ->

    buttonSelector   = '.snapshots .add-button'

    @openSnapshotsSettings(browser)

    browser
      .waitForElementVisible buttonSelector, 20000
      .click                 buttonSelector

  nameSnapshot: (browser) ->
    name            = helpers.getFakeText().split(' ')[0]
    inputSelector   = '.snapshots .text.hitenterview'

    browser
      .waitForElementVisible inputSelector, 20000
      .click                 inputSelector
      .setValue              inputSelector, [name, browser.Keys.RETURN]

    return name


  createSnapshot: (browser) ->

    upgradeSelector = '.kdmodal.computeplan-modal .custom-link-view'

    @attemptCreateSnapshot(browser)

    browser.pause 6000 #Wait for the modal for upgrading to be displayed or not

    browser.isVisible upgradeSelector, (result) ->

      if result.value
{'fraction_non_alphanumeric': 0.09456948172620276, 'fraction_numerical': 0.018170555440842454, 'mean_word_length': 2.6503391107761867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '5893796', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1313, 'n_words': 317}