<commit_before>require 'selenium_test_helper'

class ZookaTest < Kracker::SeleniumTestCase

  def setup
    @filename_1 = Kracker::current_filename('zooka_1').gsub('yaml', 'png')
    @filename_2 = Kracker::current_filename('zooka_2').gsub('yaml', 'png')

    FileUtils.rm_rf @filename_1
    FileUtils.rm_rf @filename_2
    super
  end

  def teardown
    FileUtils.rm_rf @filename_1
    FileUtils.rm_rf @filename_2
    super
  end

  def test_zooka__pass
    index_page = visit_index

    index_page.navigation.config!

    page.driver.save_screenshot(@filename_1)
    page.driver.save_screenshot(@filename_2)

    image_1 = ChunkyPNG::Image.from_file(@filename_1)
    image_2 = ChunkyPNG::Image.from_file(@filename_2)

    analyzer = Kracker::Zooka::Analyzer.new({:image_1 => image_1, :image_2 => image_2})
    analyzer.analyze
    not_compliant = analyzer.noncompliant_pixels

    expected = 0

    assert analyzer.same?, 'images should be found to be the same'
    assert_equal expected, not_compliant.count
  end

  def test_zooka__fail
    index_page = visit_index

    index_page.navigation.config!

    page.driver.save_screenshot(@filename_1)

    add_centered_element('the zooka will rock you!')
    page.driver.save_screenshot(@filename_2)

    image_1 = ChunkyPNG::Image.from_file(@filename_1)
    image_2 = ChunkyPNG::Image.from_file(@filename_2)

    analyzer = Kracker::Zooka::Analyzer.new({:image_1 => image_1, :image_2 => image_2})
    analyzer.analyze
    not_compliant = analyzer.noncompliant_pixels

    expected = ENV['TRAVIS'] ? 30400 : 26400

    refute analyzer.same?, 'images should be found to be different'
    assert_equal expected, not_compliant.count
  end

end<commit_msg>had to adjust the same expectation value for travis runs.<commit_after>require 'selenium_test_helper'

class ZookaTest < Kracker::SeleniumTestCase

  def setup
    @filename_1 = Kracker::current_filename('zooka_1').gsub('yaml', 'png')
    @filename_2 = Kracker::current_filename('zooka_2').gsub('yaml', 'png')

    FileUtils.rm_rf @filename_1
    FileUtils.rm_rf @filename_2
    super
  end

  def teardown
    FileUtils.rm_rf @filename_1
    FileUtils.rm_rf @filename_2
    super
  end

  def test_zooka__pass
    index_page = visit_index

    index_page.navigation.config!

    page.driver.save_screenshot(@filename_1)
    page.driver.save_screenshot(@filename_2)

    image_1 = ChunkyPNG::Image.from_file(@filename_1)
    image_2 = ChunkyPNG::Image.from_file(@filename_2)

    analyzer = Kracker::Zooka::Analyzer.new({:image_1 => image_1, :image_2 => image_2})
    analyzer.analyze
    not_compliant = analyzer.noncompliant_pixels

    expected = 0

    assert analyzer.same?, 'images should be found to be the same'
    assert_equal expected, not_compliant.count
  end

  def test_zooka__fail
    index_page = visit_index

    index_page.navigation.config!

    page.driver.save_screenshot(@filename_1)

    add_centered_element('the zooka will rock you!')
    page.driver.save_screenshot(@filename_2)

    image_1 = ChunkyPNG::Image.from_file(@filename_1)
    image_2 = ChunkyPNG::Image.from_file(@filename_2)

    analyzer = Kracker::Zooka::Analyzer.new({:image_1 => image_1, :image_2 => image_2})
    analyzer.analyze
    not_compliant = analyzer.noncompliant_pixels

    expected = ENV['TRAVIS'] ? 27200 : 26400

    refute analyzer.same?, 'images should be found to be different'
    assert_equal expected, not_compliant.count
  end

end
{'fraction_non_alphanumeric': 0.09947795823665893, 'fraction_numerical': 0.02262180974477958, 'mean_word_length': 4.2336874051593325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '4010958', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1190, 'n_words': 216}