<commit_before>should = require 'should'
{wd40, browser, login_url, home_url, prepIntegration} = require './helper'

describe 'New dataset tool', ->
  prepIntegration()

  before (done) ->
    wd40.fill '#username', 'ehg', ->
      wd40.fill '#password', '<PASSWORD>', ->
        wd40.click '#login', done

  before (done) ->
    browser.waitForElementByCss '.dataset-list', 4000, done

  context 'when I click the "new dataset" button', ->
    iframeUrl = null
    before (done) ->
      wd40.click '.new-dataset', ->
        browser.waitForElementByCss '#chooser .tool', 4000, done

    context 'when I click on the newdataset tool', ->
      before (done) ->
        wd40.click '.newdataset.tool', =>
          browser.waitForElementByTagName 'iframe', 10000, =>
            browser.url (err, url) =>
              @currentUrl = url
              done err

      before (done) ->
        # wait for the tool menu toggle to load
        setTimeout done, 1000

      it 'takes me to the dataset settings page', ->
        @currentUrl.should.match new RegExp("#{home_url}/dataset/[^/]+/settings")

      it 'and shows that the "Code a dataset" tool is active', (done) ->
        wd40.elementByCss '#toolbar .active', (err, link) ->
          link.text (err, text) ->
            text.toLowerCase().should.include 'code a dataset'
            done()

      it 'and shows me the "Code in a dataset" tool contents', (done) ->
        wd40.switchToBottomFrame ->
          wd40.trueURL (err, url) ->
            iframeUrl = url
            done()

    context 'when I wait a little while and then go back to the dataset page', ->
      before (done) ->
        # wait for the data tables tool to be installed in the background
        setTimeout done, 5000

      before (done) ->
        browser.get @currentUrl.replace(/\/settings$/, ''), done

      it 'shows that the "View in a table" tool is active', (done) ->
        wd40.elementByCss '#toolbar .active', (err, link) ->
          link.text (err, text) ->
            text.toLowerCase().should.include 'view in a table'
            done()

      it 'and shows me the "View in a table" tool contents', (done) ->
        wd40.switchToBottomFrame ->
          wd40.trueURL (err, url) ->
            url.should.not.equal iframeUrl
            done()<commit_msg>fix test which was barfing on line breaks<commit_after>should = require 'should'
{wd40, browser, login_url, home_url, prepIntegration} = require './helper'

describe 'New dataset tool', ->
  prepIntegration()

  before (done) ->
    wd40.fill '#username', 'ehg', ->
      wd40.fill '#password', '<PASSWORD>', ->
        wd40.click '#login', done

  before (done) ->
    browser.waitForElementByCss '.dataset-list', 4000, done

  context 'when I click the "new dataset" button', ->
    iframeUrl = null
    before (done) ->
      wd40.click '.new-dataset', ->
        browser.waitForElementByCss '#chooser .tool', 4000, done

    context 'when I click on the newdataset tool', ->
      before (done) ->
        wd40.click '.newdataset.tool', =>
          browser.waitForElementByTagName 'iframe', 10000, =>
            browser.url (err, url) =>
              @currentUrl = url
              done err

      before (done) ->
        # wait for the tool menu toggle to load
        setTimeout done, 1000

      it 'takes me to the dataset settings page', ->
        @currentUrl.should.match new RegExp("#{home_url}/dataset/[^/]+/settings")

      it 'and shows that the "Code a dataset" tool is active', (done) ->
        wd40.elementByCss '#toolbar .active', (err, link) ->
          link.text (err, text) ->
            text.toLowerCase().replace('\n',' ').should.include 'code a dataset'
            done()

      it 'and shows me the "Code in a dataset" tool contents', (done) ->
        wd40.switchToBottomFrame ->
          wd40.trueURL (err, url) ->
            iframeUrl = url
            done()

    context 'when I wait a little while and then go back to the dataset page', ->
      before (done) ->
        # wait for the data tables tool to be installed in the background
        setTimeout done, 5000

      before (done) ->
        browser.get @currentUrl.replace(/\/settings$/, ''), done

      it 'shows that the "View in a table" tool is active', (done) ->
        wd40.elementByCss '#toolbar .active', (err, link) ->
          link.text (err, text) ->
            text.toLowerCase().replace('\n',' ').should.include 'view in a table'
            done()

      it 'and shows me the "View in a table" tool contents', (done) ->
        wd40.switchToBottomFrame ->
          wd40.trueURL (err, url) ->
            url.should.not.equal iframeUrl
            done()
{'fraction_non_alphanumeric': 0.13065755764304013, 'fraction_numerical': 0.019214346712211786, 'mean_word_length': 2.148521505376344, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 65, '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': '1866840', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1332, 'n_words': 454}