Skip to content

Commit

Permalink
Merge pull request #652 from SavageLearning/feature/selenium-tests-fo…
Browse files Browse the repository at this point in the history
…r-1.14.379

make selenium work for 1.14.379
  • Loading branch information
chaim1221 authored May 22, 2021
2 parents 45fd88f + f40284e commit ed25504
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Machete.Selenium/Integration/HttpClientUtil/HttpClientUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public static async Task SetTenantLookUpCache(string url)
throw new Exception("Cannot retrieve records");
}
var content = await httpResponse.Content.ReadAsStringAsync();
var deserializedContent = JsonConvert.DeserializeObject<JsonObject>(content);
var resultList = _mapper.Map<List<Lookup>>(deserializedContent["data"]);
var deserializedContent = JsonConvert.DeserializeObject<ListResponseModel<LookupVM>>(content);
var resultList = _mapper.Map<List<Lookup>>(deserializedContent.data);
_tenantLookupsCache = new List<Lookup>(resultList);
}
}
Expand Down Expand Up @@ -116,8 +116,8 @@ public static async Task<int> GetWorkAssignment(int id)
var waResponse = await
HttpClient.GetAsync($"{SharedConfig.BaseSeleniumTestUrl}api/workassignments/{id}");
var httpResponseString = await waResponse.Content.ReadAsStringAsync();
var deserializedResponse = JsonConvert.DeserializeObject<JsonObject>(httpResponseString);
var domainWA = _mapper.Map<WorkAssignment>(deserializedResponse["data"]);
var deserializedResponse = JsonConvert.DeserializeObject<ItemResponseModel<WorkAssignmentVM>>(httpResponseString);
var domainWA = _mapper.Map<WorkAssignment>(deserializedResponse.data);
return domainWA.pseudoID ?? 0;
}
}
Expand Down
3 changes: 2 additions & 1 deletion Machete.Selenium/Integration/Views/PersonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text;
using System.Threading.Tasks;
using Machete.Data.Initialize;
using Machete.Domain;
using Machete.Web.Maps;
using Machete.Test.Integration.Fluent;
using Machete.Test.Integration.HttpClientUtil;
Expand Down Expand Up @@ -141,7 +142,7 @@ public void SePerson_signin_sanctioned_worker_fails()
_wkr.dwccardnum = sharedUI.nextAvailableDwccardnum(frb.ToFactory());
var _san = (Web.ViewModel.Event)ViewModelRecords.event1.Clone();
_san.Person = _per;
_san.eventTypeID = MacheteLookups.cache.First(x => x.category == "eventtype" && x.text_EN == "Sanction").ID;
_san.eventTypeID = HttpClientUtil.GetLookup(LCategory.eventtype, "Sanction");
var _act = (Web.ViewModel.Activity)ViewModelRecords.activity.Clone();

//Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static int GetNextMemberID(DbSet<Worker> db)
dateupdated = DateTime.Now,
dateFrom = DateTime.Now,
dateTo = DateTime.Now + TimeSpan.FromDays(30),
eventTypeID = HttpClientUtil.GetLookup(LCategory.eventtype, "Complaint"),
eventTypeID = HttpClientUtil.GetLookup(LCategory.eventtype, "Sanction"),
notes = "Event note"
};

Expand Down
17 changes: 9 additions & 8 deletions Machete.Selenium/Integration/Views/sharedUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ public bool workerCreate(Worker _wkr, string imagepath)

SelectOption(By.Id(prefix + "memberStatusID"), "Active");
SelectOption(By.Id(prefix + "neighborhoodID"), HttpClientUtil.GetFirstLookupInCategory(LCategory.neighborhood).TextEN());
SelectOption(By.Id(prefix + "typeOfWorkID"), @"Day Worker Center");
SelectOption(By.Id(prefix + "typeOfWorkID"), HttpClientUtil.GetFirstLookupInCategory(LCategory.worktype).TextEN());
SelectOption(By.Id(prefix + "englishlevelID"), "1");
SelectOption(By.Id(prefix + "incomeID"), @"Poor (Less than $15,000)");
SelectOption(By.Id(prefix + "incomeID"), HttpClientUtil.GetFirstLookupInCategory(LCategory.income).TextEN());
_d.FindElement(By.Id(prefix + "imagefile")).SendKeys(imagepath);
_d.FindElement(By.Id("createWorkerBtn")).Click();
//
Expand All @@ -194,7 +194,7 @@ public bool workerSanction(Worker _wkr)

WaitThenClickElement(By.Id(_wkr.idPrefix + "memberStatusID"));
Thread.Sleep(1000);
SelectOption(By.Id(_wkr.idPrefix + "memberStatusID"), "Sanctioned");
SelectOption(By.Id(_wkr.idPrefix + "memberStatusID"), HttpClientUtil.GetLookup(LCategory.memberstatus, "Sanctioned").TextEN());
Thread.Sleep(1000);
WaitThenClickElement(By.Id(_wkr.idPrefix + "SaveButton"));
Thread.Sleep(1000);
Expand Down Expand Up @@ -234,10 +234,10 @@ public bool workerValidate(Worker _wkr)

Assert.AreEqual(_wkr.dwccardnum.ToString(), WaitForElement(By.Id(prefix + "dwccardnum")).GetAttribute("value"));
Assert.AreEqual("Active", GetOptionText(WaitForElement(By.Id(prefix + "memberStatusID"))));
Assert.AreEqual("Primary City", GetOptionText(WaitForElement(By.Id(prefix + "neighborhoodID"))));
Assert.AreEqual(@"Day Worker Center", GetOptionText(WaitForElement(By.Id(prefix + "typeOfWorkID"))));
Assert.AreEqual(HttpClientUtil.GetFirstLookupInCategory(LCategory.neighborhood).TextEN(), GetOptionText(WaitForElement(By.Id(prefix + "neighborhoodID"))));
Assert.AreEqual(HttpClientUtil.GetFirstLookupInCategory(LCategory.worktype).TextEN(), GetOptionText(WaitForElement(By.Id(prefix + "typeOfWorkID"))));
Assert.AreEqual("1", GetOptionText(WaitForElement(By.Id(prefix + "englishlevelID"))));
Assert.AreEqual(@"Poor (Less than $15,000)", GetOptionText(WaitForElement(By.Id(prefix + "incomeID"))));
Assert.AreEqual(HttpClientUtil.GetFirstLookupInCategory(LCategory.income).TextEN(), GetOptionText(WaitForElement(By.Id(prefix + "incomeID"))));
return true;
}

Expand Down Expand Up @@ -431,8 +431,9 @@ public bool employerDelete(Employer _emp)
WaitThenClickElement(By.Id("deleteEmployerButton-" + _emp.ID.ToString()));
WaitThenClickElement(By.Id("popup_ok"));

Thread.Sleep(5000);
Thread.Sleep(1000);
WaitForElement(By.Id("employerTable_searchbox")).SendKeys(_emp.name);
Thread.Sleep(1000);
bool result = WaitForElementValue(By.XPath("//table[@id='employerTable']/tbody/tr/td[1]"), "No matching records found");
Assert.IsTrue(result, "Employer not deleted properly");
return true;
Expand Down Expand Up @@ -1076,7 +1077,7 @@ public static string SolutionDirectory()
}
public static int nextAvailableDwccardnum(MacheteContext DB)
{
int attempt = 30000;
int attempt = DB.Workers.Last().dwccardnum;
while (DB.Workers.Any(x => x.dwccardnum == attempt))
{
++attempt;
Expand Down

0 comments on commit ed25504

Please sign in to comment.