This commit is contained in:
2026-02-25 10:26:52 -08:00
parent 36b875f79f
commit 49812b65a4

View File

@@ -210,35 +210,25 @@ namespace raven_integration
[Fact]
public async Task SearchAndExtractShouldWork()
{
const string TEST_SEARCH_PHRASE = "cast goose";
const string TEST_SEARCH_PHRASE = "*cast* goose";
//CREATE A PROJECT
dynamic D = new JObject();
D.name = Util.Uniquify("Wildcard contains search test PROJECT");
var projectName = Util.Uniquify("Wildcard contains search test PROJECT");
var dateStarted = DateTime.Now.ToString("o");
var payload = $$"""
{"id":0,"concurrency":0,"name":"{{projectName}}","active":true,"notes":"This record will match in notes: broadcasting to the goose","wiki":null,"customFields":"{}","tags":["blue","zebra"],"dateStarted":"{{dateStarted}}","dateCompleted":null,"projectOverseerId":null,"accountNumber":"TestAccountNumber"}
""";
D.dollarAmount = 1.11m;
D.active = true;
D.usertype = 1;
D.notes = "This record will match in notes: broadcasting to the goose";
ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), payload);
Util.ValidateDataReturnResponseOk(a);
long MatchProjectInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
//CREATE FIRST TEST USER WITH PHRASE IN NAME
D = new JObject();
D.name = Util.Uniquify("Wildcard contains search NAME goose elcastro Test User");
D.notes = "This user has the match in it's name";
var userName = Util.Uniquify("Wildcard contains search NAME goose elcastro Test User");
payload = $$"""
{"id":0,"concurrency":0,"active":true,"allowLogin":true,"name":"{{userName}}","roles":8,"userType":2,"employeeNumber":null,"notes":"This user has the match in it's name","customerId":null,"headOfficeId":null,"vendorId":null,"wiki":null,"customFields":"{}","tags":[],"lastLogin":null,"password":"{{userName}}","login":"{{userName}}"}
""";
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
D.customFields = Util.UserRequiredCustomFieldsJsonString();
a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a);
long MatchUserInNameId = a.ObjectResponse["data"]["id"].Value<long>();
@@ -258,7 +248,7 @@ namespace raven_integration
//Turn the list into an array of id's
var v = ((JArray)a.ObjectResponse["data"]["searchResults"]);
List<long> MatchingIdList = new List<long>();
List<long> MatchingIdList = [];
foreach (JObject j in v)
{
MatchingIdList.Add(j["id"].Value<long>());
@@ -271,10 +261,10 @@ namespace raven_integration
//Ensure excerpt works and contains the search phrase
// /Search/Info/2/1?phrase=we&max=200
a = await Util.GetAsync($"search/Info/2/{MatchProjectInNotesId}?phrase={TEST_SEARCH_PHRASE}&max=200", await Util.GetTokenAsync("superuser", "l3tm3in"));
a = await Util.GetAsync($"search/Info/25/{MatchProjectInNotesId}?phrase={TEST_SEARCH_PHRASE}&max=200", await Util.GetTokenAsync("superuser", "l3tm3in"));
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(" ")[1]);
a.ObjectResponse["data"].Value<string>().Should().Contain("broadcasting to the goose");
a.ObjectResponse["data"].Value<string>().Should().Contain("PROJECT");
}//eot