Browse Source

Merge remote-tracking branch 'origin/develop' into main

main
Jonathan McCaffrey 4 years ago
parent
commit
d81ce15e29
  1. 2
      Components/Navigation/DesktopNavComponent.razor
  2. 5
      Components/Navigation/DesktopNavLinkComponent.razor
  3. 14
      Components/Utils/Links.cs
  4. BIN
      IGP/Database.db
  5. 20
      IGP/Dialog/SearchDialogComponent.razor
  6. 4
      IGP/Pages/Database/DatabaseSinglePage.razor
  7. 2
      IGP/Pages/Database/Entity/EntityViewComponent.razor
  8. 4
      IGP/Pages/Database/Entity/Parts/EntityHeaderComponent.razor
  9. 4
      IGP/Pages/Database/Entity/Parts/EntityStatsComponent.razor
  10. 4
      IGP/Pages/Database/Parts/EntityFilterComponent.razor
  11. 2
      IGP/wwwroot/generated/AgileTaskModels.json
  12. 2
      IGP/wwwroot/generated/WebPageModels.json
  13. 2
      Model/Website/SearchPointModel.cs
  14. 25
      Services/Website/SearchService.cs
  15. 44
      TestAutomation/Pages/DatabasePage.cs
  16. 30
      TestAutomation/Pages/DatabaseSinglePage.cs
  17. 6
      TestAutomation/Shared/WebsiteSearchDialog.cs
  18. 59
      TestAutomation/TestSearchFeatures.cs
  19. 53
      TestAutomation/Utils/Website.cs
  20. 0
      TestAutomation/_Tests.cs

2
Components/Navigation/DesktopNavComponent.razor

@ -32,7 +32,7 @@
{
<div class="navMenuPosition">
<div class="navMenuContainer">
<DesktopNavSectionComponent Section=webSection/>
<DesktopNavSectionComponent Section="@webSection"/>
</div>
</div>
}

5
Components/Navigation/DesktopNavLinkComponent.razor

