kopia lustrzana https://github.com/wagtail/wagtail
Fix test for tableblock
rodzic
cf6fc34e96
commit
0e45188aa8
|
@ -6,10 +6,13 @@ from django.urls import reverse
|
|||
from django.utils import translation
|
||||
|
||||
from wagtail.contrib.table_block.blocks import DEFAULT_TABLE_OPTIONS, TableBlock
|
||||
from wagtail.core.blocks.field_block import FieldBlockAdapter
|
||||
from wagtail.core.models import Page
|
||||
from wagtail.tests.testapp.models import TableBlockStreamPage
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
|
||||
from .blocks import TableInput
|
||||
|
||||
|
||||
class TestTableBlock(TestCase):
|
||||
def setUp(self):
|
||||
|
@ -377,19 +380,20 @@ class TestTableBlockForm(WagtailTestUtils, SimpleTestCase):
|
|||
block_3_opts = TableBlock(table_options={'allowEmpty': False}).table_options
|
||||
self.assertEqual(block_3_opts['allowEmpty'], False)
|
||||
|
||||
@unittest.expectedFailure # TODO(telepath)
|
||||
def test_tableblock_render_form(self):
|
||||
"""
|
||||
Test the rendered form field generated by TableBlock.
|
||||
"""
|
||||
def test_adapt(self):
|
||||
block = TableBlock()
|
||||
html = block.render_form(value=self.value)
|
||||
self.assertIn('<script>initTable', html)
|
||||
self.assertIn('<div class="field char_field widget-table_input">', html)
|
||||
# check that options render in the init function
|
||||
self.assertIn('"editor": "text"', html)
|
||||
self.assertIn('"autoColumnSize": false', html)
|
||||
self.assertIn('"stretchH": "all"', html)
|
||||
|
||||
block.set_name('test_tableblock')
|
||||
js_args = FieldBlockAdapter().js_args(block)
|
||||
|
||||
self.assertEqual(js_args[0], 'test_tableblock')
|
||||
self.assertIsInstance(js_args[1], TableInput)
|
||||
self.assertEqual(js_args[2], {
|
||||
'label': 'Test tableblock',
|
||||
'required': True,
|
||||
'icon': 'table',
|
||||
'classname': 'field char_field widget-table_input fieldname-test_tableblock'
|
||||
})
|
||||
|
||||
def test_searchable_content(self):
|
||||
"""
|
||||
|
@ -401,6 +405,7 @@ class TestTableBlockForm(WagtailTestUtils, SimpleTestCase):
|
|||
self.assertIn('Brenik', search_content)
|
||||
|
||||
|
||||
# TODO(telepath) replace this with a functional test
|
||||
class TestTableBlockPageEdit(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
self.value = {
|
||||
|
@ -422,7 +427,7 @@ class TestTableBlockPageEdit(TestCase, WagtailTestUtils):
|
|||
self.table_block_page = self.root_page.add_child(instance=table_block_page_instance)
|
||||
self.user = self.login()
|
||||
|
||||
@unittest.expectedFailure # TODO(telepath)
|
||||
@unittest.expectedFailure
|
||||
def test_page_edit_page_view(self):
|
||||
"""
|
||||
Test that edit page loads with saved table data and correct init function.
|
||||
|
|
Ładowanie…
Reference in New Issue