<commit_before>field_name = "your_problem-category"

casper.test.begin "Subtotal Calculator", (test) ->

  # helpers method
  casper.startChecker()

  # Navigate to the page needed for tests
  casper.thenEvaluate ->
    $("input[name=your_problem-category]:first").click()
  casper.then ->
    @fill 'form', {}, true
    @waitForUrl /.*your_details/
  casper.thenEvaluate ->
    $("input[value=1][type=radio]").click()
  casper.then ->
    @fill 'form', {}, true
    @waitForUrl /.*your_capital/
  casper.thenEvaluate ->
    $("input[type=number]").val(0)
    $("input[value=0][type=radio]").click()
  casper.then ->
    @fill 'form', {}, true
    @waitForUrl /.*your_income/
  casper.thenEvaluate ->
    $("input[type=number]").val(0)
  casper.then ->
    @fill 'form', {}, true
    @waitForUrl /.*your_allowances/

  # check first section is calculated correctly
  casper.thenEvaluate ->
    $("#id_your_allowances-mortgage").val(50).keyup()
  casper.then ->
    @test.assertSelectorHasText {type: 'xpath', path: '//*[@id="content"]/div/form/section[1]/div/p/span'}, "£ 50.00", "first total calculated the correct value"
    @test.assertSelectorHasText {type: 'xpath', path: '//*[@id="content"]/div/form/section[2]/div/p/span'}, "£ 0.00", "second total remained at 0"

  # check second section is calculated correctly
  casper.thenEvaluate ->
    $("#id_partners_allowances-mortgage").val(75).keyup()
    $("#id_partners_allowances-rent").val(150).keyup()
  casper.then ->
    @test.assertSelectorHasText {type: 'xpath', path: '//*[@id="content"]/div/form/section[1]/div/p/span'}, "£ 50.00", "first total remained the same value"
    @test.assertSelectorHasText {type: 'xpath', path: '//*[@id="content"]/div/form/section[2]/div/p/span'}, "£ 225.00", "second total calculated the correct value"

  casper.run ->
    @test.done()

<commit_msg>updated: test to set user to not have benefits. A full/complete test for the new form hasn't been written as we are moving to webdriver and selenium.<commit_after>field_name = "your_problem-category"

casper.test.begin "Subtotal Calculator", (test) ->

  # helpers method
  casper.startChecker()

  # Navigate to the page needed for tests
  casper.thenEvaluate ->
    $("input[name=your_problem-category]:first").click()
  casper.then ->
    @fill 'form', {}, true
    @waitForUrl /.*your_details/
  casper.thenEvaluate ->
    $("input[value=1][type=radio]").click()
    $("input[value=0][name=your_details-has_benefits]").click()
  casper.then ->
    @fill 'form', {}, true
    @waitForUrl /.*your_capital/
  casper.thenEvaluate ->
    $("input[type=number]").val(0)
    $("input[value=0][type=radio]").click()
  casper.then ->
    @fill 'form', {}, true
    @waitForUrl /.*your_income/
  casper.thenEvaluate ->
    $("input[type=number]").val(0)
  casper.then ->
    @fill 'form', {}, true
    @waitForUrl /.*your_allowances/

  # check first section is calculated correctly
  casper.thenEvaluate ->
    $("#id_your_allowances-mortgage").val(50).keyup()
  casper.then ->
    @test.assertSelectorHasText {type: 'xpath', path: '//*[@id="content"]/div/form/section[1]/div/p/span'}, "£ 50.00", "first total calculated the correct value"
    @test.assertSelectorHasText {type: 'xpath', path: '//*[@id="content"]/div/form/section[2]/div/p/span'}, "£ 0.00", "second total remained at 0"

  # check second section is calculated correctly
  casper.thenEvaluate ->
    $("#id_partners_allowances-mortgage").val(75).keyup()
    $("#id_partners_allowances-rent").val(150).keyup()
  casper.then ->
    @test.assertSelectorHasText {type: 'xpath', path: '//*[@id="content"]/div/form/section[1]/div/p/span'}, "£ 50.00", "first total remained the same value"
    @test.assertSelectorHasText {type: 'xpath', path: '//*[@id="content"]/div/form/section[2]/div/p/span'}, "£ 225.00", "second total calculated the correct value"

  casper.run ->
    @test.done()


{'fraction_non_alphanumeric': 0.19042717447246527, 'fraction_numerical': 0.016726711271230058, 'mean_word_length': 4.002574002574002, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '8692', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1329, 'n_words': 269}