-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathmoney_and_salary_questions_test.rb
74 lines (61 loc) · 2.95 KB
/
money_and_salary_questions_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require_relative "engine_test_helper"
class MoneyAndSalaryQuestionsTest < EngineIntegrationTest
setup do
stub_content_store_has_item("/annual-bonus")
end
with_and_without_javascript do
should "handle money and salary questions" do
visit "/annual-bonus/y"
find "h1", text: "How much do you earn?"
within "#current-question" do
within '.govuk-label[for="response"]' do
assert_page_has_content "How much do you earn?"
end
assert page.has_field?("response[amount]", type: "text")
assert page.has_select?("response[period]", options: ["per week", "per month", "per year"])
end
fill_in "response[amount]", with: "5000"
select "month", from: "response[period]"
click_on "Continue"
find "h1", text: "What size bonus do you want?"
assert_current_url "/annual-bonus/y/5000.0-month"
assert page.has_link?("Start again", href: "/annual-bonus")
within ".gem-c-summary-list" do
within ".govuk-summary-list__key" do
assert_page_has_content "How much do you earn?"
end
within(".govuk-summary-list__value") { assert_page_has_content "£5,000 per month" }
within(".govuk-summary-list__actions") { assert page.has_link?("Change", href: "/annual-bonus/y?previous_response=5000.0-month") }
end
within "#current-question" do
within '.govuk-label[for="response"]' do
assert_page_has_content "What size bonus do you want?"
end
assert page.has_field?("response", type: "text")
end
fill_in "response", with: "1000000"
click_on "Continue"
find "h1", text: "Information based on your answers"
assert_current_url "/annual-bonus/y/5000.0-month/1000000.0"
assert page.has_link?("Start again", href: "/annual-bonus")
within ".govuk-summary-list__row:nth-child(1)" do
within ".govuk-summary-list__key" do
assert_page_has_content "How much do you earn?"
end
within(".govuk-summary-list__value") { assert_page_has_content "£5,000 per month" }
within(".govuk-summary-list__actions") { assert page.has_link?("Change", href: "/annual-bonus/y?previous_response=5000.0-month") }
end
within ".govuk-summary-list__row:nth-child(2)" do
within ".govuk-summary-list__key" do
assert_page_has_content "What size bonus do you want?"
end
within(".govuk-summary-list__value") { assert_page_has_content "£1,000,000" }
within(".govuk-summary-list__actions") { assert page.has_link?("Change", href: "/annual-bonus/y/5000.0-month?previous_response=1000000.0") }
end
within "#result-info" do
within page.find(".gem-c-heading h2", match: :first) { assert_page_has_content "OK, here you go." }
within(".info-notice") { assert_page_has_content "This is allowed because £1,000,000 is more than your annual salary of £60,000" }
end
end
end # with_and_without_javascript
end