<commit_before>require_relative "../../test_helper"
require_relative "flow_test_helper"

class AmIGettingMinimumWageTest < ActiveSupport::TestCase
  include FlowTestHelper

  setup do
    setup_for_testing_flow "am-i-getting-minimum-wage"
  end
  
  # Q1
  should "ask 'what would you like to check?'" do
    assert_current_node :what_would_you_like_to_check?
  end
  
  context "when checking current pay" do
    setup do
      add_response :current_payment
    end
    
    # Q2
    should "ask 'are you an apprentice?'" do
      assert_current_node :are_you_an_apprentice?
    end
    
    context "answered 'no' to 'are you an apprentice?'" do
      # Q3
      should "ask 'how old are you?'" do
        add_response :no
        assert_current_node :how_old_are_you?
      end
    end
    
    context "answered 'apprentice under 19' to 'are you an apprentice?'" do
      # Q4
      should "ask 'how often do you get paid?'" do
        add_response :apprentice_under_19
        assert_current_node :pay_frequency?
      end
    end
    
    context "answered 'apprentice over 19' to 'are you an apprentice?'" do
      setup do
        add_response :apprentice_over_19
      end
    
      # Q4
      should "ask 'how often do you get paid?'" do
        assert_current_node :pay_frequency?
      end
      
      context "answered weekly to 'how often do you get paid?'" do
        setup do
          add_response "7"
        end
        
        # Q5
        should "ask 'how many hours do you work?'" do
          assert_current_node :hours_worked_during_the_pay_period?
        end
        
        context "answered 'how many hours do you work?'" do
          setup do
            add_response "42"
          end
          
          # Q6
          should "ask 'how much do you get paid?'" do
            assert_current_node :quantity_paid_during_pay_period?
          end
          
          context "answered 158.39 to 'how much do you get paid?'" do
            setup do
              @initial_total_basic_pay = 158.39
              add_response @initial_total_basic_pay
            end

            should "calculate basic pay hourly rate" do
              assert_state_variable("basic_hourly_rate", 3.77)
            end
            
            # Q7
            should "ask 'how many hours overtime?'" do
              assert_current_node :hours_overtime_during_pay_period?
            end
            
            context "answer '8 hours' to 'how many hours overtime?'" do
              setup do
                add_response 8
              end
              
              # Q8
              should "ask 'what rate of overtime per hour?'" do
                assert_current_node :overtime_pay_per_hour?
              end
              
              context "answer 4.59 to 'overtime per hour?'" do
                setup do
                  add_response 4.59
                end
                
                should "calculate the total overtime pay" do
                  assert_state_variable("total_overtime_pay", 36.72)
                end
                
                should "add the total overtime pay to the total basic pay" do
                  assert_state_variable("total_basic_pay", 195.11)
                end
              end
              
              context "answer 3.71 to 'overtime per hour?'" do
                setup do
                  add_response 3.71
                end
                should "calculate the overtime pay using the lesser value from basic and overtime rates." do
                  assert_state_variable("total_overtime_pay", 30.16)
                end
              end
              
            end
            
            context "answer 'no overtime' to 'how many hours overtime?'" do
              setup do
                add_response 0
              end
              
              # Q9
              should "ask 'are you provided with accommodation?'" do
                assert_current_node :provided_with_accommodation?
              end
            
              context "answer 'no' to 'are you provided with accommodation?'" do
                setup do
                  add_response :no
                end
                
                should "make no adjustment for accommodation" do
                  assert_state_variable("total_basic_pay", @initial_total_basic_pay.to_s)
                end
                
                should "show the results" do
                  assert_current_node :results
                end
              end
              
              context "answer 'yes charged accommodation' to 'are you provided with accommodation?'" do
                setup do
                  add_response :yes_charged
                end
                
                # Q10
                should "ask 'how much do you pay for the accommodation?'" do
                  assert_current_node :accommodation_charge?
                end
                
                context "answer 7.35 to 'how much do you pay for accommodation?'" do
                  setup do
                    add_response 7.35
                  end
                  
                  should "ask 'how often do you use the accommodation?'" do
                    assert_current_node :accommodation_usage?
                  end
                  
                  context "answer 4 to 'how often do you use the accommodation?'" do<commit_msg>Accommodation adjustments added<commit_after>require_relative "../../test_helper"
require_relative "flow_test_helper"

