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

describe 'View', ->
  prepIntegration()

  randomname = "Prune graph number #{Math.random()}"

  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 on a Prune dataset then the graph of prunes view', ->
    before (done) ->
      browser.elementByPartialLinkText 'Prune', (err, link) ->
        link.click done

    before (done) ->
      wd40.click '#toolbar .tool[data-toolname="prune-graph"] .tool-icon', done

    it 'takes me to the Graph of Prunes page', (done) ->
      wd40.trueURL (err, result) ->
        result.should.match /\/view\/(\w+)/
        done()

    it 'there is a custom-named "Data Scientist\'s Report" tool', (done) ->
      wd40.getText '#dataset-tools', (err, text) ->
        text.replace(/\s+/g, ' ').toLowerCase().should.include "data scientist's report"
        done()

    context 'when I click the "hide" link on the "Code a prune" tool', ->
      before (done) ->
          browser.elementByCss '#toolbar .tool[data-toolname="prune-graph"]', (err, el) ->
            el.elementByCss '.dropdown-toggle', (err, optionsToggle) ->
              optionsToggle.click (err) ->
                 wd40.click '#tool-options-menu .hide-tool', done

      it "I'm redirected to the dataset's default tool", (done) ->
        wd40.waitForMatchingURL /dataset[/]\w+([/]settings)?[/]?$/, done

      it 'And the "Code a prune" tool is no longer visible', (done) ->
        browser.elementByCss '#toolbar .tool[data-toolname="prune-graph"]', (err, el) -><commit_msg>more resilient view.coffee test<commit_after>should = require 'should'
{wd40, browser, base_url, login_url, home_url, prepIntegration} = require './helper'

describe 'View', ->
  prepIntegration()

  randomname = "Prune graph number #{Math.random()}"

  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 on a Prune dataset then the graph of prunes view', ->
    before (done) ->
      wd40.elementByPartialLinkText 'Prune', (err, link) ->
        link.click done

    before (done) ->
      wd40.waitForVisibleByCss '#toolbar .tool[data-toolname="prune-graph"] .tool-icon', ->
        wd40.click '#toolbar .tool[data-toolname="prune-graph"] .tool-icon', done

    it 'takes me to the Graph of Prunes page', (done) ->
      wd40.waitForMatchingURL /\/view\/(\w+)/, (err, url) ->
        done()

    it 'there is a custom-named "Data Scientist\'s Report" tool', (done) ->
      wd40.getText '#dataset-tools', (err, text) ->
        text.replace(/\s+/g, ' ').toLowerCase().should.include "data scientist's report"
        done()

    context 'when I click the "hide" link on the "Code a prune" tool', ->
      before (done) ->
          wd40.elementByCss '#toolbar .tool[data-toolname="prune-graph"]', (err, el) ->
            el.elementByCss '.dropdown-toggle', (err, optionsToggle) ->
              optionsToggle.click (err) ->
                 wd40.click '#tool-options-menu .hide-tool', done

      it "I'm redirected to the dataset's default tool", (done) ->
        wd40.waitForMatchingURL /dataset[/]\w+([/]settings)?[/]?$/, done

      it 'And the "Code a prune" tool is no longer visible', (done) ->
        # we use browser, and not wd40, here because wd40
        # would timeout waiting for the element to appear
        browser.elementByCss '#toolbar .tool[data-toolname="prune-graph"]', (err, el) ->
{'fraction_non_alphanumeric': 0.16152832674571804, 'fraction_numerical': 0.014229249011857707, 'mean_word_length': 2.754698318496538, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '2858437', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1182, 'n_words': 343}