<commit_before>feature 'List orders', js: true do
  let!(:user)                   { FactoryBot.create(:user) }
  let!(:john)                   { FactoryBot.create(:user, :john) }
  let!(:vacation_request_type)  { FactoryBot.create(:order_type, :vacation_request, name: 'Vacation request') }
  let!(:support_request_type)   { FactoryBot.create(:order_type, :support_request, name: 'Support request') }
  let!(:vacation_request_order) { FactoryBot.create(:order, :order_vacation_request) }
  let!(:support_request_order)  { FactoryBot.create(:order, :order_support_request, order_type: support_request_type) }
  let!(:problem_descriptions)   { 'Problem description' }
  let!(:contract_number)        { 111 }

  before(:each) do
    signin(user.email, user.password)

    click_on 'Orders'
    expect(page).to have_content 'Orders list'
    expect_widget_presence
  end

  scenario 'with correct filter defaults' do
    # "Orders list" tab is active by default
    expect(active_tab('Orders list')).not_to be_nil

    # "Order type" select
    expect(label('order_type_id')).to                eq('Order type')
    expect(placeholder('order_type_id')).to          eq('Order type')
    expect(select2_default_text('order_type_id')).to eq('Order type')
    expect(select_options('order_type_id')).to       eq(['Empty order type',
                                                         'Support request',
                                                         'Vacation request'])

    # "Order status" select
    expect(label('state')).to                eq('Order status')
    expect(placeholder('state')).to          eq('Order status')
    expect(select2_default_text('state')).to eq('Order status')
    expect(select_options('state')).to       eq(['New',
                                                 'In progress',
                                                 'Completed'])

    # "Archived" select
    expect(label('archived')).to          eq('Archived')
    expect(placeholder('archived')).to    eq('Archived')
    expect(select2_text('archived')).to   eq("\nNo")
    expect(select_options('archived')).to eq(%w(Yes No))

    # "User" multiple select
    expect(label('user_id')).to                   eq('User')
    expect(placeholder('user_id[]')).to           eq('User')
    expect(select2_multiple_text('user_id[]')).to eq([user.full_name, 'Empty'])
    expect(select_options('user_id[]')).to        eq([user.full_name, 'Empty'])
    # enter 2 symbols in lookup and find users
    expect(success_select_search('user_id[]', 'Jo')).to eq([john.full_name, user.full_name])

    # Calendar "from"
    expect(label('created_at_from')).to          eq('from')
    expect(calendar_value('created_at_from')).to eq(in_current_locale((DateTime.now - 1.day).beginning_of_day))

    # Calendar "to"
    expect(label('created_at_to')).to          eq('to')
    expect(calendar_value('created_at_to')).to eq(in_current_locale(DateTime.now.end_of_day))<commit_msg>Use application timezone in test (#579)<commit_after>feature 'List orders', js: true do
  let!(:user)                   { FactoryBot.create(:user) }
  let!(:john)                   { FactoryBot.create(:user, :john) }
  let!(:vacation_request_type)  { FactoryBot.create(:order_type, :vacation_request, name: 'Vacation request') }
  let!(:support_request_type)   { FactoryBot.create(:order_type, :support_request, name: 'Support request') }
  let!(:vacation_request_order) { FactoryBot.create(:order, :order_vacation_request) }
  let!(:support_request_order)  { FactoryBot.create(:order, :order_support_request, order_type: support_request_type) }
  let!(:problem_descriptions)   { 'Problem description' }
  let!(:contract_number)        { 111 }

  before(:each) do
    signin(user.email, user.password)

    click_on 'Orders'
    expect(page).to have_content 'Orders list'
    expect_widget_presence
  end

  scenario 'with correct filter defaults' do
    # "Orders list" tab is active by default
    expect(active_tab('Orders list')).not_to be_nil

    # "Order type" select
    expect(label('order_type_id')).to                eq('Order type')
    expect(placeholder('order_type_id')).to          eq('Order type')
    expect(select2_default_text('order_type_id')).to eq('Order type')
    expect(select_options('order_type_id')).to       eq(['Empty order type',
                                                         'Support request',
                                                         'Vacation request'])

    # "Order status" select
    expect(label('state')).to                eq('Order status')
    expect(placeholder('state')).to          eq('Order status')
    expect(select2_default_text('state')).to eq('Order status')
    expect(select_options('state')).to       eq(['New',
                                                 'In progress',
                                                 'Completed'])

    # "Archived" select
    expect(label('archived')).to          eq('Archived')
    expect(placeholder('archived')).to    eq('Archived')
    expect(select2_text('archived')).to   eq("\nNo")
    expect(select_options('archived')).to eq(%w(Yes No))

    # "User" multiple select
    expect(label('user_id')).to                   eq('User')
    expect(placeholder('user_id[]')).to           eq('User')
    expect(select2_multiple_text('user_id[]')).to eq([user.full_name, 'Empty'])
    expect(select_options('user_id[]')).to        eq([user.full_name, 'Empty'])
    # enter 2 symbols in lookup and find users
    expect(success_select_search('user_id[]', 'Jo')).to eq([john.full_name, user.full_name])

    # Calendar "from"
    expect(label('created_at_from')).to          eq('from')
    expect(calendar_value('created_at_from')).to eq(in_current_locale((Time.current - 1.day).beginning_of_day))

    # Calendar "to"
    expect(label('created_at_to')).to          eq('to')
    expect(calendar_value('created_at_to')).to eq(in_current_locale(Time.current.end_of_day))
{'fraction_non_alphanumeric': 0.1437941473259334, 'fraction_numerical': 0.0035317860746720484, 'mean_word_length': 2.841731266149871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4250798', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1738, 'n_words': 304}