<commit_before>require_relative 'spec_helper'
require 'json'

describe 'Trend Crawl' do
  include PageObject::PageFactory

  before do
    unless @browser
      @headless = Headless.new
      @browser = Watir::Browser.new
    end
    @browser.goto 'localhost:9292'
  end

  describe 'Go to home page' do
    it 'finds title & header & three tabs & keywords area' do
      visit HomePage do |page|
        page.title.must_equal 'Explore with FirstGlance'
        page.execute_script("return (typeof arguments[0].naturalWidth!=\"undefined\" && arguments[0].naturalWidth>0)", page.header_img_element)
        page.trend_link_element.exists?.must_equal true
        page.article_link_element.exists?.must_equal true
        page.about_link_element.exists?.must_equal true
        page.keywords_header.must_equal 'Keywords'
        page.keywords_div_element.exists?.must_equal true
      end
    end
  end

  describe 'Go to trend_bs page' do
    it 'show dashboard' do
      @browser.link(text: 'Trend').click

      @browser.div(id: 'plot').present?.must_equal true
    end
  end

  describe 'Go to article_bs page' do
    it 'show article' do
      @browser.link(text: 'Article').click

      @browser.h4.text.must_equal 'Contents'
    end
  end
end
<commit_msg>refactor trend and article page<commit_after>require_relative 'spec_helper'
require 'json'

describe 'Trend Crawl' do
  include PageObject::PageFactory

  before do
    unless @browser
      @headless = Headless.new
      @browser = Watir::Browser.new
    end
    @browser.goto 'localhost:9292'
  end

  describe 'Go to home page' do
    it 'finds title & header & three tabs & keywords area' do
      visit HomePage do |page|
        page.title.must_equal 'Explore with FirstGlance'
        page.execute_script("return (typeof arguments[0].naturalWidth!=\"undefined\" && arguments[0].naturalWidth>0)", page.header_img_element)
        page.trend_link_element.exists?.must_equal true
        page.article_link_element.exists?.must_equal true
        page.about_link_element.exists?.must_equal true
        page.keywords_header.must_equal 'Keywords'
        page.keywords_div_element.exists?.must_equal true
      end
    end
  end

  describe 'Go to trend_bs page' do
    it 'show plot' do
      visit TrendPage do |page|
        page.click_trend_tab

        page.plot_element.present?.must_equal true
      end
    end
  end

  describe 'Go to article_bs page' do
    it 'show article' do
      visit ArticlePage do |page|
        page.click_article_tab

        page.header_temp.must_equal 'Contents'
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08719135802469136, 'fraction_numerical': 0.005787037037037037, 'mean_word_length': 3.007727975270479, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1306408', 'n_tokens_mistral': 813, 'n_tokens_neox': 784, 'n_words': 205}