public async Task <IActionResult> GetComparedTests(long id) { var folder = await _foldersProvider.GetActiveFolder(); if (User.Identity.IsAuthenticated) { var user = await _usersProvider.GetUser(User.GetUserId()); folder = user.SelectedFolder; } var runs = await _runsProvider.GetTestsForComparison(id, folder); var testInfo = await _runsProvider.GetAllTestsInfo(); var model = new List <ViewTest>(); foreach (var item in runs) { var info = testInfo.FirstOrDefault(p => p.TestName == item?.Name + ".py"); if (info == null) { continue; } var newTest = new ViewTest(item) { SuitName = info.SuiteName, Author = info.AuthorLogin }; model.Add(newTest); } return(PartialView("ResultsExplorer/_ResultsComparisonPartial", model)); }
// GET public async Task <IActionResult> Index(int id, string suit, int filterOption, string query, string userFilter, int page = 1) { var filter = (TestExplorerFilter)filterOption; if (string.IsNullOrEmpty(suit)) { suit = "ALL"; } var run = await _runsProvider.GetRun(id); var testsInfo = await _runsProvider.GetAllTestsInfo(); var testInfos = testsInfo as TestInfo[] ?? testsInfo.ToArray(); var testInfoTests = testInfos.Select(p => p.TestName).ToList(); testsInfo = testInfos.ToList(); var model = new TestsExplorerViewModel { Environment = run.Environment, ReportTime = run.ReportTime, RunId = run.Id }; foreach (var test in run.Tests) { var testSuite = testsInfo.FirstOrDefault(p => p.TestName == test.Name + ".py"); if (testSuite == null) { continue; } { var exists = model.TestSets.FirstOrDefault(p => p.Name == testSuite.SuiteName); if (exists != null) { //add new tests to existing suite var newTest = new ViewTest(test, testInfos); exists.Tests.Add(newTest); } else { var newTestSuite = new TestSet { Name = testSuite.SuiteName, Id = testSuite.Id }; var newTest = new ViewTest(test, testInfos); newTestSuite.Tests.Add(newTest); model.TestSets.Add(newTestSuite); } } } foreach (var testSet in model.TestSets) { testSet.FailedTests = testSet.Tests.Count(p => p.Failed); } //display all tests var allTestSet = new TestSet { Name = "ALL", FailedTests = run.Tests.Count(p => p.Steps.ToList().Exists(z => !z.IsPassed)), Id = -1, }; allTestSet.Tests = new List <ViewTest>(); run.Tests.ToList().ForEach(p => allTestSet.Tests.Add(new ViewTest(p, testInfos) )); model.TestSets.Add(allTestSet); var notAssignedTests = run.Tests.Where(p => !testInfoTests.Contains(p.Name + ".py")).ToList(); //Display not assigned var notAssignedTestSet = new TestSet { Name = "NOT ASSIGNED", FailedTests = 0, Id = 0, Tests = new List <ViewTest>() }; notAssignedTests.ToList().ForEach(p => allTestSet.Tests.Add(new ViewTest(p, testInfos) )); model.TestSets.Add(notAssignedTestSet); model.FilteredTestSets = model.TestSets.Clone(); if (!string.IsNullOrEmpty(suit)) { model.SelectedSuite = suit; model.FilteredTestSets = model.FilteredTestSets.Where(p => p.Name == suit).ToList(); } switch (filter) { case TestExplorerFilter.Total: break; case TestExplorerFilter.Passed: foreach (var testSets in model.FilteredTestSets) { testSets.Tests = testSets.Tests.Where(p => p.Status == TestStatus.Passed).ToList(); } break; case TestExplorerFilter.Failed: foreach (var testSets in model.FilteredTestSets) { testSets.Tests = testSets.Tests.Where(p => p.Status == TestStatus.Failed).ToList(); } break; case TestExplorerFilter.Errors: foreach (var testSets in model.FilteredTestSets) { testSets.Tests = testSets.Tests.Where(p => p.Status == TestStatus.Error).ToList(); } break; default: throw new ArgumentOutOfRangeException(); } model.TestExplorerFilter = filter; model.Query = query; if (!string.IsNullOrEmpty(query)) { foreach (var testSet in model.FilteredTestSets) { if (query.Contains("!")) { testSet.Tests = testSet.Tests.Where(p => p.Name.Equals(query.Replace("!", ""))).ToList(); } else { testSet.Tests = testSet.Tests.Where(p => p.Name.Contains(query)).ToList(); } } } model.Users = testInfos.Select(p => p.AuthorLogin).Distinct(); if (userFilter != null) { model.UserFilter = userFilter; foreach (var testSet in model.FilteredTestSets) { testSet.Tests = testSet.Tests.Where(p => p.Author == userFilter).ToList(); } } model.Pager = new Pager(model.FilteredTestSets.SelectMany(p => p.Tests).Count(), page); return(View(model)); }
public async Task <IActionResult> Index() { var folder = await _foldersProvider.GetActiveFolder(); SystemUser user = null; if (HttpContext.User.Identity.IsAuthenticated) { user = await _usersProvider.GetUser(HttpContext.User.GetUserId()); folder = user.SelectedFolder; } var platforms = new string[] { "osx", "win7", "win", "linux" }; var runs = folder.Runs; var model = new DashboardDataModel { FailedTests = new List <FailedTestPerPlatform>(), Users = await _usersProvider.GetAllUsers() }; foreach (var platform in platforms) { model.LatestStats.Add(await _runsProvider.GetLatestRunForEnvironment(platform, folder.Id)); } foreach (var run in runs.GroupBy(p => p.Environment).OrderBy(p => p.Key)) { var runner = run.OrderByDescending(p => p.ReportTime).FirstOrDefault(); model.LatestResults.Add(runner); var allTestsInfo = await _runsProvider.GetAllTestsInfo(); foreach (var test in runner.FailedTests) { var testInfo = allTestsInfo.FirstOrDefault(p => p.TestName == test + ".py"); var failedTest = new FailedTestPerPlatform { LinuxRunId = runs.Where(p => p.Environment == "linux").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id, OsxRunId = runs.Where(p => p.Environment == "osx").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id, Win10RunId = runs.Where(p => p.Environment == "win").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id, Win7RunId = runs.Where(p => p.Environment == "win7").OrderByDescending(p => p.ReportTime).FirstOrDefault()?.Id, TestId = runs.OrderByDescending(p => p.ReportTime).Where(p => p.Tests != null).SelectMany(z => z.Tests).FirstOrDefault(q => q.Name == test)?.Id, Test = test, Author = testInfo?.AuthorLogin, Suit = testInfo?.SuiteName, CurrentUser = user, Linux = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "linux")?.FailedTests.ToList().Exists(p => p == test), Windows7 = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "win7")?.FailedTests.ToList().Exists(p => p == test), Osx = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "osx")?.FailedTests.ToList().Exists(p => p == test), Windows10 = runs.OrderByDescending(p => p.ReportTime).FirstOrDefault(p => p.Environment == "win")?.FailedTests.ToList().Exists(p => p == test) }; model.FailedTests.Add(failedTest); } } model.FailedTests = model.FailedTests.Distinct().ToList(); //Historic data var groupedEnvironment = runs.GroupBy(p => p.Environment); model.HistoricData = new List <HistoricData>(); foreach (var grouping in groupedEnvironment) { var newHistoricData = new HistoricData { Platform = grouping.Key }; var groupedDate = grouping.GroupBy(p => p.ReportTime.Date).OrderBy(p => p.Key); newHistoricData.HistoricDataItems = new List <HistoricDataItems>(); foreach (var dt in groupedDate) { var item = dt.OrderByDescending(p => p.Total).FirstOrDefault(); if (item != null) { newHistoricData.HistoricDataItems.Add(new HistoricDataItems { DateLabel = dt.Key.ToShortDateString(), Blocked = item.Blocked, Failed = item.Failed, Passed = item.Passed, Skipped = item.Skipped, Total = item.Total }); } } model.HistoricData.Add(newHistoricData); } return(View(model)); }