|
14 | 14 | :post, |
15 | 15 | raw: |
16 | 16 | "<div data-theme-toc='true'></div>\n\n# Heading 1\nContent for the first heading\n## Heading 2\nContent for the second heading\n### Heading 3\nContent for the third heading\n# Heading 4\nContent for the fourth heading", |
17 | | - topic: topic_1, |
| 17 | + topic: topic_1 |
18 | 18 | ) |
19 | 19 | end |
20 | 20 |
|
|
23 | 23 | :post, |
24 | 24 | raw: |
25 | 25 | "\n# Heading 1\nContent for the first heading\n## Heading 2\nContent for the second heading\n### Heading 3\nContent for the third heading\n# Heading 4\nContent for the fourth heading", |
26 | | - topic: topic_2, |
| 26 | + topic: topic_2 |
27 | 27 | ) |
28 | 28 | end |
29 | 29 |
|
|
32 | 32 | :post, |
33 | 33 | raw: |
34 | 34 | "intentionally \n long \n content \n so \n there's \n plenty \n to be \n scrolled \n past \n which \n will \n force \n the \n timeline \n to \n hide \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll ", |
35 | | - topic: topic_1, |
| 35 | + topic: topic_1 |
36 | 36 | ) |
37 | 37 | end |
38 | 38 |
|
|
41 | 41 | :post, |
42 | 42 | raw: |
43 | 43 | "<div data-theme-toc='true'></div>\n\n# Heading For Reply 1\nContent for the first heading\n## Heading For Reply 2\nContent for the second heading\n### Heading For Reply 3\nContent for the third heading\n# Heading For Reply 4\nContent for the fourth heading", |
44 | | - topic: topic_1, |
| 44 | + topic: topic_1 |
45 | 45 | ) |
46 | 46 | end |
47 | 47 |
|
|
50 | 50 | :post, |
51 | 51 | raw: |
52 | 52 | "intentionally \n long \n content \n so \n there's \n plenty \n to be \n scrolled \n past \n which \n will \n force \n the \n timeline \n to \n hide \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll \n scroll ", |
53 | | - topic: topic_1, |
| 53 | + topic: topic_1 |
54 | 54 | ) |
55 | 55 | end |
56 | 56 |
|
|
94 | 94 | expect(page).to have_no_css(".d-toc-item.d-toc-h1") |
95 | 95 | end |
96 | 96 |
|
| 97 | + it "table of contents updates the highlighted section after navigating directly to other topic" do |
| 98 | + source_topic = Fabricate(:topic, category: category, tags: [tag]) |
| 99 | + |
| 100 | + Fabricate( |
| 101 | + :post, |
| 102 | + topic: source_topic, |
| 103 | + raw: |
| 104 | + "<div data-theme-toc='true'></div>\n\n# Heading 1 on the source topic\nContent for the first heading\n## Heading 2\nContent for the second heading\n### Heading 3\nContent for the third heading\n# Heading 4\nContent for the fourth heading\n<a href=c>Other topic</a>" |
| 105 | + ) |
| 106 | + visit("/t/#{source_topic.id}") |
| 107 | + |
| 108 | + expect(page).to have_css( |
| 109 | + ".d-toc-item.d-toc-h1.active a[data-d-toc='toc-h1-heading-1-on-the-source-topic']" |
| 110 | + ) |
| 111 | + find("a[href='/t/#{topic_1.slug}/#{topic_1.id}'").click |
| 112 | + |
| 113 | + expect(page).to have_css( |
| 114 | + ".d-toc-item.d-toc-h1.active a[data-d-toc='toc-h1-heading-1']" |
| 115 | + ) |
| 116 | + expect(page).to have_no_css( |
| 117 | + "a[data-d-toc='toc-h1-heading-1-on-the-source-topic']" |
| 118 | + ) |
| 119 | + end |
| 120 | + |
97 | 121 | it "timeline will appear without markup if auto_TOC_categories is set to the topic's category" do |
98 | 122 | theme.update_setting(:auto_TOC_categories, "#{category.id}") |
99 | 123 | theme.save! |
|
0 commit comments