@@ -13,8 +13,8 @@ class PageContentTest extends TestCase
13
13
14
14
public function test_page_includes ()
15
15
{
16
- $ page = Page::first ();
17
- $ secondPage = Page::where ('id ' , '!= ' , $ page ->id )->first ();
16
+ $ page = Page::query ()-> first ();
17
+ $ secondPage = Page::query ()-> where ('id ' , '!= ' , $ page ->id )->first ();
18
18
19
19
$ secondPage ->html = "<p id='section1'>Hello, This is a test</p><p id='section2'>This is a second block of content</p> " ;
20
20
$ secondPage ->save ();
@@ -42,8 +42,8 @@ public function test_page_includes()
42
42
43
43
public function test_saving_page_with_includes ()
44
44
{
45
- $ page = Page::first ();
46
- $ secondPage = Page::where ('id ' , '!= ' , $ page ->id )->first ();
45
+ $ page = Page::query ()-> first ();
46
+ $ secondPage = Page::query ()-> where ('id ' , '!= ' , $ page ->id )->first ();
47
47
48
48
$ this ->asEditor ();
49
49
$ includeTag = '{{@ ' . $ secondPage ->id . '}} ' ;
@@ -60,8 +60,8 @@ public function test_saving_page_with_includes()
60
60
61
61
public function test_page_includes_do_not_break_tables ()
62
62
{
63
- $ page = Page::first ();
64
- $ secondPage = Page::where ('id ' , '!= ' , $ page ->id )->first ();
63
+ $ page = Page::query ()-> first ();
64
+ $ secondPage = Page::query ()-> where ('id ' , '!= ' , $ page ->id )->first ();
65
65
66
66
$ content = '<table id="table"><tbody><tr><td>test</td></tr></tbody></table> ' ;
67
67
$ secondPage ->html = $ content ;
@@ -97,7 +97,7 @@ public function test_page_includes_rendered_on_book_export()
97
97
public function test_page_content_scripts_removed_by_default ()
98
98
{
99
99
$ this ->asEditor ();
100
- $ page = Page::first ();
100
+ $ page = Page::query ()-> first ();
101
101
$ script = 'abc123<script>console.log("hello-test")</script>abc123 ' ;
102
102
$ page ->html = "escape {$ script }" ;
103
103
$ page ->save ();
@@ -120,7 +120,7 @@ public function test_more_complex_content_script_escaping_scenarios()
120
120
];
121
121
122
122
$ this ->asEditor ();
123
- $ page = Page::first ();
123
+ $ page = Page::query ()-> first ();
124
124
125
125
foreach ($ checks as $ check ) {
126
126
$ page ->html = $ check ;
@@ -145,7 +145,7 @@ public function test_iframe_js_and_base64_urls_are_removed()
145
145
];
146
146
147
147
$ this ->asEditor ();
148
- $ page = Page::first ();
148
+ $ page = Page::query ()-> first ();
149
149
150
150
foreach ($ checks as $ check ) {
151
151
$ page ->html = $ check ;
@@ -171,7 +171,7 @@ public function test_javascript_uri_links_are_removed()
171
171
];
172
172
173
173
$ this ->asEditor ();
174
- $ page = Page::first ();
174
+ $ page = Page::query ()-> first ();
175
175
176
176
foreach ($ checks as $ check ) {
177
177
$ page ->html = $ check ;
@@ -192,7 +192,7 @@ public function test_form_actions_with_javascript_are_removed()
192
192
];
193
193
194
194
$ this ->asEditor ();
195
- $ page = Page::first ();
195
+ $ page = Page::query ()-> first ();
196
196
197
197
foreach ($ checks as $ check ) {
198
198
$ page ->html = $ check ;
@@ -215,7 +215,7 @@ public function test_metadata_redirects_are_removed()
215
215
];
216
216
217
217
$ this ->asEditor ();
218
- $ page = Page::first ();
218
+ $ page = Page::query ()-> first ();
219
219
220
220
foreach ($ checks as $ check ) {
221
221
$ page ->html = $ check ;
@@ -232,7 +232,7 @@ public function test_metadata_redirects_are_removed()
232
232
public function test_page_inline_on_attributes_removed_by_default ()
233
233
{
234
234
$ this ->asEditor ();
235
- $ page = Page::first ();
235
+ $ page = Page::query ()-> first ();
236
236
$ script = '<p onmouseenter="console.log( \'test \')">Hello</p> ' ;
237
237
$ page ->html = "escape {$ script }" ;
238
238
$ page ->save ();
@@ -255,7 +255,7 @@ public function test_more_complex_inline_on_attributes_escaping_scenarios()
255
255
];
256
256
257
257
$ this ->asEditor ();
258
- $ page = Page::first ();
258
+ $ page = Page::query ()-> first ();
259
259
260
260
foreach ($ checks as $ check ) {
261
261
$ page ->html = $ check ;
@@ -271,7 +271,7 @@ public function test_more_complex_inline_on_attributes_escaping_scenarios()
271
271
public function test_page_content_scripts_show_when_configured ()
272
272
{
273
273
$ this ->asEditor ();
274
- $ page = Page::first ();
274
+ $ page = Page::query ()-> first ();
275
275
config ()->push ('app.allow_content_scripts ' , 'true ' );
276
276
277
277
$ script = 'abc123<script>console.log("hello-test")</script>abc123 ' ;
@@ -286,7 +286,7 @@ public function test_page_content_scripts_show_when_configured()
286
286
public function test_page_inline_on_attributes_show_if_configured ()
287
287
{
288
288
$ this ->asEditor ();
289
- $ page = Page::first ();
289
+ $ page = Page::query ()-> first ();
290
290
config ()->push ('app.allow_content_scripts ' , 'true ' );
291
291
292
292
$ script = '<p onmouseenter="console.log( \'test \')">Hello</p> ' ;
@@ -301,7 +301,7 @@ public function test_page_inline_on_attributes_show_if_configured()
301
301
public function test_duplicate_ids_does_not_break_page_render ()
302
302
{
303
303
$ this ->asEditor ();
304
- $ pageA = Page::first ();
304
+ $ pageA = Page::query ()-> first ();
305
305
$ pageB = Page::query ()->where ('id ' , '!= ' , $ pageA ->id )->first ();
306
306
307
307
$ content = '<ul id="bkmrk-xxx-%28"></ul> <ul id="bkmrk-xxx-%28"></ul> ' ;
@@ -318,7 +318,7 @@ public function test_duplicate_ids_does_not_break_page_render()
318
318
public function test_duplicate_ids_fixed_on_page_save ()
319
319
{
320
320
$ this ->asEditor ();
321
- $ page = Page::first ();
321
+ $ page = Page::query ()-> first ();
322
322
323
323
$ content = '<ul id="bkmrk-test"><li>test a</li><li><ul id="bkmrk-test"><li>test b</li></ul></li></ul> ' ;
324
324
$ pageSave = $ this ->put ($ page ->getUrl (), [
@@ -328,14 +328,14 @@ public function test_duplicate_ids_fixed_on_page_save()
328
328
]);
329
329
$ pageSave ->assertRedirect ();
330
330
331
- $ updatedPage = Page::where ('id ' , '= ' , $ page ->id )->first ();
331
+ $ updatedPage = Page::query ()-> where ('id ' , '= ' , $ page ->id )->first ();
332
332
$ this ->assertEquals (substr_count ($ updatedPage ->html , "bkmrk-test \"" ), 1 );
333
333
}
334
334
335
335
public function test_anchors_referencing_non_bkmrk_ids_rewritten_after_save ()
336
336
{
337
337
$ this ->asEditor ();
338
- $ page = Page::first ();
338
+ $ page = Page::query ()-> first ();
339
339
340
340
$ content = '<h1 id="non-standard-id">test</h1><p><a href="#non-standard-id">link</a></p> ' ;
341
341
$ this ->put ($ page ->getUrl (), [
@@ -344,7 +344,7 @@ public function test_anchors_referencing_non_bkmrk_ids_rewritten_after_save()
344
344
'summary ' => ''
345
345
]);
346
346
347
- $ updatedPage = Page::where ('id ' , '= ' , $ page ->id )->first ();
347
+ $ updatedPage = Page::query ()-> where ('id ' , '= ' , $ page ->id )->first ();
348
348
$ this ->assertStringContainsString ('id="bkmrk-test" ' , $ updatedPage ->html );
349
349
$ this ->assertStringContainsString ('href="#bkmrk-test" ' , $ updatedPage ->html );
350
350
}
@@ -484,6 +484,25 @@ public function test_page_markdown_strikethrough_rendering()
484
484
$ pageView ->assertElementExists ('.page-content p > s ' );
485
485
}
486
486
487
+ public function test_page_markdown_single_html_comment_saving ()
488
+ {
489
+ $ this ->asEditor ();
490
+ $ page = Page::query ()->first ();
491
+
492
+ $ content = '<!-- Test Comment --> ' ;
493
+ $ this ->put ($ page ->getUrl (), [
494
+ 'name ' => $ page ->name , 'markdown ' => $ content ,
495
+ 'html ' => '' , 'summary ' => ''
496
+ ]);
497
+
498
+ $ page ->refresh ();
499
+ $ this ->assertStringMatchesFormat ($ content , $ page ->html );
500
+
501
+ $ pageView = $ this ->get ($ page ->getUrl ());
502
+ $ pageView ->assertStatus (200 );
503
+ $ pageView ->assertSee ($ content );
504
+ }
505
+
487
506
public function test_base64_images_get_extracted_from_page_content ()
488
507
{
489
508
$ this ->asEditor ();
0 commit comments