Tests to demo a bug.
I haven't investigated the cause.
@@ -896,6 +896,36 @@ class TestTable(Table):
verify_table_html(query={adv_query_param: '!!!'}, table=TestTable(rows=TFoo.objects.all().order_by('pk')), find=dict(class_='iommi_query_error'), expected_html='<div class="iommi_query_error">Invalid syntax for query</div>')
+@pytest.mark.django_db
+def test_query_form_freetext():
+ class TestTable(Table):
+ b = Column(filter__include=True, filter__freetext=True)
+
+ expected_html = """
+ <span class="iommi_query_form_simple">
+ <div><label for="id_freetext">Search</label><input id="id_freetext" name="freetext" type="text" value=""></div>
+ </span>
+ """
+ verify_table_html(table=TestTable(rows=TFoo.objects.all()[:1]), find=dict(class_="iommi_query_form_simple"), expected_html=expected_html)
+
+
+@pytest.mark.django_db
+def test_query_form_freetext__exclude_label():
+ # As of right now this test does not pass! But I claim it should.
+ class TestTable(Table):
+ b = Column(filter__include=True, filter__freetext=True)
+
+ class Meta:
+ query__form__fields__freetext__label__include = False
+
+ expected_html = """
+ <span class="iommi_query_form_simple">
+ <div><input id="id_freetext" name="freetext" type="text" value=""></div>
+ </span>
+ """
+ verify_table_html(table=TestTable(rows=TFoo.objects.all()[:1]), find=dict(class_="iommi_query_form_simple"), expected_html=expected_html)
+
+
@pytest.mark.django_db
def test_query():
assert TFoo.objects.all().count() == 0
