|
| 1 | +from unittest import skipIf |
| 2 | +from cms import __version__ as cms_version |
1 | 3 | from cms.api import add_plugin |
2 | 4 | from cms.test_utils.testcases import CMSTestCase |
3 | 5 | from cms.utils.urlutils import admin_reverse |
4 | 6 |
|
| 7 | +from djangocms_text.cms_plugins import TextPlugin |
| 8 | + |
5 | 9 | from djangocms_frontend.contrib.utilities.cms_plugins import ( |
| 10 | + EditorNotePlugin, |
6 | 11 | HeadingPlugin, |
7 | 12 | SpacingPlugin, |
8 | 13 | TOCPlugin, |
@@ -117,3 +122,48 @@ def test_heading_inline_endpoint(self): |
117 | 122 | heading.refresh_from_db() |
118 | 123 | self.assertEqual(heading.heading, "My new heading") # New data |
119 | 124 | self.assertEqual(heading.heading_id, "id1") # Other fields unchanged |
| 125 | + |
| 126 | + def test_editor_note(self): |
| 127 | + editor_note = add_plugin( |
| 128 | + placeholder=self.placeholder, |
| 129 | + plugin_type=EditorNotePlugin.__name__, |
| 130 | + language=self.language, |
| 131 | + ) |
| 132 | + add_plugin( |
| 133 | + placeholder=self.placeholder, |
| 134 | + plugin_type=TextPlugin.__name__, |
| 135 | + language=self.language, |
| 136 | + target=editor_note, |
| 137 | + body="<p>My private note</p>", |
| 138 | + ) |
| 139 | + self.publish(self.page, self.language) |
| 140 | + |
| 141 | + with self.login_user_context(self.superuser): |
| 142 | + response = self.client.get(self.request_url) |
| 143 | + self.assertEqual(response.status_code, 200) |
| 144 | + self.assertNotContains(response, 'My private note') |
| 145 | + |
| 146 | + @skipIf(cms_version < "4", "django CMS 4+ required") |
| 147 | + def test_editor_note_with_cms4(self): |
| 148 | + from cms.toolbar.utils import get_object_edit_url |
| 149 | + |
| 150 | + editor_note = add_plugin( |
| 151 | + placeholder=self.placeholder, |
| 152 | + plugin_type=EditorNotePlugin.__name__, |
| 153 | + language=self.language, |
| 154 | + ) |
| 155 | + add_plugin( |
| 156 | + placeholder=self.placeholder, |
| 157 | + plugin_type=TextPlugin.__name__, |
| 158 | + language=self.language, |
| 159 | + target=editor_note, |
| 160 | + body="<p>My private note</p>", |
| 161 | + ) |
| 162 | + |
| 163 | + endpoint = get_object_edit_url(self.page.get_admin_content("en")) |
| 164 | + |
| 165 | + with self.login_user_context(self.superuser): |
| 166 | + response = self.client.get(endpoint) |
| 167 | + print(response.content) |
| 168 | + self.assertEqual(response.status_code, 200) |
| 169 | + self.assertContains(response, 'My private note') |
0 commit comments