class AmIGettingMinimumWageTest < ActiveSupport::TestCase
  include FlowTestHelper

  setup do
    setup_for_testing_flow "am-i-getting-minimum-wage"
  end
  
  # Q1
  should "ask 'what would you like to check?'" do
    assert_current_node :what_would_you_like_to_check?
  end
  
  context "when checking current pay" do
    setup do
      add_response :current_payment
    end
    
    # Q2
    should "ask 'are you an apprentice?'" do
      assert_current_node :are_you_an_apprentice?
    end
    
    context "answered 'no' to 'are you an apprentice?'" do
      # Q3
      should "ask 'how old are you?'" do
        add_response :no
        assert_current_node :how_old_are_you?
      end
    end
    
    context "answered 'apprentice under 19' to 'are you an apprentice?'" do
      # Q4
      should "ask 'how often do you get paid?'" do
        add_response :apprentice_under_19
        assert_current_node :pay_frequency?
      end
    end
    
    context "answered 'apprentice over 19' to 'are you an apprentice?'" do
      setup do
        add_response :apprentice_over_19
      end
    
      # Q4
      should "ask 'how often do you get paid?'" do
        assert_current_node :pay_frequency?
      end
      
      context "answered weekly to 'how often do you get paid?'" do
        setup do
          add_response "7"
        end
        
        # Q5
        should "ask 'how many hours do you work?'" do
          assert_current_node :hours_worked_during_the_pay_period?
        end
        
        context "answered 'how many hours do you work?'" do
          setup do
            add_response "42"
          end
          
          # Q6
          should "ask 'how much do you get paid?'" do
            assert_current_node :quantity_paid_during_pay_period?
          end
          
          context "answered 158.39 to 'how much do you get paid?'" do
            setup do
              @initial_total_basic_pay = 158.39
              add_response @initial_total_basic_pay
            end

            should "calculate basic pay hourly rate" do
              assert_state_variable("basic_hourly_rate", 3.77)
            end
            
            # Q7
            should "ask 'how many hours overtime?'" do
              assert_current_node :hours_overtime_during_pay_period?
            end
            
            context "answer '8 hours' to 'how many hours overtime?'" do
              setup do
                add_response 8
              end
              
              # Q8
              should "ask 'what rate of overtime per hour?'" do
                assert_current_node :overtime_pay_per_hour?
              end
              
              context "answer 4.59 to 'overtime per hour?'" do
                setup do
                  add_response 4.59
                end
                
                should "calculate the total overtime pay" do
                  assert_state_variable("total_overtime_pay", 36.72)
                end
                
                should "add the total overtime pay to the total basic pay" do
                  assert_state_variable("total_basic_pay", 195.11)
                end
              end
              
              context "answer 3.71 to 'overtime per hour?'" do
                setup do
                  add_response 3.71
                end
                should "calculate the overtime pay using the lesser value from basic and overtime rates." do
                  assert_state_variable("total_overtime_pay", 30.16)
                end
              end
              
            end
            
            context "answer 'no overtime' to 'how many hours overtime?'" do
              setup do
                add_response 0
              end
              
              # Q9
              should "ask 'are you provided with accommodation?'" do
                assert_current_node :provided_with_accommodation?
              end
            
              context "answer 'no' to 'are you provided with accommodation?'" do
                setup do
                  add_response :no
                end
                
                should "make no adjustment for accommodation" do
                  assert_state_variable("total_basic_pay", @initial_total_basic_pay.to_s)
                end
                
                should "show the results" do
                  assert_current_node :results
                end
              end
              
              context "answer 'yes charged accommodation' to 'are you provided with accommodation?'" do
                setup do
                  add_response :yes_charged
                end
                
                # Q10
                should "ask 'how much do you pay for the accommodation?'" do
                  assert_current_node :accommodation_charge?
                end
                
                context "answer 4.72 to 'how much do you pay for accommodation?'" do
                  setup do
                    add_response 4.72
                  end
                  
                  should "ask 'how often do you use the accommodation?'" do
                    assert_current_node :accommodation_usage?
                  end
                  
                  context "answer 4 to 'how often do you use the accommodation?'" do
                    setup do
                      add_response 4
                    end
                    
                    should "make no adjustment for charged accommodation" do
                      assert_state_variable("total_basic_pay", @initial_total_basic_pay.to_s)
                    end
                  end
                end
                
                context "answer 7.35 to 'how much do you pay for accommodation?'" do
                  setup do
                    add_response 7.35
                  end
                  
                  should "ask 'how often do you use the accommodation?'" do
                    assert_current_node :accommodation_usage?
                  end
                  
                  context "answer 4 to 'how often do you use the accommodation?'" do
{'fraction_non_alphanumeric': 0.04848381017646051, 'fraction_numerical': 0.012849066301182113, 'mean_word_length': 1.2749415432579891, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3518988', 'n_tokens_mistral': 3091, 'n_tokens_neox': 2803, 'n_words': 977}