@ -1,4 +1,5 @@
@inject INavigationService NavigationService;
@using Components.Utils
@inject INavigationService NavigationService;
@inject NavigationManager NavigationManager;
@if (isOnPage)
@ -11,7 +12,7 @@
}
else
{
<NavLink @onclick="() => { NavigationService.ChangeNavigationState(NavigationStateType.Default); NavigationService.ChangeNavigationSectionId(-1); }" href="@Page.Href" class="desktopNavLink">
<NavLink target="@Links.GetTarget(Page.Href)" @onclick="() => { NavigationService.ChangeNavigationState(NavigationStateType.Default); NavigationService.ChangeNavigationSectionId(-1); }" href="@Page.Href" class="desktopNavLink">
<div class="navName">
@Page.Name
</div>

14
Components/Utils/Links.cs

@ -0,0 +1,14 @@
namespace Components.Utils;
public static class Links
{
public static string GetTarget(string link)
{
if (link.StartsWith("https://"))
{
return "_blank";
}
return "_self";
}
}

BIN
IGP/Database.db

Binary file not shown.

20
IGP/Dialog/SearchDialogComponent.razor

@ -14,7 +14,7 @@
@onclick:stopPropagation="true">
<FormLayoutComponent>
<FormTextComponent OnFocus="OnFocus" Id="search-input-box" Placeholder="Search..." OnInput="SearchChanged"></FormTextComponent>
<FormTextComponent OnFocus="OnFocus" Id="searchInput" Placeholder="Search..." OnInput="SearchChanged"></FormTextComponent>
</FormLayoutComponent>
<div class="searchBox">
@ -33,11 +33,17 @@
<div class="searchContents">
@foreach (var searchPoint in searchPoints)
{
<button class="searchLink @searchPoint.PointType.ToLower()"
label="@searchPoint.Title"
@onclick="() => OnSearch(searchPoint)">
@searchPoint.Title
</button>
<div>
<button class="searchLink @searchPoint.PointType.ToLower()"
label="@searchPoint.Title"
@onclick="() => OnSearch(searchPoint)">
@searchPoint.Title
</button>
@if (!searchPoint.Summary.Trim().Equals(""))
{
<i> - @searchPoint.Summary</i>
}
</div>
}
</div>
</div>
@ -134,7 +140,7 @@
private void FocusTimer(object? sender, ElapsedEventArgs e)
{
jsRuntime.InvokeVoidAsync("SetFocusToElement", "search-input-box");
jsRuntime.InvokeVoidAsync("SetFocusToElement", "searchInput");
StateHasChanged();
}

4
IGP/Pages/Database/DatabaseSinglePage.razor

@ -39,8 +39,8 @@
else if (_entity == null)
{
<PaperComponent>
<div>Invalid entity name entered: @Text</div>
<div>No such entity. Did you mean <b>"Throne"</b>?</div>
<div>Invalid entity name entered: <span id="invalidSearch">@Text</span></div>
<div>No such entity. Did you mean <b>"<span id="validSearch">Throne</span>"</b>?</div>
</PaperComponent>
}

2
IGP/Pages/Database/Entity/EntityViewComponent.razor

@ -2,7 +2,7 @@
{
var isVanguard = Entity.VanguardAdded() != null ? " vanguard" : "";
<div class="entitiesContainer @isVanguard">
<div id="@Entity.EntityType.ToLower()-@Entity.Info().Name.ToLower()" class="entitiesContainer @isVanguard">
<EntityHeaderComponent></EntityHeaderComponent>
<div class="entityPartsContainer">
<EntityVanguardAddedComponent></EntityVanguardAddedComponent>

4
IGP/Pages/Database/Entity/Parts/EntityHeaderComponent.razor

@ -1,7 +1,7 @@
@if (StyleType.Equals("Plain"))
{
<div>
<b>@Entity?.Info().Name</b>
<b id="entityName">@Entity?.Info().Name</b>
@if (Entity?.Info().Descriptive != DescriptiveType.None)
{
<span>, @Entity?.Info().Descriptive.Replace("_", " ")</span>
@ -11,7 +11,7 @@
else
{
<div class="entityHeader">
<div class="entityHeaderText">
<div id="entityName" class="entityHeaderText">
@Entity?.Info().Name
</div>
<div style="font-size:1.4rem;">

4
IGP/Pages/Database/Entity/Parts/EntityStatsComponent.razor

@ -14,7 +14,7 @@
@if (!Vitality.Health.Equals(0))
{
<div>
<b>Health:</b> @Vitality.Health
<b>Health:</b> <span id="entityHealth">@Vitality.Health</span>
</div>
}
@if (!Vitality.Energy.Equals(0))
@ -90,7 +90,7 @@
@if (!Vitality.Health.Equals(0))
{
<div>
<b>Health:</b> @Vitality.Health
<b>Health:</b> <span id="entityHealth">@Vitality.Health</span>
</div>
}
@if (!Vitality.Energy.Equals(0))

4
IGP/Pages/Database/Parts/EntityFilterComponent.razor

@ -46,7 +46,7 @@
<button class="choiceButton @styleClass" @onclick="@(e => OnChangeEntity(choice))">@choice.Replace("_", " ")</button>
}
</div>
<FormTextComponent Label="Search Label" Placeholder="Throne..." OnChange="@(e => EntityFilterService.EnterSearchText(e.Value!.ToString()!))"/>
<FormTextComponent Id="filterName" Label="Filter Name" Placeholder="Throne..." OnChange="@(e => EntityFilterService.EnterSearchText(e.Value!.ToString()!))"/>
</div>
</div>
@ -91,7 +91,7 @@
</FormSelectComponent>
<FormTextComponent Label="Search Label" Placeholder="Throne..." OnChange="OnSearchTextChanged"/>
<FormTextComponent Id="filterName" Label="Filter Name" Placeholder="Throne..." OnChange="OnSearchTextChanged"/>
</FormLayoutComponent>
</div>

2
IGP/wwwroot/generated/AgileTaskModels.json

File diff suppressed because one or more lines are too long

2
IGP/wwwroot/generated/WebPageModels.json

@ -1 +1 @@
[{"Id":1,"WebSectionModelId":2,"Name":"Database","Description":"Database of game information","Href":"database","IsPrivate":"False"},{"Id":2,"WebSectionModelId":1,"Name":"Build Calculator","Description":"Build order calculator for determining army timings","Href":"build-calculator","IsPrivate":"False"},{"Id":3,"WebSectionModelId":1,"Name":"Harass Calculator","Description":"Alloy harassment calculator","Href":"harass-calculator","IsPrivate":"False"},{"Id":4,"WebSectionModelId":1,"Name":"Memory Tester","Description":"Testing memory","Href":"memory-tester","IsPrivate":"False"},{"Id":5,"WebSectionModelId":1,"Name":"Comparion Charts","Description":"Ecnomy charts to compare build orders","Href":"comparison-charts","IsPrivate":"True"},{"Id":6,"WebSectionModelId":2,"Name":"Notes","Description":"General player notes","Href":"notes","IsPrivate":"False"},{"Id":7,"WebSectionModelId":2,"Name":"Key Mapping","Description":"General key mapping info","Href":"keymapping","IsPrivate":"True"},{"Id":8,"WebSectionModelId":4,"Name":"Road Map","Description":"Plans for this website","Href":"roadmap","IsPrivate":"False"},{"Id":9,"WebSectionModelId":4,"Name":"Change Log","Description":"Past updates to the website","Href":"changelog","IsPrivate":"False"},{"Id":10,"WebSectionModelId":4,"Name":"Agile","Description":"Showing agile view of this website","Href":"agile","IsPrivate":"False"},{"Id":11,"WebSectionModelId":4,"Name":"Making Of","Description":"Explaining development details of this website","Href":"makingof","IsPrivate":"False"},{"Id":12,"WebSectionModelId":2,"Name":"Documentation","Description":"Explaining how to use this website","Href":"documentation","IsPrivate":"True"},{"Id":13,"WebSectionModelId":3,"Name":"About","Description":"Answering general questions on the website","Href":"about","IsPrivate":"False"},{"Id":14,"WebSectionModelId":3,"Name":"Contact","Description":"My contact info","Href":"contact","IsPrivate":"False"},{"Id":15,"WebSectionModelId":3,"Name":"Streams","Description":"Stream info","Href":"streams","IsPrivate":"False"},{"Id":16,"WebSectionModelId":4,"Name":"Documentation","Description":"Development information","Href":"docs","IsPrivate":"False"},{"Id":17,"WebSectionModelId":5,"Name":"Permissions","Description":"Permission Settings","Href":"permissions","IsPrivate":"False"},{"Id":18,"WebSectionModelId":5,"Name":"Data Collection","Description":"Data Collection Settings","Href":"data-collection","IsPrivate":"True"},{"Id":19,"WebSectionModelId":5,"Name":"Storage","Description":"Storage Settings","Href":"storage","IsPrivate":"False"},{"Id":20,"WebSectionModelId":1,"Name":"Economy Comparison","Description":"Compare economies","Href":"economy-comparison","IsPrivate":"False"}]
[{"Id":1,"WebSectionModelId":2,"Name":"Database","Description":"Database of game information","Href":"database","IsPrivate":"False"},{"Id":2,"WebSectionModelId":1,"Name":"Build Calculator","Description":"Build order calculator for determining army timings","Href":"build-calculator","IsPrivate":"False"},{"Id":3,"WebSectionModelId":1,"Name":"Harass Calculator","Description":"Alloy harassment calculator","Href":"harass-calculator","IsPrivate":"False"},{"Id":4,"WebSectionModelId":1,"Name":"Memory Tester","Description":"Testing memory","Href":"memory-tester","IsPrivate":"False"},{"Id":5,"WebSectionModelId":1,"Name":"Comparion Charts","Description":"Ecnomy charts to compare build orders","Href":"comparison-charts","IsPrivate":"True"},{"Id":6,"WebSectionModelId":2,"Name":"Notes","Description":"General player notes","Href":"notes","IsPrivate":"False"},{"Id":7,"WebSectionModelId":2,"Name":"Key Mapping","Description":"General key mapping info","Href":"keymapping","IsPrivate":"True"},{"Id":8,"WebSectionModelId":4,"Name":"Milestones","Description":"Link to Milestones on GitHub","Href":"https://github.com/JonathanMcCaffrey/IGP-Fan-Reference/milestones","IsPrivate":"False"},{"Id":9,"WebSectionModelId":4,"Name":"Commits","Description":"Link to Commits on GitHub","Href":"https://github.com/JonathanMcCaffrey/IGP-Fan-Reference/commits/main","IsPrivate":"False"},{"Id":10,"WebSectionModelId":4,"Name":"Tasks","Description":"Link to Tasks on GitHub","Href":"https://github.com/JonathanMcCaffrey/IGP-Fan-Reference/projects/3","IsPrivate":"False"},{"Id":11,"WebSectionModelId":4,"Name":"Code","Description":"Link to Code on GitHub","Href":"https://github.com/JonathanMcCaffrey/IGP-Fan-Reference","IsPrivate":"False"},{"Id":12,"WebSectionModelId":2,"Name":"Documentation","Description":"Explaining how to use this website","Href":"documentation","IsPrivate":"True"},{"Id":13,"WebSectionModelId":3,"Name":"About","Description":"Answering general questions on the website","Href":"about","IsPrivate":"False"},{"Id":14,"WebSectionModelId":3,"Name":"Contact","Description":"My contact info","Href":"contact","IsPrivate":"False"},{"Id":15,"WebSectionModelId":3,"Name":"Streams","Description":"Stream info","Href":"streams","IsPrivate":"False"},{"Id":16,"WebSectionModelId":4,"Name":"Wiki","Description":"Link to Wiki on GitHub","Href":"https://github.com/JonathanMcCaffrey/IGP-Fan-Reference/wiki","IsPrivate":"False"},{"Id":17,"WebSectionModelId":5,"Name":"Permissions","Description":"Permission Settings","Href":"permissions","IsPrivate":"False"},{"Id":18,"WebSectionModelId":5,"Name":"Data Collection","Description":"Data Collection Settings","Href":"data-collection","IsPrivate":"True"},{"Id":19,"WebSectionModelId":5,"Name":"Storage","Description":"Storage Settings","Href":"storage","IsPrivate":"False"},{"Id":20,"WebSectionModelId":1,"Name":"Economy Comparison","Description":"Compare economies","Href":"economy-comparison","IsPrivate":"False"}]

2
Model/Website/SearchPointModel.cs

@ -3,6 +3,8 @@
public class SearchPointModel
{
public string Title { get; set; } = "";
public string Summary { get; set; } = "";
public string Tags { get; set; } = "";
public string PointType { get; set; } = "";
public string Href { get; set; } = "";

25
Services/Website/SearchService.cs

@ -61,6 +61,7 @@ public class SearchService : ISearchService
{
Title = webPage.Name,
PointType = "WebPage",
Summary = $"{webPage.Description}",
Href = webPage.Href
});
@ -72,7 +73,9 @@ public class SearchService : ISearchService
SearchPoints.Add(new SearchPointModel
{
Title = note.Name,
PointType = "Note", Href = note.GetNoteLink()
PointType = "Note",
Href = note.GetNoteLink(),
Summary = note.Description
});
Searches["Notes"].Add(SearchPoints.Last());
@ -81,29 +84,25 @@ public class SearchService : ISearchService
foreach (var entity in DATA.Get().Values)
{
var summary =
entity.Info().Description.Length > 35
? entity.Info().Description.Substring(0, 30).Trim() + "..."
: entity.Info().Description.Length > 0
? entity.Info().Description
: "";
SearchPoints.Add(new SearchPointModel
{
Title = entity.Info().Name,
Tags = $"{entity.EntityType},{entity.Descriptive}",
PointType = "Entity",
Summary = $"{entity.EntityType}, {summary}",
Href = $"database/{entity.Info().Name.ToLower()}"
});
Searches["Entities"].Add(SearchPoints.Last());
}
foreach (var doc in documentationService.DocContentModels)
{
SearchPoints.Add(new SearchPointModel
{
Title = doc.Name,
PointType = "Document", Href = doc.GetDocLink()
});
Searches["Documents"].Add(SearchPoints.Last());
}
isLoaded = true;
NotifyDataChanged();

44
TestAutomation/Pages/DatabasePage.cs

@ -0,0 +1,44 @@
using System.Collections.ObjectModel;
using TestAutomation.Shared;
using TestAutomation.Utils;
namespace TestAutomation.Pages;
public class DatabasePage : BaseElement
{
private IWebElement FilterNameInput => Website.Find("filterName");
private ReadOnlyCollection<IWebElement> EntityNames() =>
Website.FindAll("entityName");
private IWebElement EntityName(string entityType, string entityName) =>
Website.Find("entityName",
$"{entityType.ToLower()}-{entityName.ToLower()}");
public DatabasePage(Website website) : base(website) { }
public DatabasePage FilterName(string name)
{
Website.EnterInput(FilterNameInput, name);
return this;
}
public DatabasePage GetEntityName(string entityType, string entityName, out string result)
{
result = EntityName(entityType, entityName).Text;
return this;
}
public DatabasePage GetEntityName(int index,out string result)
{
result = EntityNames()[index].Text;
return this;
}
}

30
TestAutomation/Pages/DatabaseSinglePage.cs

@ -5,7 +5,37 @@ namespace TestAutomation.Pages;
public class DatabaseSinglePage : BaseElement
{
private IWebElement EntityName => Website.Find("entityName");
private IWebElement EntityHealth => Website.Find("entityHealth");
private IWebElement InvalidSearch => Website.Find("invalidSearch");
private IWebElement ValidSearch => Website.Find("validSearch");
public DatabaseSinglePage(Website website) : base(website) { }
public DatabaseSinglePage GetEntityName(out string result)
{
result = EntityName.Text;
return this;
}
public DatabaseSinglePage GetEntityHealth(out string result)
{
result = EntityHealth.Text;
return this;
}
public DatabaseSinglePage GetInvalidSearch(out string result)
{
result = InvalidSearch.Text;
return this;
}
public DatabaseSinglePage GetValidSearch(out string result)
{
result = ValidSearch.Text;
return this;
}
}

6
TestAutomation/Shared/WebsiteSearchDialog.cs

@ -25,11 +25,9 @@ public class WebsiteSearchDialog : BaseElement
return this;
}
public void SelectSearchEntity(string throne)
public DatabaseSinglePage SelectSearchEntity(string throne)
{
Website.Click(Website.FindButtonWithLabel(throne));
//TODO Add DatabaseSinglePage
//return Website.DatabaseSinglePage;
return Website.DatabaseSinglePage;
}
}

59
TestAutomation/TestSearchFeatures.cs

@ -1,3 +1,5 @@
using TestAutomation.Utils;
namespace TestAutomation;
[TestFixture]
@ -17,7 +19,6 @@ public class TestSearchFeatures : BaseTest
}
[Test]
[Ignore("Not completed")]
public void DesktopSearchForThrone()
{
TestReport.CreateTest();
@ -27,9 +28,59 @@ public class TestSearchFeatures : BaseTest
Website.NavigationBar
.ClickSearchButton()
.Search("Throne")
.SelectSearchEntity("Throne");
// .GetName(out var name);
.SelectSearchEntity("Throne")
.GetEntityName(out var name)
.GetEntityHealth(out var health);
TestReport.CheckPassed(name.Equals("Throne"), new TestMessage(){ Description = "Couldn't find Throne via search."});
TestReport.CheckPassed(!health.Trim().Equals(""), new TestMessage(){ Description = "Throne has no visible health!"});
}
[Test]
public void DesktopFilterForThrone()
{
TestReport.CreateTest();
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database");
Website.DatabasePage
.FilterName("Throne")
.GetEntityName(0, out var name);
TestReport.CheckPassed(name.Equals("Throne"),
new TestMessage(){ Description = "Couldn't find Throne via filter."});
}
[Test]
public void SeeThroneByDefault()
{
TestReport.CreateTest();
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database");
Website.DatabasePage
.GetEntityName( "army", "throne", out var name);
TestReport.CheckPassed(name.Equals("Throne"),
new TestMessage(){ Description = "Couldn't find Throne on the page by default."});
}
[Test]
public void DirectLinkNotThroneFailure()
{
TestReport.CreateTest();
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database/not throne");
Website.DatabaseSinglePage
.GetInvalidSearch(out var invalidSearch)
.GetValidSearch(out var validSearch);
TestReport.CheckPassed(invalidSearch.Equals("not throne"),
new TestMessage(){ Description = "Couldn't find invalid search text on the page."});
TestReport.CheckPassed(validSearch.Equals("Throne"),
new TestMessage(){ Description = "Couldn't find valid search text on the page."});
// TestReport.CheckPassed(name.Equals("Throne"), "Couldn't find Throne via search.");
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/database/not throne");
}
}

