This commit is contained in:
2026-02-25 09:33:05 -08:00
parent 7bbf0df7b9
commit 2f0681353a

View File

@@ -1,9 +1,6 @@
using System;
using Xunit; using Xunit;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Linq;
using FluentAssertions; using FluentAssertions;
using System.Collections.Generic;
namespace raven_integration namespace raven_integration
{ {
@@ -11,98 +8,69 @@ namespace raven_integration
public class SearchOps public class SearchOps
{ {
//NOTE: this test failed one time for no apparent reason but then was ok afterwards
[Fact] [Fact]
public async Task PhraseOnlySearchShouldReturnCorrectResultsInOrder() public async Task PhraseOnlySearchShouldReturnCorrectResultsInOrder()
{ {
const string TEST_SEARCH_PHRASE = "simple dogs";
//CREATE A WIDGET //CREATE A PROJECT phrase in notes
dynamic D = new JObject(); var projectName = Util.Uniquify("search notes test project should match");
D.name = Util.Uniquify("search NOTES Test WIDGET"); var dateStarted = DateTime.Now.ToString("o");
D.customFields = Util.WidgetRequiredCustomFieldsJsonString(); var payload = $$"""
D.dollarAmount = 1.11m; {"id":0,"concurrency":0,"name":"{{projectName}}","active":true,"notes":"This record will match in notes: The quick brown and simple fox jumped over the six lazy dogs!","wiki":null,"customFields":"{}","tags":["blue","zebra"],"dateStarted":"{{dateStarted}}","dateCompleted":null,"projectOverseerId":null,"accountNumber":"TestAccountNumber"}
D.active = true; """;
D.usertype = 1;
D.notes = "This record will match in notes: The quick brown and simple fox jumped over the six lazy dogs!";
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), payload);
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchWidgetInNotesId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchProjectInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE FIRST TEST USER WITH PHRASE IN NAME //CREATE FIRST TEST USER WITH PHRASE IN NAME
D = new JObject(); var userName = Util.Uniquify("search NAME DOGS simple Test User");
D.name = Util.Uniquify("search NAME DOGS simple Test User"); payload = $$"""
D.customFields = Util.WidgetRequiredCustomFieldsJsonString(); {"id":0,"concurrency":0,"active":true,"allowLogin":true,"name":"{{userName}}","roles":8,"userType":2,"employeeNumber":null,"notes":null,"customerId":null,"headOfficeId":null,"vendorId":null,"wiki":null,"customFields":"{}","tags":[],"lastLogin":null,"password":"{{userName}}","login":"{{userName}}"}
D.notes = "This user has the match in it's name"; """;
a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), payload);
D.active = true;
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.usertype = 1;
D.userType = 2;// not service type user
a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchUserInNameId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchUserInNameId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE A SECOND TEST USER WITH PHRASE IN NOTES //CREATE A SECOND TEST USER WITH PHRASE IN NOTES
D = new JObject(); userName = Util.Uniquify("search NOTES Test User");
D.name = Util.Uniquify("search NOTES Test User"); payload = $$"""
D.customFields = Util.WidgetRequiredCustomFieldsJsonString(); {"id":0,"concurrency":0,"active":true,"allowLogin":true,"name":"{{userName}}","roles":8,"userType":2,"employeeNumber":null,"notes":"This user has the match simple dogs in its notes","customerId":null,"headOfficeId":null,"vendorId":null,"wiki":null,"customFields":"{}","tags":[],"lastLogin":null,"password":"{{userName}}","login":"{{userName}}"}
D.notes = "This user has the match simple dogs in its notes"; """;
a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), payload);
D.active = true;
D.login = Util.Uniquify("LOGIN");
D.password = Util.Uniquify("PASSWORD");
D.usertype = 1;
D.userType = 2;// not service type user
a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchUserInNotesId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchUserInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE A SECOND WIDGET //CREATE A SECOND PROJECT
D = new JObject(); projectName = Util.Uniquify("search NAME simple as in dogs Test PROJECT");
D.name = Util.Uniquify("search NAME simple as in dogs Test WIDGET"); payload = $$"""
D.customFields = Util.WidgetRequiredCustomFieldsJsonString(); {"id":0,"concurrency":0,"name":"{{projectName}}","active":true,"notes":"This Project matches in name","wiki":null,"customFields":"{}","tags":["blue","zebra"],"dateStarted":"{{dateStarted}}","dateCompleted":null,"projectOverseerId":null,"accountNumber":"TestAccountNumber"}
D.dollarAmount = 1.11m; """;
D.active = true; a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), payload);
D.usertype = 1;
D.notes = "This Widget matches in name";
a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchWidgetInNameId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchProjectInNameId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE A THIRD WIDGET //CREATE A THIRD PROJECT
D = new JObject(); projectName = Util.Uniquify("XXX NO MATCH search simple THIRD Test PROJECT");
D.name = Util.Uniquify("search NO-MATCH THIRD Test WIDGET"); payload = $$"""
D.customFields = Util.WidgetRequiredCustomFieldsJsonString(); {"id":0,"concurrency":0,"name":"{{projectName}}","active":true,"notes":"This Project should not be returned in the search as it only contains a single keyword in the name not both","wiki":null,"customFields":"{}","tags":["blue","zebra"],"dateStarted":"{{dateStarted}}","dateCompleted":null,"projectOverseerId":null,"accountNumber":"TestAccountNumber"}
D.dollarAmount = 1.11m; """;
D.active = true; a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), payload);
D.usertype = 1;
D.notes = "This Widget should not be returned in the search as it only contains a single keyword in the name not both";
a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchNothingWidgetId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchNothingProjectId = a.ObjectResponse["data"]["id"].Value<long>();
//Now see if can find those objects with a phrase search //Now see if can find those objects with a phrase search
dynamic SearchParameters = new JObject(); dynamic SearchParameters = new JObject();
SearchParameters.phrase = "simple dogs";
SearchParameters.phrase = TEST_SEARCH_PHRASE;
SearchParameters.typeOnly = 0;//no type SearchParameters.typeOnly = 0;//no type
SearchParameters.maxResults = 0; SearchParameters.maxResults = 0;
a = await Util.PostAsync("search", await Util.GetTokenAsync("superuser", "l3tm3in"), SearchParameters.ToString()); a = await Util.PostAsync("search", await Util.GetTokenAsync("superuser", "l3tm3in"), SearchParameters.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
//Now validate the return list //Now validate the return list
((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().BeGreaterOrEqualTo(3); ((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().BeGreaterOrEqualTo(4);
//Turn the list into an array of id's //Turn the list into an array of id's
var v = ((JArray)a.ObjectResponse["data"]["searchResults"]); var v = ((JArray)a.ObjectResponse["data"]["searchResults"]);
@@ -113,24 +81,16 @@ namespace raven_integration
} }
//Ensure the expected items are returned //Ensure the expected items are returned
MatchingIdList.Should().Contain(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId"); MatchingIdList.Should().Contain(MatchProjectInNotesId, "ShouldContainMatchProjectInNotesId");
MatchingIdList.Should().Contain(MatchWidgetInNameId, "ShouldContainMatchWidgetInNameId"); MatchingIdList.Should().Contain(MatchProjectInNameId, "ShouldContainMatchProjectInNameId");
MatchingIdList.Should().Contain(MatchUserInNotesId, "ShouldContainMatchUserInNotesId"); MatchingIdList.Should().Contain(MatchUserInNotesId, "ShouldContainMatchUserInNotesId");
MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId"); MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId");
MatchingIdList.Should().NotContain(MatchNothingWidgetId, "ShouldNotContainMatchNothingWidgetId"); MatchingIdList.Should().NotContain(MatchNothingProjectId, "ShouldNotContainMatchNothingProjectId");
//Assert the order (roughly, this is kind of a waste of time, either the code is sorting or not, it's not going to change)
//first item must be a widget
a.ObjectResponse["data"]["searchResults"][0]["type"].Value<int>().Should().Be(2);
//final item must be a user
a.ObjectResponse["data"]["searchResults"][MatchingIdList.Count - 1]["type"].Value<int>().Should().Be(3);
//FULL BODY SEARCH RIGHTS //FULL BODY SEARCH RIGHTS
//First up test a full record search returns no results due to insufficient rights //First up test a full record search returns no results due to insufficient rights
//even though the record exists //even though the record exists
//Just re-run the above search exactly but with a no rights to full User or Widget role instead //Just re-run the above search exactly but with a no rights to full User or Project role instead
//Only BizAdmin* roles can read a full user record //Only BizAdmin* roles can read a full user record
//This search should return zero items //This search should return zero items
@@ -150,19 +110,19 @@ namespace raven_integration
{ {
const string TEST_SEARCH_PHRASE = "hap* goose"; const string TEST_SEARCH_PHRASE = "hap* goose";
//CREATE A WIDGET //CREATE A PROJECT
dynamic D = new JObject(); dynamic D = new JObject();
D.name = Util.Uniquify("Wildcard startswith search test WIDGET"); D.name = Util.Uniquify("Wildcard startswith search test PROJECT");
D.customFields = Util.WidgetRequiredCustomFieldsJsonString();
D.dollarAmount = 1.11m; D.dollarAmount = 1.11m;
D.active = true; D.active = true;
D.usertype = 1; D.usertype = 1;
D.notes = "This record will match in notes: The quick brown and hapless goose"; D.notes = "This record will match in notes: The quick brown and hapless goose";
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchWidgetInNotesId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchProjectInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE FIRST TEST USER WITH PHRASE IN NAME //CREATE FIRST TEST USER WITH PHRASE IN NAME
D = new JObject(); D = new JObject();
@@ -204,7 +164,7 @@ namespace raven_integration
} }
//Ensure the expected items are returned //Ensure the expected items are returned
MatchingIdList.Should().Contain(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId"); MatchingIdList.Should().Contain(MatchProjectInNotesId, "ShouldContainMatchProjectInNotesId");
MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId"); MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId");
}//eot }//eot
@@ -215,18 +175,18 @@ namespace raven_integration
{ {
const string TEST_SEARCH_PHRASE = "goose *act"; const string TEST_SEARCH_PHRASE = "goose *act";
//CREATE A WIDGET //CREATE A PROJECT
dynamic D = new JObject(); dynamic D = new JObject();
D.name = Util.Uniquify("Wildcard endswith search test WIDGET"); D.name = Util.Uniquify("Wildcard endswith search test PROJECT");
D.customFields = Util.WidgetRequiredCustomFieldsJsonString();
D.dollarAmount = 1.11m; D.dollarAmount = 1.11m;
D.active = true; D.active = true;
D.usertype = 1; D.usertype = 1;
D.notes = "This record will match in notes: react to the goose"; D.notes = "This record will match in notes: react to the goose";
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchWidgetInNotesId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchProjectInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE FIRST TEST USER WITH PHRASE IN NAME //CREATE FIRST TEST USER WITH PHRASE IN NAME
D = new JObject(); D = new JObject();
@@ -268,7 +228,7 @@ namespace raven_integration
} }
//Ensure the expected items are returned //Ensure the expected items are returned
MatchingIdList.Should().Contain(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId"); MatchingIdList.Should().Contain(MatchProjectInNotesId, "ShouldContainMatchProjectInNotesId");
MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId"); MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId");
}//eot }//eot
@@ -281,18 +241,18 @@ namespace raven_integration
{ {
const string TEST_SEARCH_PHRASE = "cast goose"; const string TEST_SEARCH_PHRASE = "cast goose";
//CREATE A WIDGET //CREATE A PROJECT
dynamic D = new JObject(); dynamic D = new JObject();
D.name = Util.Uniquify("Wildcard contains search test WIDGET"); D.name = Util.Uniquify("Wildcard contains search test PROJECT");
D.customFields = Util.WidgetRequiredCustomFieldsJsonString();
D.dollarAmount = 1.11m; D.dollarAmount = 1.11m;
D.active = true; D.active = true;
D.usertype = 1; D.usertype = 1;
D.notes = "This record will match in notes: broadcasting to the goose"; D.notes = "This record will match in notes: broadcasting to the goose";
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchWidgetInNotesId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchProjectInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE FIRST TEST USER WITH PHRASE IN NAME //CREATE FIRST TEST USER WITH PHRASE IN NAME
D = new JObject(); D = new JObject();
@@ -334,13 +294,13 @@ namespace raven_integration
} }
//Ensure the expected items are returned //Ensure the expected items are returned
MatchingIdList.Should().Contain(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId"); MatchingIdList.Should().Contain(MatchProjectInNotesId, "ShouldContainMatchProjectInNotesId");
MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId"); MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId");
//Ensure excerpt works and contains the search phrase //Ensure excerpt works and contains the search phrase
// /Search/Info/2/1?phrase=we&max=200 // /Search/Info/2/1?phrase=we&max=200
a = await Util.GetAsync($"search/Info/2/{MatchWidgetInNotesId}?phrase={TEST_SEARCH_PHRASE}&max=200", await Util.GetTokenAsync("superuser", "l3tm3in")); a = await Util.GetAsync($"search/Info/2/{MatchProjectInNotesId}?phrase={TEST_SEARCH_PHRASE}&max=200", await Util.GetTokenAsync("superuser", "l3tm3in"));
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
a.ObjectResponse["data"].Value<string>().Should().Contain(TEST_SEARCH_PHRASE.Split(" ")[0]); a.ObjectResponse["data"].Value<string>().Should().Contain(TEST_SEARCH_PHRASE.Split(" ")[0]);
a.ObjectResponse["data"].Value<string>().Should().Contain(TEST_SEARCH_PHRASE.Split(" ")[1]); a.ObjectResponse["data"].Value<string>().Should().Contain(TEST_SEARCH_PHRASE.Split(" ")[1]);
@@ -368,36 +328,36 @@ namespace raven_integration
//w.tags = InclusiveTagsArray; //w.tags = InclusiveTagsArray;
//CREATE A WIDGET //CREATE A PROJECT
dynamic D = new JObject(); dynamic D = new JObject();
D.name = Util.Uniquify("TAG search test WIDGET TAG AND PHRASE"); D.name = Util.Uniquify("TAG search test PROJECT TAG AND PHRASE");
D.customFields = Util.WidgetRequiredCustomFieldsJsonString();
D.dollarAmount = 1.11m; D.dollarAmount = 1.11m;
D.active = true; D.active = true;
D.usertype = 1; D.usertype = 1;
D.notes = "This record will match in notes and tag: elementary my dear aardvark"; D.notes = "This record will match in notes and tag: elementary my dear aardvark";
D.tags = TagsArray; D.tags = TagsArray;
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchWidgetInNotesId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchProjectInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE A WIDGET WITH TAG BUT NOT SEARCH PHRASE //CREATE A PROJECT WITH TAG BUT NOT SEARCH PHRASE
D = new JObject(); D = new JObject();
D.name = Util.Uniquify("TAG search test WIDGET TAG ONLY"); D.name = Util.Uniquify("TAG search test PROJECT TAG ONLY");
D.customFields = Util.WidgetRequiredCustomFieldsJsonString();
D.dollarAmount = 1.11m; D.dollarAmount = 1.11m;
D.active = true; D.active = true;
D.usertype = 1; D.usertype = 1;
D.notes = "This record will match in tag but no search phrase"; D.notes = "This record will match in tag but no search phrase";
D.tags = TagsArray; D.tags = TagsArray;
a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long NoPhraseMatchWidgetInTagId = a.ObjectResponse["data"]["id"].Value<long>(); long NoPhraseMatchProjectInTagId = a.ObjectResponse["data"]["id"].Value<long>();
@@ -441,9 +401,9 @@ namespace raven_integration
} }
//Ensure the expected items are returned //Ensure the expected items are returned
MatchingIdList.Should().Contain(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId"); MatchingIdList.Should().Contain(MatchProjectInNotesId, "ShouldContainMatchProjectInNotesId");
MatchingIdList.Should().NotContain(MatchUserInNameId, "ShouldNotContainMatchUserInNameId"); MatchingIdList.Should().NotContain(MatchUserInNameId, "ShouldNotContainMatchUserInNameId");
MatchingIdList.Should().NotContain(NoPhraseMatchWidgetInTagId, "ShouldNotContainNoPhraseMatchWidgetInTagId"); MatchingIdList.Should().NotContain(NoPhraseMatchProjectInTagId, "ShouldNotContainNoPhraseMatchProjectInTagId");
}//eot }//eot
@@ -530,22 +490,22 @@ namespace raven_integration
[Fact] [Fact]
public async Task SearchForSerialFieldShouldWork() public async Task SearchForSerialFieldShouldWork()
{ {
//CREATE A WIDGET //CREATE A PROJECT
dynamic D = new JObject(); dynamic D = new JObject();
D.name = Util.Uniquify("Serial search test WIDGET"); D.name = Util.Uniquify("Serial search test PROJECT");
D.customFields = Util.WidgetRequiredCustomFieldsJsonString();
D.dollarAmount = 1.11m; D.dollarAmount = 1.11m;
D.active = true; D.active = true;
D.usertype = 1; D.usertype = 1;
D.notes = "Test for serial number search"; D.notes = "Test for serial number search";
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchWidgetInSerialId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchProjectInSerialId = a.ObjectResponse["data"]["id"].Value<long>();
var MatchWidgetSerial = a.ObjectResponse["data"]["serial"].Value<uint>(); var MatchProjectSerial = a.ObjectResponse["data"]["serial"].Value<uint>();
//TODO: get this from the return object //TODO: get this from the return object
string SerialSearch = MatchWidgetSerial.ToString(); ; string SerialSearch = MatchProjectSerial.ToString(); ;
//Now see if can find those objects with a phrase search //Now see if can find those objects with a phrase search
@@ -569,7 +529,7 @@ namespace raven_integration
} }
//Ensure the expected items are returned //Ensure the expected items are returned
MatchingIdList.Should().Contain(MatchWidgetInSerialId, "ShouldContainMatchWidgetInSerialId"); MatchingIdList.Should().Contain(MatchProjectInSerialId, "ShouldContainMatchProjectInSerialId");
@@ -588,7 +548,7 @@ namespace raven_integration
[xUnit.net 00:00:21.49] raven_integration.SearchOps.CustomFieldSearchShouldWork [FAIL] [xUnit.net 00:00:21.49] raven_integration.SearchOps.CustomFieldSearchShouldWork [FAIL]
X raven_integration.SearchOps.CustomFieldSearchShouldWork [1s 84ms] X raven_integration.SearchOps.CustomFieldSearchShouldWork [1s 84ms]
Error Message: Error Message:
Expected MatchingIdList {109274L, 109095L, 108919L, 108740L, 108558L, 108382L, 108201L, 108021L, 107842L, 107663L, 107487L, 107305L, 107126L, 106947L, 106768L, 106589L, 106413L, 106233L, 106052L, 105873L, 105692L, 105510L, 105341L, 105157L, 104978L, 104799L, 104620L, 104441L, 104262L, 104084L, 103906L, 103725L, .468 more.} to contain 195378L because ShouldContainMatchingCustomFieldWidgetId. Expected MatchingIdList {109274L, 109095L, 108919L, 108740L, 108558L, 108382L, 108201L, 108021L, 107842L, 107663L, 107487L, 107305L, 107126L, 106947L, 106768L, 106589L, 106413L, 106233L, 106052L, 105873L, 105692L, 105510L, 105341L, 105157L, 104978L, 104799L, 104620L, 104441L, 104262L, 104084L, 103906L, 103725L, .468 more.} to contain 195378L because ShouldContainMatchingCustomFieldProjectId.
Stack Trace: Stack Trace:
at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message) at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message)
at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message) at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)
@@ -610,18 +570,18 @@ Likely fix is to force order to most recent or simply to delete after test so th
dCustomField.c4 = "true"; dCustomField.c4 = "true";
dCustomField.c5 = "23.45"; dCustomField.c5 = "23.45";
//CREATE A WIDGET //CREATE A PROJECT
dynamic D = new JObject(); dynamic D = new JObject();
D.name = Util.Uniquify("CUSTOMFIELD search test WIDGET"); D.name = Util.Uniquify("CUSTOMFIELD search test PROJECT");
D.customFields = dCustomField.ToString(); D.customFields = dCustomField.ToString();
D.dollarAmount = 1.11m; D.dollarAmount = 1.11m;
D.active = true; D.active = true;
D.usertype = 1; D.usertype = 1;
D.notes = "This record will match in custom field"; D.notes = "This record will match in custom field";
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long MatchingWidgetId = a.ObjectResponse["data"]["id"].Value<long>(); long MatchingProjectId = a.ObjectResponse["data"]["id"].Value<long>();
//Now see if can find this object with a phrase search //Now see if can find this object with a phrase search
@@ -646,11 +606,11 @@ Likely fix is to force order to most recent or simply to delete after test so th
} }
//Ensure the expected items are returned //Ensure the expected items are returned
MatchingIdList.Should().Contain(MatchingWidgetId, "ShouldContainMatchingCustomFieldWidgetId"); MatchingIdList.Should().Contain(MatchingProjectId, "ShouldContainMatchingCustomFieldProjectId");
//Now delete the newly created one so the list doesn't build up and prevent this test from working in big runs... //Now delete the newly created one so the list doesn't build up and prevent this test from working in big runs...
//DELETE //DELETE
ApiResponse DELETETestResponse = await Util.DeleteAsync("widget/" + MatchingWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in")); ApiResponse DELETETestResponse = await Util.DeleteAsync("project/" + MatchingProjectId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
Util.ValidateHTTPStatusCode(DELETETestResponse, 204); Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
@@ -664,18 +624,18 @@ Likely fix is to force order to most recent or simply to delete after test so th
{ {
string TEST_SEARCH_PHRASE = Util.Uniquify("qqwweerrttyy"); string TEST_SEARCH_PHRASE = Util.Uniquify("qqwweerrttyy");
//CREATE A WIDGET //CREATE A PROJECT
dynamic d = new JObject(); dynamic d = new JObject();
d.name = Util.Uniquify("Wildcard endswith search test WIDGET"); d.name = Util.Uniquify("Wildcard endswith search test PROJECT");
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
d.dollarAmount = 1.11m; d.dollarAmount = 1.11m;
d.active = true; d.active = true;
d.usertype = 1; d.usertype = 1;
d.notes = $"This record will match in notes: {TEST_SEARCH_PHRASE} there"; d.notes = $"This record will match in notes: {TEST_SEARCH_PHRASE} there";
ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString()); ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
Util.ValidateDataReturnResponseOk(a); Util.ValidateDataReturnResponseOk(a);
long WidgetId = (long)a.ObjectResponse["data"]["id"]; long ProjectId = (long)a.ObjectResponse["data"]["id"];
//Now see if can find with a phrase search //Now see if can find with a phrase search
dynamic SearchParameters = new JObject(); dynamic SearchParameters = new JObject();
@@ -687,8 +647,8 @@ Likely fix is to force order to most recent or simply to delete after test so th
//Now validate the return list (should be only one as it's super unique) //Now validate the return list (should be only one as it's super unique)
((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().Be(1); ((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().Be(1);
//Now delete the widget and re-run the search //Now delete the project and re-run the search
a = await Util.DeleteAsync("widget/" + WidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in")); a = await Util.DeleteAsync("project/" + ProjectId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
Util.ValidateHTTPStatusCode(a, 204); Util.ValidateHTTPStatusCode(a, 204);
a = await Util.PostAsync("search", await Util.GetTokenAsync("superuser", "l3tm3in"), SearchParameters.ToString()); a = await Util.PostAsync("search", await Util.GetTokenAsync("superuser", "l3tm3in"), SearchParameters.ToString());