This commit is contained in:
@@ -9,11 +9,15 @@ filter to SQL / Widget list filtered with tests - see core-list-graph-datatable
|
|||||||
|
|
||||||
SON OF TAGS
|
SON OF TAGS
|
||||||
//done - How to set GIN index? is it automatic? Do I need to specify it?
|
//done - How to set GIN index? is it automatic? Do I need to specify it?
|
||||||
- Test setting a widget tag collection to see it works with ef core
|
//DONE - Test setting a widget tag collection to see it works with ef core
|
||||||
- Seed widget with predictable tags (Maybe colour names "red", "green", "blue" etc)
|
|
||||||
- Run a tag search test
|
- Run a tag search test
|
||||||
- Unicode tag names as well!!!!
|
//DONE - regular easy tags
|
||||||
- Update tag count / cloud maybe if that's a feature? Or fuck it it can be added any time
|
- Unicode tag names
|
||||||
|
- Remove old tag code, models, schema tables, cleanup and db erase code that refers to them
|
||||||
|
- Add new tag code to all taggable objects
|
||||||
|
- Update seeder to tag objects with known set of tags for test and eval purposes
|
||||||
|
- Seed widget with predictable tags (Maybe colour names "red", "green", "blue" etc)
|
||||||
|
|
||||||
SERVER SCHEMA
|
SERVER SCHEMA
|
||||||
- Add unique constraint to all name columns in all tables in ayschema and run tests (how did I miss that before??)
|
- Add unique constraint to all name columns in all tables in ayschema and run tests (how did I miss that before??)
|
||||||
|
|||||||
@@ -787,8 +787,10 @@ namespace AyaNova.Biz
|
|||||||
//select * from awidget where awidget.tags @> array['blah','blah3'::varchar(255)]
|
//select * from awidget where awidget.tags @> array['blah','blah3'::varchar(255)]
|
||||||
StringBuilder sbTags = new StringBuilder();
|
StringBuilder sbTags = new StringBuilder();
|
||||||
sbTags.Append("@> array[");
|
sbTags.Append("@> array[");
|
||||||
foreach (string s in sTags)
|
List<string> normalizedTags = TagUtil.NormalizeTags(sTags);
|
||||||
|
foreach (string s in normalizedTags)
|
||||||
{
|
{
|
||||||
|
|
||||||
sbTags.Append($"'{s}',");
|
sbTags.Append($"'{s}',");
|
||||||
}
|
}
|
||||||
sb.Append(sbTags.ToString().TrimEnd(','));
|
sb.Append(sbTags.ToString().TrimEnd(','));
|
||||||
|
|||||||
@@ -7304,6 +7304,148 @@ namespace raven_integration
|
|||||||
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public async void UnicodeTagFilterWorks()
|
||||||
|
{
|
||||||
|
|
||||||
|
var TestName = "UnicodeTagFilterWorks";
|
||||||
|
var WidgetRunNameStart = Util.Uniquify(TestName);
|
||||||
|
|
||||||
|
List<long> InclusiveWidgetIdList = new List<long>();
|
||||||
|
List<long> ExclusiveWidgetIdList = new List<long>();
|
||||||
|
|
||||||
|
//CREATE 4 TEST WIDGETS
|
||||||
|
//two inclusive and two not inclusive
|
||||||
|
|
||||||
|
//first inclusive widget
|
||||||
|
dynamic w = new JObject();
|
||||||
|
w.name = Util.Uniquify(WidgetRunNameStart);
|
||||||
|
//Tags
|
||||||
|
dynamic InclusiveTagsArray = new JArray();
|
||||||
|
InclusiveTagsArray.Add("red-tag-test");
|
||||||
|
InclusiveTagsArray.Add("orange-tag-test");
|
||||||
|
InclusiveTagsArray.Add("Ādam Iñtërnâtiônàližætiøn");
|
||||||
|
w.tags = InclusiveTagsArray;
|
||||||
|
|
||||||
|
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
|
||||||
|
|
||||||
|
//second inclusive widget
|
||||||
|
w.name = Util.Uniquify(WidgetRunNameStart);
|
||||||
|
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
|
||||||
|
|
||||||
|
//first exclusive widget
|
||||||
|
w.name = Util.Uniquify(WidgetRunNameStart);
|
||||||
|
//Tags
|
||||||
|
dynamic ExclusiveTagsArray = new JArray();
|
||||||
|
ExclusiveTagsArray.Add("crimson-tag-test");
|
||||||
|
ExclusiveTagsArray.Add("amber-tag-test");
|
||||||
|
ExclusiveTagsArray.Add("saffron-tag-test");
|
||||||
|
ExclusiveTagsArray.Add("emerald-tag-test");
|
||||||
|
ExclusiveTagsArray.Add("azure-tag-test");
|
||||||
|
ExclusiveTagsArray.Add("red-tag-test");
|
||||||
|
ExclusiveTagsArray.Add("blue-tag-test");
|
||||||
|
ExclusiveTagsArray.Add("cobalt-tag-test");
|
||||||
|
ExclusiveTagsArray.Add("magenta-tag-test");
|
||||||
|
w.tags = ExclusiveTagsArray;//Missing green
|
||||||
|
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
|
||||||
|
|
||||||
|
//second exclusive widget
|
||||||
|
w.name = Util.Uniquify(WidgetRunNameStart);
|
||||||
|
w.active = false;
|
||||||
|
|
||||||
|
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), w.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value<long>());
|
||||||
|
|
||||||
|
|
||||||
|
//CREATE FILTER
|
||||||
|
dynamic d = new JObject();
|
||||||
|
d.name = Util.Uniquify(WidgetRunNameStart);
|
||||||
|
// d.ownerId = 1L;
|
||||||
|
d["public"] = true;
|
||||||
|
d.listKey = "widget";
|
||||||
|
|
||||||
|
dynamic dfilter = new JArray();
|
||||||
|
|
||||||
|
//name starts with filter to constrict to widgets that this test block created only
|
||||||
|
dynamic DataFilterNameStart = new JObject();
|
||||||
|
DataFilterNameStart.fld = "name";
|
||||||
|
DataFilterNameStart.op = OpStartsWith;
|
||||||
|
DataFilterNameStart.value = WidgetRunNameStart;
|
||||||
|
dfilter.Add(DataFilterNameStart);
|
||||||
|
|
||||||
|
//active test filter
|
||||||
|
dynamic DataFilterActive = new JObject();
|
||||||
|
DataFilterActive.fld = "tags";
|
||||||
|
DataFilterActive.op = OpEquality;
|
||||||
|
dynamic FilterTagsArray = new JArray();
|
||||||
|
FilterTagsArray.Add("red-tag-test");
|
||||||
|
FilterTagsArray.Add("green-tag-test");//green is the only one missing from the exclusive widget
|
||||||
|
FilterTagsArray.Add("blue-tag-test");
|
||||||
|
DataFilterActive.value = FilterTagsArray;
|
||||||
|
dfilter.Add(DataFilterActive);
|
||||||
|
|
||||||
|
d.filter = dfilter.ToString();//it expects it to be a json string, not actual json
|
||||||
|
|
||||||
|
a = await Util.PostAsync("DataFilter", await Util.GetTokenAsync("BizAdminFull"), d.ToString());
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
|
||||||
|
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
//NOW FETCH WIDGET LIST WITH FILTER
|
||||||
|
a = await Util.GetAsync($"Widget/listwidgets?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
|
Util.ValidateDataReturnResponseOk(a);
|
||||||
|
Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
|
//assert contains at least two records
|
||||||
|
((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
|
||||||
|
var v = ((JArray)a.ObjectResponse["data"]);
|
||||||
|
List<long> IDInResultList = new List<long>();
|
||||||
|
int InclusiveMatchCount = 0;
|
||||||
|
int ExclusiveMatchCount = 0;
|
||||||
|
foreach (JObject o in v)
|
||||||
|
{
|
||||||
|
if (InclusiveWidgetIdList.Contains(o["id"].Value<long>()))
|
||||||
|
InclusiveMatchCount++;
|
||||||
|
if (ExclusiveWidgetIdList.Contains(o["id"].Value<long>()))
|
||||||
|
ExclusiveMatchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
|
||||||
|
ExclusiveMatchCount.Should().Be(0);
|
||||||
|
|
||||||
|
//DELETE WIDGETS
|
||||||
|
foreach (long l in InclusiveWidgetIdList)
|
||||||
|
{
|
||||||
|
a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (long l in ExclusiveWidgetIdList)
|
||||||
|
{
|
||||||
|
a = await Util.DeleteAsync("Widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
}
|
||||||
|
|
||||||
|
//DELETE DATAFILTER
|
||||||
|
a = await Util.DeleteAsync("DataFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
|
||||||
|
Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion tag tests
|
#endregion tag tests
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user