+ $this->assertStringContainsString('<img src=""', $page->refresh()->html);
+ }
+
+ public function test_nested_headers_gets_assigned_an_id()
+ {
+ $page = $this->entities->page();
+
+ $content = '<table><tbody><tr><td><h5>Simple Test</h5></td></tr></tbody></table>';
+ $this->asEditor()->put($page->getUrl(), [
+ 'name' => $page->name,
+ 'html' => $content,
+ ]);
+
+ // The top level <table> node will get assign the bkmrk-simple-test id because the system will
+ // take the node value of h5
+ // So the h5 should get the bkmrk-simple-test-1 id
+ $this->assertStringContainsString('<h5 id="bkmrk-simple-test-1">Simple Test</h5>', $page->refresh()->html);
+ }
+
+ public function test_non_breaking_spaces_are_preserved()
+ {
+ $page = $this->entities->page();
+
+ $content = '<p> </p>';
+ $this->asEditor()->put($page->getUrl(), [
+ 'name' => $page->name,
+ 'html' => $content,
+ ]);
+
+ $this->assertStringContainsString('<p id="bkmrk-%C2%A0"> </p>', $page->refresh()->html);
+ }
+
+ public function test_page_save_with_many_headers_and_links_is_reasonable()
+ {
+ $page = $this->entities->page();
+
+ $content = '';
+ for ($i = 0; $i < 500; $i++) {
+ $content .= "<table><tbody><tr><td><h5 id='header-{$i}'>Simple Test</h5><a href='#header-{$i}'></a></td></tr></tbody></table>";
+ }
+
+ $time = time();
+ $this->asEditor()->put($page->getUrl(), [
+ 'name' => $page->name,
+ 'html' => $content,
+ ])->assertRedirect();
+
+ $timeElapsed = time() - $time;
+ $this->assertLessThan(3, $timeElapsed);