@@ -101,4 +101,59 @@ class HtmlValidatorTest < Minitest::Test
101
101
assert Govspeak ::HtmlValidator . new ( "{button start}[Start now](https://gov.uk){/button}" ) . valid?
102
102
assert Govspeak ::HtmlValidator . new ( "{button start cross-domain-tracking:UA-XXXXXX-Y}[Start now](https://gov.uk){/button}" ) . valid?
103
103
end
104
+
105
+ test "allow a table with no tbody" do
106
+ # The publication https://whitehall-admin.integration.publishing.service.gov.uk/government/admin/publications/889052
107
+ # with the HTML attachment "What Works Network membership requirements (HTML)"
108
+ # has a table with no tbody
109
+ assert Govspeak ::HtmlValidator . new ( "<table><tr><td>Hello</td></tr></table>" ) . valid? , "No <tbody> is valid"
110
+ end
111
+
112
+ test "allow a table with a tbody" do
113
+ # If the above test is made to pass, there is a chance this will break
114
+ assert Govspeak ::HtmlValidator . new ( "<table><tbody><tr><td>Hello</td></tr></tbody></table>" ) . valid? , "<tbody> is valid"
115
+ end
116
+
117
+ test "allow a table with a quotes round an element" do
118
+ # The publication https://whitehall-admin.integration.publishing.service.gov.uk/government/admin/publications/964161
119
+ # with the HTML attachment "Upper Tribunal (Tax and Chancery) financial services hearings and register 2014 to date"
120
+ # has quotes spanning table elements
121
+ skip "This should probabably fail"
122
+ assert Govspeak ::HtmlValidator . new ( "<table><tbody><tr><td>\" Hello</td><td>World\" </td></tr></tbody></table>" ) . valid?
123
+ end
124
+
125
+ test "allow a govspeak table" do
126
+ # This ensures that tables created with Markdown are still valid
127
+ # https://whitehall-admin.integration.publishing.service.gov.uk/government/admin/detailed-guides/968711/edit
128
+ govspeak = "
129
+ Table | Header
130
+ - | -
131
+ Build | cells"
132
+ assert Govspeak ::HtmlValidator . new ( govspeak ) . valid? , "Markdown tables are OK"
133
+ end
134
+
135
+ test "allow a document with 2 tables: one with a tbody and one without" do
136
+ # The guidance https://whitehall-admin.integration.publishing.service.gov.uk/government/admin/publications/938674
137
+ # with the HTML attachment "2018 to 2019: Student Loan deduction tables" has tables with and without tbody tags
138
+ html = "
139
+ <table><tr><td>Hello</td></tr></table>
140
+
141
+ <table><tbody><tr><td>Hello</td></tr></tbody></table>
142
+ "
143
+ assert Govspeak ::HtmlValidator . new ( html ) . valid? , "All tables are valid"
144
+ end
145
+
146
+ test "allow unsuitable chars" do
147
+ # The Sanatize gem remove Unsuitable Chars https://github.com/rgrove/sanitize/blob/master/lib/sanitize.rb#L170
148
+ values = [
149
+ "\u2028 " , # https://whitehall-admin.integration.publishing.service.gov.uk/government/admin/news/968745/edit
150
+ "\u202a " , # https://whitehall-admin.integration.publishing.service.gov.uk/government/admin/news/947317/edit
151
+ "\u202c " , # https://whitehall-admin.integration.publishing.service.gov.uk/government/admin/news/947317/edit
152
+ "\ufffc " # https://whitehall-admin.integration.publishing.service.gov.uk/government/admin/news/951534
153
+ ]
154
+ values . each do |value |
155
+ assert Govspeak ::HtmlValidator . new ( value ) . valid? , "value: #{ value } (#{ value . unpack ( "U*" ) } )"
156
+ end
157
+ end
158
+
104
159
end
0 commit comments