govuk-design-system-rails 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/helpers/govuk_design_system/accordion_helper.rb +7 -0
- data/app/helpers/govuk_design_system/back_link_helper.rb +13 -0
- data/app/helpers/govuk_design_system/breadcrumbs_helper.rb +7 -0
- data/app/helpers/govuk_design_system/button_helper.rb +71 -0
- data/app/helpers/govuk_design_system/checkboxes_helper.rb +8 -0
- data/app/helpers/govuk_design_system/components_helper.rb +13 -0
- data/app/helpers/govuk_design_system/cookie_banner_helper.rb +7 -0
- data/app/helpers/govuk_design_system/date_input_helper.rb +8 -0
- data/app/helpers/govuk_design_system/details_helper.rb +32 -0
- data/app/helpers/govuk_design_system/error_message_helper.rb +7 -0
- data/app/helpers/govuk_design_system/error_summary_helper.rb +20 -0
- data/app/helpers/govuk_design_system/fieldset_helper.rb +9 -0
- data/app/helpers/govuk_design_system/file_upload_helper.rb +59 -0
- data/app/helpers/govuk_design_system/header_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hint_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hmcts_badge_helper.rb +7 -0
- data/app/helpers/govuk_design_system/hmcts_banner_helper.rb +7 -0
- data/app/helpers/govuk_design_system/input_helper.rb +8 -0
- data/app/helpers/govuk_design_system/inset_text_helper.rb +9 -0
- data/app/helpers/govuk_design_system/label_helper.rb +7 -0
- data/app/helpers/govuk_design_system/notification_banner_helper.rb +8 -0
- data/app/helpers/govuk_design_system/phase_banner_helper.rb +21 -0
- data/app/helpers/govuk_design_system/radios_helper.rb +8 -0
- data/app/helpers/govuk_design_system/select_helper.rb +8 -0
- data/app/helpers/govuk_design_system/skip_link_helper.rb +13 -0
- data/app/helpers/govuk_design_system/summary_list_helper.rb +7 -0
- data/app/helpers/govuk_design_system/tabs_helper.rb +7 -0
- data/app/helpers/govuk_design_system/tag_helper.rb +8 -0
- data/app/helpers/govuk_design_system/textarea_helper.rb +8 -0
- data/app/helpers/govuk_design_system/warning_text_helper.rb +20 -0
- data/app/views/components/_govuk_accordion.html.erb +44 -0
- data/app/views/components/_govuk_action_link.html.erb +12 -0
- data/app/views/components/_govuk_breadcrumbs.html.erb +25 -0
- data/app/views/components/_govuk_checkboxes.html.erb +125 -0
- data/app/views/components/_govuk_cookie_banner.html.erb +75 -0
- data/app/views/components/_govuk_date_input.html.erb +94 -0
- data/app/views/components/_govuk_error_message.html.erb +13 -0
- data/app/views/components/_govuk_error_summary.html.erb +32 -0
- data/app/views/components/_govuk_fieldset.html.erb +21 -0
- data/app/views/components/_govuk_header.html.erb +64 -0
- data/app/views/components/_govuk_hint.html.erb +7 -0
- data/app/views/components/_govuk_hr.html.erb +1 -0
- data/app/views/components/_govuk_input.html.erb +97 -0
- data/app/views/components/_govuk_inset_text.html.erb +10 -0
- data/app/views/components/_govuk_label.html.erb +18 -0
- data/app/views/components/_govuk_notification_banner.html.erb +68 -0
- data/app/views/components/_govuk_radios.html.erb +141 -0
- data/app/views/components/_govuk_select.html.erb +105 -0
- data/app/views/components/_govuk_summary_list.html.erb +39 -0
- data/app/views/components/_govuk_tabs.html.erb +46 -0
- data/app/views/components/_govuk_textarea.html.erb +70 -0
- data/app/views/components/_hmcts_banner.html.erb +33 -0
- data/app/views/form_components/_govuk_checkboxes.html.erb +21 -0
- data/app/views/form_components/_govuk_date_input.html.erb +32 -0
- data/app/views/form_components/_govuk_input.html.erb +11 -0
- data/app/views/form_components/_govuk_radios.html.erb +24 -0
- data/app/views/form_components/_govuk_select.html.erb +25 -0
- data/app/views/form_components/_govuk_textarea.html.erb +11 -0
- data/lib/govuk-design-system-rails.rb +1 -0
- data/lib/govuk_design_system/engine.rb +50 -0
- data/lib/govuk_design_system.rb +4 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/packs/application.js +15 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config/application.rb +38 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +76 -0
- data/spec/dummy/config/environments/production.rb +120 -0
- data/spec/dummy/config/environments/test.rb +59 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +43 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config.ru +6 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/development_secret.txt +1 -0
- data/spec/helpers/govuk_design_system/accordion_helper_spec.rb +353 -0
- data/spec/helpers/govuk_design_system/breadcrumbs_helper_spec.rb +90 -0
- data/spec/helpers/govuk_design_system/button_helper_spec.rb +34 -0
- data/spec/helpers/govuk_design_system/checkboxes_helper_spec.rb +146 -0
- data/spec/helpers/govuk_design_system/cookie_banner_helper_spec.rb +65 -0
- data/spec/helpers/govuk_design_system/date_input_helper_spec.rb +63 -0
- data/spec/helpers/govuk_design_system/details_helper_spec.rb +42 -0
- data/spec/helpers/govuk_design_system/error_message_helper_spec.rb +18 -0
- data/spec/helpers/govuk_design_system/error_summary_helper_spec.rb +39 -0
- data/spec/helpers/govuk_design_system/header_helper_spec.rb +138 -0
- data/spec/helpers/govuk_design_system/hint_helper_spec.rb +20 -0
- data/spec/helpers/govuk_design_system/hmcts_badge_helper_spec.rb +16 -0
- data/spec/helpers/govuk_design_system/hmcts_banner_helper_spec.rb +59 -0
- data/spec/helpers/govuk_design_system/input_helper_spec.rb +157 -0
- data/spec/helpers/govuk_design_system/inset_text_helper_spec.rb +58 -0
- data/spec/helpers/govuk_design_system/label_helper_spec.rb +21 -0
- data/spec/helpers/govuk_design_system/notification_banner_helper_spec.rb +98 -0
- data/spec/helpers/govuk_design_system/radios_helper_spec.rb +270 -0
- data/spec/helpers/govuk_design_system/select_helper_spec.rb +85 -0
- data/spec/helpers/govuk_design_system/summary_list_helper_spec.rb +138 -0
- data/spec/helpers/govuk_design_system/tabs_helper_spec.rb +129 -0
- data/spec/helpers/govuk_design_system/tag_helper_spec.rb +17 -0
- data/spec/helpers/govuk_design_system/textarea_helper_spec.rb +67 -0
- data/spec/rails_helper.rb +64 -0
- data/spec/spec_helper.rb +116 -0
- metadata +401 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::HintHelper, type: :helper do
|
4
|
+
describe "#govukHint" do
|
5
|
+
it "returns the correct HTML for the default example" do
|
6
|
+
html = helper.govukHint({
|
7
|
+
id: "test-hint",
|
8
|
+
classes: %w[test-class],
|
9
|
+
attributes: { "data-test" => "test-attr" },
|
10
|
+
text: "test"
|
11
|
+
})
|
12
|
+
|
13
|
+
expect(html).to match_html(<<~HTML)
|
14
|
+
<div class="govuk-hint test-class" data-test="test-attr" id="test-hint">
|
15
|
+
test
|
16
|
+
</div>
|
17
|
+
HTML
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::HmctsBadgeHelper, type: :helper do
|
4
|
+
describe "#hmctsBadge" do
|
5
|
+
it "returns the correct HTML for success" do
|
6
|
+
html = helper.hmctsBadge({
|
7
|
+
text: "Information",
|
8
|
+
classes: "hmcts-govuk-badge--green"
|
9
|
+
})
|
10
|
+
|
11
|
+
expect(html).to match_html(<<~HTML)
|
12
|
+
<span class="hmcts-badge hmcts-govuk-badge--green">Information</span>
|
13
|
+
HTML
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::HmctsBannerHelper, type: :helper do
|
4
|
+
describe "#govukInput" do
|
5
|
+
it "returns the correct HTML for success" do
|
6
|
+
html = helper.hmctsBanner({
|
7
|
+
text: "The image was added",
|
8
|
+
type: "success"
|
9
|
+
})
|
10
|
+
|
11
|
+
expect(html).to match_html(<<~HTML)
|
12
|
+
<div class="hmcts-banner hmcts-banner--success">
|
13
|
+
<div class="hmcts-banner__message">
|
14
|
+
The image was added
|
15
|
+
<svg class="hmcts-banner__icon" focusable="false" height="25" role="presentation" viewBox="0 0 25 25" width="25" xmlns="http://www.w3.org/2000/svg">
|
16
|
+
<path d="M25,6.2L8.7,23.2L0,14.1l4-4.2l4.7,4.9L21,2L25,6.2z"></path>
|
17
|
+
</svg>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
HTML
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns the correct HTML for information" do
|
24
|
+
html = helper.hmctsBanner({
|
25
|
+
text: "The image did not finish uploading - you must refresh the image",
|
26
|
+
type: "information"
|
27
|
+
})
|
28
|
+
|
29
|
+
expect(html).to match_html(<<~HTML)
|
30
|
+
<div class="hmcts-banner">
|
31
|
+
<div class="hmcts-banner__message">
|
32
|
+
The image did not finish uploading - you must refresh the image
|
33
|
+
<svg class="hmcts-banner__icon" fill="currentColor" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" height="25" width="25">
|
34
|
+
<path d="M13.7,18.5h-2.4v-2.4h2.4V18.5z M12.5,13.7c-0.7,0-1.2-0.5-1.2-1.2V7.7c0-0.7,0.5-1.2,1.2-1.2s1.2,0.5,1.2,1.2v4.8 C13.7,13.2,13.2,13.7,12.5,13.7z M12.5,0.5c-6.6,0-12,5.4-12,12s5.4,12,12,12s12-5.4,12-12S19.1,0.5,12.5,0.5z"></path>
|
35
|
+
</svg>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
HTML
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns the correct HTML when a symbol type is passed" do
|
42
|
+
html = helper.hmctsBanner({
|
43
|
+
text: "The image did not finish uploading - you must refresh the image",
|
44
|
+
type: :information
|
45
|
+
})
|
46
|
+
|
47
|
+
expect(html).to match_html(<<~HTML)
|
48
|
+
<div class="hmcts-banner">
|
49
|
+
<div class="hmcts-banner__message">
|
50
|
+
The image did not finish uploading - you must refresh the image
|
51
|
+
<svg class="hmcts-banner__icon" fill="currentColor" role="presentation" focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" height="25" width="25">
|
52
|
+
<path d="M13.7,18.5h-2.4v-2.4h2.4V18.5z M12.5,13.7c-0.7,0-1.2-0.5-1.2-1.2V7.7c0-0.7,0.5-1.2,1.2-1.2s1.2,0.5,1.2,1.2v4.8 C13.7,13.2,13.2,13.7,12.5,13.7z M12.5,0.5c-6.6,0-12,5.4-12,12s5.4,12,12,12s12-5.4,12-12S19.1,0.5,12.5,0.5z"></path>
|
53
|
+
</svg>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
HTML
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::InputHelper, type: :helper do
|
4
|
+
describe "#govukInput" do
|
5
|
+
it "returns the correct HTML for the default example" do
|
6
|
+
html = helper.govukInput({
|
7
|
+
label: {
|
8
|
+
text: "What is the name of the event?",
|
9
|
+
classes: "govuk-label--l",
|
10
|
+
isPageHeading: true
|
11
|
+
},
|
12
|
+
id: "event-name",
|
13
|
+
name: "event-name"
|
14
|
+
})
|
15
|
+
|
16
|
+
expect(html).to match_html(<<~HTML)
|
17
|
+
<div class="govuk-form-group">
|
18
|
+
<h1 class="govuk-label-wrapper"><label class="govuk-label govuk-label--l" for="event-name">
|
19
|
+
What is the name of the event?
|
20
|
+
</label>
|
21
|
+
</h1>
|
22
|
+
<input class="govuk-input" id="event-name" name="event-name" type="text">
|
23
|
+
</div>
|
24
|
+
HTML
|
25
|
+
end
|
26
|
+
|
27
|
+
it "allows a prefix" do
|
28
|
+
html = helper.govukInput({
|
29
|
+
id: "cost",
|
30
|
+
name: "cost",
|
31
|
+
label: {
|
32
|
+
text: "What is the cost in pounds?",
|
33
|
+
classes: "govuk-label--l",
|
34
|
+
isPageHeading: true
|
35
|
+
},
|
36
|
+
prefix: {
|
37
|
+
text: "£"
|
38
|
+
},
|
39
|
+
classes: "govuk-input--width-5",
|
40
|
+
spellcheck: false
|
41
|
+
})
|
42
|
+
|
43
|
+
expect(html).to match_html(<<~HTML)
|
44
|
+
<div class="govuk-form-group">
|
45
|
+
<h1 class="govuk-label-wrapper"><label class="govuk-label govuk-label--l" for="cost">
|
46
|
+
What is the cost in pounds?
|
47
|
+
</label>
|
48
|
+
</h1>
|
49
|
+
<div class="govuk-input__wrapper">
|
50
|
+
<div class="govuk-input__prefix" aria-hidden="true">£</div>
|
51
|
+
<input class="govuk-input govuk-input--width-5" id="cost" name="cost" type="text" spellcheck="false">
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
HTML
|
55
|
+
end
|
56
|
+
|
57
|
+
it "allows hint text" do
|
58
|
+
html = helper.govukInput({
|
59
|
+
label: {
|
60
|
+
text: "What is the name of the event?",
|
61
|
+
classes: "govuk-label--l",
|
62
|
+
isPageHeading: true
|
63
|
+
},
|
64
|
+
hint: {
|
65
|
+
text: "The name you’ll use on promotional material"
|
66
|
+
},
|
67
|
+
id: "event-name",
|
68
|
+
name: "event-name"
|
69
|
+
})
|
70
|
+
|
71
|
+
expect(html).to match_html(<<~HTML)
|
72
|
+
<div class="govuk-form-group">
|
73
|
+
<h1 class="govuk-label-wrapper"><label class="govuk-label govuk-label--l" for="event-name">
|
74
|
+
What is the name of the event?
|
75
|
+
</label>
|
76
|
+
</h1>
|
77
|
+
<div id="event-name-hint" class="govuk-hint">
|
78
|
+
The name you’ll use on promotional material
|
79
|
+
</div>
|
80
|
+
<input class="govuk-input" id="event-name" name="event-name" type="text" aria-describedby="event-name-hint">
|
81
|
+
</div>
|
82
|
+
HTML
|
83
|
+
end
|
84
|
+
|
85
|
+
it "allows a pattern to be specified" do
|
86
|
+
html = helper.govukInput({
|
87
|
+
label: {
|
88
|
+
text: "What is your account number?",
|
89
|
+
classes: "govuk-label--l",
|
90
|
+
isPageHeading: true
|
91
|
+
},
|
92
|
+
classes: "govuk-input--width-10",
|
93
|
+
hint: {
|
94
|
+
text: "Must be between 6 and 8 digits long"
|
95
|
+
},
|
96
|
+
id: "account-number",
|
97
|
+
name: "account-number",
|
98
|
+
inputmode: "numeric",
|
99
|
+
pattern: "[0-9]*",
|
100
|
+
spellcheck: false
|
101
|
+
})
|
102
|
+
|
103
|
+
expect(html).to match_html(<<~HTML)
|
104
|
+
<div class="govuk-form-group">
|
105
|
+
<h1 class="govuk-label-wrapper"><label class="govuk-label govuk-label--l" for="account-number">
|
106
|
+
What is your account number?
|
107
|
+
</label>
|
108
|
+
</h1>
|
109
|
+
<div id="account-number-hint" class="govuk-hint">
|
110
|
+
Must be between 6 and 8 digits long
|
111
|
+
</div>
|
112
|
+
<input class="govuk-input govuk-input--width-10" id="account-number" name="account-number" type="text" spellcheck="false" aria-describedby="account-number-hint" pattern="[0-9]*" inputmode="numeric">
|
113
|
+
</div>
|
114
|
+
HTML
|
115
|
+
end
|
116
|
+
|
117
|
+
it "handles error messages correctly" do
|
118
|
+
html = helper.govukInput({
|
119
|
+
id: "cost-per-item-error",
|
120
|
+
name: "cost-per-item-error",
|
121
|
+
label: {
|
122
|
+
text: "What is the cost per item, in pounds?",
|
123
|
+
classes: "govuk-label--l",
|
124
|
+
isPageHeading: true
|
125
|
+
},
|
126
|
+
prefix: {
|
127
|
+
text: "£"
|
128
|
+
},
|
129
|
+
suffix: {
|
130
|
+
text: "per item"
|
131
|
+
},
|
132
|
+
errorMessage: {
|
133
|
+
text: "Enter a cost per item, in pounds"
|
134
|
+
},
|
135
|
+
classes: "govuk-input--width-5",
|
136
|
+
spellcheck: false
|
137
|
+
})
|
138
|
+
|
139
|
+
expect(html).to match_html(<<~HTML)
|
140
|
+
<div class="govuk-form-group govuk-form-group--error">
|
141
|
+
<h1 class="govuk-label-wrapper"><label class="govuk-label govuk-label--l" for="cost-per-item-error">
|
142
|
+
What is the cost per item, in pounds?
|
143
|
+
</label>
|
144
|
+
</h1>
|
145
|
+
<p id="cost-per-item-error-error" class="govuk-error-message">
|
146
|
+
<span class="govuk-visually-hidden">Error:</span> Enter a cost per item, in pounds
|
147
|
+
</p>
|
148
|
+
<div class="govuk-input__wrapper">
|
149
|
+
<div class="govuk-input__prefix" aria-hidden="true">£</div>
|
150
|
+
<input class="govuk-input govuk-input--width-5 govuk-input--error" id="cost-per-item-error" name="cost-per-item-error" type="text" spellcheck="false" aria-describedby="cost-per-item-error-error">
|
151
|
+
<div class="govuk-input__suffix" aria-hidden="true">per item</div>
|
152
|
+
</div>
|
153
|
+
</div>
|
154
|
+
HTML
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::InsetTextHelper, type: :helper do
|
4
|
+
describe "#govukInsetText" do
|
5
|
+
it "returns the correct HTML for the default example" do
|
6
|
+
html = helper.govukInsetText({
|
7
|
+
text: "It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application."
|
8
|
+
})
|
9
|
+
|
10
|
+
expect(html).to match_html(<<~HTML)
|
11
|
+
<div class="govuk-inset-text">
|
12
|
+
It can take up to 8 weeks to register a lasting power of attorney if there are no mistakes in the application.
|
13
|
+
</div>
|
14
|
+
HTML
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns the correct HTML for an example using html" do
|
18
|
+
inset_html = <<~HTML.html_safe
|
19
|
+
<p class="govuk-body-l govuk-!-margin-bottom-4">
|
20
|
+
Creating a case starts from a product record page.
|
21
|
+
</p>
|
22
|
+
<p class="govuk-body">
|
23
|
+
Find a product and create the case from there.
|
24
|
+
</p>
|
25
|
+
<details class="govuk-details" data-module="govuk-details">
|
26
|
+
<summary class="govuk-details__summary">
|
27
|
+
<span class="govuk-details__summary-text">
|
28
|
+
How to create a case
|
29
|
+
</span>
|
30
|
+
</summary>
|
31
|
+
</details>
|
32
|
+
HTML
|
33
|
+
|
34
|
+
html = helper.govukInsetText({
|
35
|
+
classes: "govuk-!-margin-bottom-7",
|
36
|
+
html: inset_html
|
37
|
+
})
|
38
|
+
|
39
|
+
expect(html).to match_html(<<~HTML)
|
40
|
+
<div class="govuk-inset-text govuk-!-margin-bottom-7">
|
41
|
+
<p class="govuk-body-l govuk-!-margin-bottom-4">
|
42
|
+
Creating a case starts from a product record page.
|
43
|
+
</p>
|
44
|
+
<p class="govuk-body">
|
45
|
+
Find a product and create the case from there.
|
46
|
+
</p>
|
47
|
+
<details class="govuk-details" data-module="govuk-details">
|
48
|
+
<summary class="govuk-details__summary">
|
49
|
+
<span class="govuk-details__summary-text">
|
50
|
+
How to create a case
|
51
|
+
</span>
|
52
|
+
</summary>
|
53
|
+
</details>
|
54
|
+
</div>
|
55
|
+
HTML
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::LabelHelper, type: :helper do
|
4
|
+
describe "#govukLabel" do
|
5
|
+
it "returns the correct HTML for the default example" do
|
6
|
+
html = helper.govukLabel({
|
7
|
+
html: "<strong>test</strong>".html_safe,
|
8
|
+
isPageHeading: true,
|
9
|
+
for: "test"
|
10
|
+
})
|
11
|
+
|
12
|
+
expect(html).to match_html(<<~HTML)
|
13
|
+
<h1 class="govuk-label-wrapper">
|
14
|
+
<label class="govuk-label" for="test">
|
15
|
+
<strong>test</strong>
|
16
|
+
</label>
|
17
|
+
</h1>
|
18
|
+
HTML
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
RSpec.describe GovukDesignSystem::NotificationBannerHelper, type: :helper do
|
4
|
+
describe "#govukNotificationBanner" do
|
5
|
+
context "when passing html to the component" do
|
6
|
+
it "returns the correct HTML" do
|
7
|
+
html = '<p class="govuk-notification-banner__heading">You have 7 days left to send your application.<a class="govuk-notification-banner__link" href="#">View application</a>.</p>'.html_safe
|
8
|
+
output = helper.govukNotificationBanner({
|
9
|
+
html: html,
|
10
|
+
})
|
11
|
+
|
12
|
+
expect(output).to match_html(<<~HTML)
|
13
|
+
<div class="govuk-notification-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
|
14
|
+
<div class="govuk-notification-banner__header">
|
15
|
+
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
|
16
|
+
Important
|
17
|
+
</h2>
|
18
|
+
</div>
|
19
|
+
<div class="govuk-notification-banner__content">
|
20
|
+
<p class="govuk-notification-banner__heading">
|
21
|
+
You have 7 days left to send your application.
|
22
|
+
<a class="govuk-notification-banner__link" href="#">View application</a>.
|
23
|
+
</p>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
HTML
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when passing text to the component" do
|
31
|
+
it "returns the correct HTML" do
|
32
|
+
output = helper.govukNotificationBanner({
|
33
|
+
text: "There may be a delay in processing your application because of the coronavirus outbreak."
|
34
|
+
})
|
35
|
+
|
36
|
+
expect(output).to match_html(<<~HTML)
|
37
|
+
<div class="govuk-notification-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
|
38
|
+
<div class="govuk-notification-banner__header">
|
39
|
+
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
|
40
|
+
Important
|
41
|
+
</h2>
|
42
|
+
</div>
|
43
|
+
<div class="govuk-notification-banner__content">
|
44
|
+
<p class="govuk-notification-banner__heading">There may be a delay in processing your application because of the coronavirus outbreak.</p>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
HTML
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when passing a block to the component" do
|
52
|
+
it "returns the correct HTML" do
|
53
|
+
output = helper.govukNotificationBanner { "Testing block passing" }
|
54
|
+
|
55
|
+
expect(output).to match_html(<<~HTML)
|
56
|
+
<div class="govuk-notification-banner" role="region" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
|
57
|
+
<div class="govuk-notification-banner__header">
|
58
|
+
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
|
59
|
+
Important
|
60
|
+
</h2>
|
61
|
+
</div>
|
62
|
+
<div class="govuk-notification-banner__content">
|
63
|
+
Testing block passing
|
64
|
+
</div>
|
65
|
+
</div>
|
66
|
+
HTML
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when rendering a success banner" do
|
71
|
+
context "when passing html to the component" do
|
72
|
+
it "returns the correct HTML for success" do
|
73
|
+
html = "<h3 class='govuk-notification-banner__heading'>Training outcome recorded and trainee withdrawn</h3><p class='govuk-body'>Contact <a class='govuk-notification-banner__link' href='#'>example@department.gov.uk</a> if you think there's a problem.</p>".html_safe
|
74
|
+
output = helper.govukNotificationBanner({
|
75
|
+
html: html,
|
76
|
+
type: "success"
|
77
|
+
})
|
78
|
+
|
79
|
+
expect(output).to match_html(<<~HTML)
|
80
|
+
<div class="govuk-notification-banner govuk-notification-banner--success" role="alert" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
|
81
|
+
<div class="govuk-notification-banner__header">
|
82
|
+
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
|
83
|
+
Success
|
84
|
+
</h2>
|
85
|
+
</div>
|
86
|
+
<div class="govuk-notification-banner__content">
|
87
|
+
<h3 class="govuk-notification-banner__heading">
|
88
|
+
Training outcome recorded and trainee withdrawn
|
89
|
+
</h3>
|
90
|
+
<p class="govuk-body">Contact <a class="govuk-notification-banner__link" href="#">example@department.gov.uk</a> if you think there's a problem.</p>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
HTML
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|