53
TestAutomation/Utils/Website.cs

@ -1,4 +1,5 @@
using OpenQA.Selenium.Interactions;
using System.Collections.ObjectModel;
using OpenQA.Selenium.Interactions;
using TestAutomation.Enums;
using TestAutomation.Shared;
@ -12,14 +13,23 @@ public class Website
{
WebDriver = webDriver;
// Pages
HarassCalculatorPage = new HarassCalculatorPage(this);
DatabasePage = new DatabasePage(this);
DatabaseSinglePage = new DatabaseSinglePage(this);
// Navigation
NavigationBar = new NavigationBar(this);
// Dialogs
WebsiteSearchDialog = new WebsiteSearchDialog(this);
}
public IWebDriver WebDriver { get; }
public HarassCalculatorPage HarassCalculatorPage { get; }
public DatabaseSinglePage DatabaseSinglePage { get; }
public DatabasePage DatabasePage { get; }
public NavigationBar NavigationBar { get; }
public WebsiteSearchDialog WebsiteSearchDialog { get; }
@ -39,6 +49,31 @@ public class Website
}
public IWebElement Find(string byId, string withParentId)
{
IWebElement parent;
try
{
parent = WebDriver.FindElement(By.Id(withParentId));
}
catch (Exception e)
{
throw new Exception($"Couldn't find parent {withParentId}. Element does not exist on current page. " +
$"\n\nPerhaps an Id is missing.");
}
try
{
return parent.FindElement(By.Id(byId));
}
catch (Exception e)
{
throw new Exception($"Couldn't find {byId}. Element does not exist on current page. " +
$"\n\nPerhaps an Id is missing.");
}
}
public IWebElement Find(string byId)
{
try
@ -52,11 +87,25 @@ public class Website
}
}
public ReadOnlyCollection<IWebElement> FindAll(string byId)
{
try
{
return WebDriver.FindElements(By.Id(byId));
}
catch (Exception e)
{
throw new Exception($"Couldn't find {byId}. Element does not exist on current page. " +
$"\n\nPerhaps an Id is missing.");
}
}
public IWebElement FindButtonWithLabel(string label)
{
try
{
return WebDriver.FindElement(By.XPath($"button[@label='{label}']"));
return WebDriver.FindElement(By.XPath($"//button[@label='{label}']"));
}
catch (Exception e)
{

0
TestAutomation/Tests.cs → TestAutomation/_Tests.cs

Loading…
Cancel
Save