24 changed files with 476 additions and 154 deletions
@ -0,0 +1,37 @@ |
|||||||
|
@inject ISearchService SearchService |
||||||
|
@inject NavigationManager NavigationManager |
||||||
|
@inject IJSRuntime JsRuntime |
||||||
|
|
||||||
|
<button id="@Id" class="searchIconButtonContainer" @onclick="ButtonClicked"> |
||||||
|
<div class="searchText"> |
||||||
|
S |
||||||
|
</div> |
||||||
|
</button> |
||||||
|
|
||||||
|
<style> |
||||||
|
.searchIconButtonContainer { |
||||||
|
background-color: var(--primary); |
||||||
|
border: 2px solid var(--primary-border); |
||||||
|
border-radius: 8px; |
||||||
|
font-weight: 800; |
||||||
|
width: 32px; |
||||||
|
padding: 5px; |
||||||
|
display: flex; |
||||||
|
flex-direction: row; |
||||||
|
justify-content: space-between; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
</style> |
||||||
|
|
||||||
|
@code { |
||||||
|
[Parameter] |
||||||
|
public RenderFragment ChildContent { get; set; } = default!; |
||||||
|
|
||||||
|
[Parameter] |
||||||
|
public string Id { get; set; } = default!; |
||||||
|
|
||||||
|
private void ButtonClicked(EventArgs eventArgs) |
||||||
|
{ |
||||||
|
SearchService.Show(); |
||||||
|
} |
||||||
|
} |
||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,51 @@ |
|||||||
|
using TestAutomation.Utils; |
||||||
|
|
||||||
|
namespace TestAutomation; |
||||||
|
|
||||||
|
public enum DeploymentType |
||||||
|
{ |
||||||
|
Dev, |
||||||
|
Local |
||||||
|
} |
||||||
|
|
||||||
|
public class BaseTest |
||||||
|
{ |
||||||
|
protected static readonly DeploymentType DeploymentType = |
||||||
|
Environment.GetEnvironmentVariable("TEST_HOOK") != null |
||||||
|
? DeploymentType.Dev |
||||||
|
: DeploymentType.Local; |
||||||
|
|
||||||
|
protected static readonly string WebsiteUrl = |
||||||
|
DeploymentType.Equals(DeploymentType.Dev) |
||||||
|
? "https://calm-mud-04916b210.1.azurestaticapps.net/" |
||||||
|
: "https://localhost:7234"; |
||||||
|
|
||||||
|
protected static readonly TestReport TestReport = new(); |
||||||
|
|
||||||
|
|
||||||
|
protected static Website WebsiteInstance = default!; |
||||||
|
|
||||||
|
protected static Website Website |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
if (WebsiteInstance == null) |
||||||
|
{ |
||||||
|
var options = new FirefoxOptions(); |
||||||
|
|
||||||
|
options.AcceptInsecureCertificates = true; |
||||||
|
// options.AddArgument("--headless"); |
||||||
|
options.AddArgument("--ignore-certificate-errors"); |
||||||
|
options.AddArgument("--start-maximized"); |
||||||
|
options.AddArgument("--test-type"); |
||||||
|
options.AddArgument("--allow-running-insecure-content"); |
||||||
|
|
||||||
|
IWebDriver webDriver = new FirefoxDriver(Environment.CurrentDirectory, options); |
||||||
|
|
||||||
|
WebsiteInstance = new Website(webDriver); |
||||||
|
} |
||||||
|
|
||||||
|
return WebsiteInstance; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
namespace TestAutomation.Enums; |
||||||
|
|
||||||
|
public enum ScreenType |
||||||
|
{ |
||||||
|
Desktop, |
||||||
|
Tablet, |
||||||
|
Mobile |
||||||
|
} |
||||||
@ -1,11 +0,0 @@ |
|||||||
using TestAutomation.Utils; |
|
||||||
|
|
||||||
namespace TestAutomation.Pages; |
|
||||||
|
|
||||||
public class BasePage { |
|
||||||
public Website website; |
|
||||||
|
|
||||||
public BasePage(Website website) { |
|
||||||
this.website = website; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,11 @@ |
|||||||
|
using TestAutomation.Shared; |
||||||
|
using TestAutomation.Utils; |
||||||
|
|
||||||
|
namespace TestAutomation.Pages; |
||||||
|
|
||||||
|
public class DatabaseSinglePage : BaseElement |
||||||
|
{ |
||||||
|
public DatabaseSinglePage(Website website) : base(website) { } |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -1,71 +1,86 @@ |
|||||||
using TestAutomation.Utils; |
using TestAutomation.Shared; |
||||||
|
using TestAutomation.Utils; |
||||||
|
|
||||||
namespace TestAutomation.Pages; |
namespace TestAutomation.Pages; |
||||||
|
|
||||||
public class HarassCalculatorPage : BasePage { |
public class HarassCalculatorPage : BaseElement |
||||||
public HarassCalculatorPage(Website website) : base(website) { } |
{ |
||||||
private IWebElement NumberOfWorkersLostToHarass => website.Find("numberOfWorkersLostToHarass"); |
public HarassCalculatorPage(Website website) : base(website) |
||||||
private IWebElement NumberOfTownHallsExisting => website.Find("numberOfTownHallsExisting"); |
{ |
||||||
private IList<IWebElement> OnTownHallTravelTimes => website.FindChildren("numberOfTownHallTravelTimes", "input"); |
} |
||||||
private int TotalAlloyHarassment => website.FindInt("totalAlloyHarassment"); |
|
||||||
private int WorkerReplacementCost => website.FindInt("workerReplacementCost"); |
private IWebElement NumberOfWorkersLostToHarass => Website.Find("numberOfWorkersLostToHarass"); |
||||||
private int DelayedMiningCost => website.FindInt("delayedMiningCost"); |
private IWebElement NumberOfTownHallsExisting => Website.Find("numberOfTownHallsExisting"); |
||||||
private int AverageTravelTime => website.FindInt("getAverageTravelTime"); |
private IList<IWebElement> OnTownHallTravelTimes => Website.FindChildren("numberOfTownHallTravelTimes", "input"); |
||||||
|
private int TotalAlloyHarassment => Website.FindInt("totalAlloyHarassment"); |
||||||
|
private int WorkerReplacementCost => Website.FindInt("workerReplacementCost"); |
||||||
|
private int DelayedMiningCost => Website.FindInt("delayedMiningCost"); |
||||||
|
private int AverageTravelTime => Website.FindInt("getAverageTravelTime"); |
||||||
|
|
||||||
private int ExampleTotalAlloyLoss => website.FindInt("exampleTotalAlloyLoss"); |
private int ExampleTotalAlloyLoss => Website.FindInt("exampleTotalAlloyLoss"); |
||||||
private int ExampleWorkerCost => website.FindInt("exampleWorkerCost"); |
private int ExampleWorkerCost => Website.FindInt("exampleWorkerCost"); |
||||||
private int ExampleMiningTimeCost => website.FindInt("exampleMiningTimeCost"); |
private int ExampleMiningTimeCost => Website.FindInt("exampleMiningTimeCost"); |
||||||
private int ExampleTotalAlloyLossDifference => website.FindInt("exampleTotalAlloyLossDifference"); |
private int ExampleTotalAlloyLossDifference => Website.FindInt("exampleTotalAlloyLossDifference"); |
||||||
private int ExampleTotalAlloyLossAccurate => website.FindInt("exampleTotalAlloyLossAccurate"); |
private int ExampleTotalAlloyLossAccurate => Website.FindInt("exampleTotalAlloyLossAccurate"); |
||||||
private int ExampleTotalAlloyLossAccurateDifference => website.FindInt("exampleTotalAlloyLossAccurateDifference"); |
private int ExampleTotalAlloyLossAccurateDifference => Website.FindInt("exampleTotalAlloyLossAccurateDifference"); |
||||||
|
|
||||||
public HarassCalculatorPage SetWorkersLostToHarass(int number) { |
public HarassCalculatorPage SetWorkersLostToHarass(int number) |
||||||
website.EnterInput(NumberOfWorkersLostToHarass, number); |
{ |
||||||
|
Website.EnterInput(NumberOfWorkersLostToHarass, number); |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public HarassCalculatorPage SetNumberOfTownHallsExisting(int number) { |
public HarassCalculatorPage SetNumberOfTownHallsExisting(int number) |
||||||
website.EnterInput(NumberOfTownHallsExisting, number); |
{ |
||||||
|
Website.EnterInput(NumberOfTownHallsExisting, number); |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public HarassCalculatorPage SetTownHallTravelTime(int forTownHall, int number) { |
public HarassCalculatorPage SetTownHallTravelTime(int forTownHall, int number) |
||||||
website.EnterInput(OnTownHallTravelTimes[forTownHall], number); |
{ |
||||||
|
Website.EnterInput(OnTownHallTravelTimes[forTownHall], number); |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public HarassCalculatorPage GetTotalAlloyHarassment(out int result) { |
public HarassCalculatorPage GetTotalAlloyHarassment(out int result) |
||||||
|
{ |
||||||
result = TotalAlloyHarassment; |
result = TotalAlloyHarassment; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLoss(out int result) { |
public HarassCalculatorPage GetExampleTotalAlloyLoss(out int result) |
||||||
|
{ |
||||||
result = ExampleTotalAlloyLoss; |
result = ExampleTotalAlloyLoss; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public HarassCalculatorPage GetExampleWorkerCost(out int result) { |
public HarassCalculatorPage GetExampleWorkerCost(out int result) |
||||||
|
{ |
||||||
result = ExampleWorkerCost; |
result = ExampleWorkerCost; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public HarassCalculatorPage GetExampleMiningTimeCost(out int result) { |
public HarassCalculatorPage GetExampleMiningTimeCost(out int result) |
||||||
|
{ |
||||||
result = ExampleMiningTimeCost; |
result = ExampleMiningTimeCost; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossAccurate(out int result) { |
public HarassCalculatorPage GetExampleTotalAlloyLossAccurate(out int result) |
||||||
|
{ |
||||||
result = ExampleTotalAlloyLossAccurate; |
result = ExampleTotalAlloyLossAccurate; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossDifference(out int result) { |
public HarassCalculatorPage GetExampleTotalAlloyLossDifference(out int result) |
||||||
|
{ |
||||||
result = ExampleTotalAlloyLossDifference; |
result = ExampleTotalAlloyLossDifference; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|
||||||
public HarassCalculatorPage GetExampleTotalAlloyLossAccurateDifference(out int result) { |
public HarassCalculatorPage GetExampleTotalAlloyLossAccurateDifference(out int result) |
||||||
|
{ |
||||||
result = ExampleTotalAlloyLossAccurateDifference; |
result = ExampleTotalAlloyLossAccurateDifference; |
||||||
return this; |
return this; |
||||||
} |
} |
||||||
|
|||||||
@ -0,0 +1,13 @@ |
|||||||
|
using TestAutomation.Utils; |
||||||
|
|
||||||
|
namespace TestAutomation.Shared; |
||||||
|
|
||||||
|
public class BaseElement |
||||||
|
{ |
||||||
|
protected readonly Website Website; |
||||||
|
|
||||||
|
protected BaseElement(Website website) |
||||||
|
{ |
||||||
|
Website = website; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
using TestAutomation.Enums; |
||||||
|
using TestAutomation.Utils; |
||||||
|
|
||||||
|
namespace TestAutomation.Shared; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class NavigationBar : BaseElement |
||||||
|
{ |
||||||
|
public NavigationBar(Website website) : base(website) { } |
||||||
|
private IWebElement HomeLink => Website.FindScreenSpecific("homeLink"); |
||||||
|
private IWebElement SearchButton => Website.FindScreenSpecific("searchButton"); |
||||||
|
|
||||||
|
public NavigationBar ClickHomeLink() |
||||||
|
{ |
||||||
|
Website.Click(HomeLink); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public WebsiteSearchDialog ClickSearchButton() |
||||||
|
{ |
||||||
|
Website.Click(SearchButton); |
||||||
|
return Website.WebsiteSearchDialog; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
using Discord.Rest; |
||||||
|
using TestAutomation.Utils; |
||||||
|
|
||||||
|
namespace TestAutomation.Shared; |
||||||
|
|
||||||
|
public class WebsiteSearchDialog : BaseElement |
||||||
|
{ |
||||||
|
public WebsiteSearchDialog(Website website) : base(website) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public IWebElement SearchBackground => Website.Find("searchBackground"); |
||||||
|
|
||||||
|
public IWebElement SearchInput => Website.Find("searchInput"); |
||||||
|
|
||||||
|
public NavigationBar CloseDialog() |
||||||
|
{ |
||||||
|
Website.ClickTopLeft(); |
||||||
|
return Website.NavigationBar; |
||||||
|
} |
||||||
|
|
||||||
|
public WebsiteSearchDialog Search(string throne) |
||||||
|
{ |
||||||
|
Website.EnterInput(SearchInput, throne); |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public void SelectSearchEntity(string throne) |
||||||
|
{ |
||||||
|
Website.Click(Website.FindButtonWithLabel(throne)); |
||||||
|
//TODO Add DatabaseSinglePage |
||||||
|
//return Website.DatabaseSinglePage; |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
namespace TestAutomation; |
||||||
|
|
||||||
|
[TestFixture] |
||||||
|
public class TestSearchFeatures : BaseTest |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void DesktopOpenCloseSearchDialog() |
||||||
|
{ |
||||||
|
TestReport.CreateTest(); |
||||||
|
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/"); |
||||||
|
|
||||||
|
Website.NavigationBar |
||||||
|
.ClickSearchButton() |
||||||
|
.CloseDialog() |
||||||
|
.ClickHomeLink(); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
[Ignore("Not completed")] |
||||||
|
public void DesktopSearchForThrone() |
||||||
|
{ |
||||||
|
TestReport.CreateTest(); |
||||||
|
|
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl + "/"); |
||||||
|
|
||||||
|
Website.NavigationBar |
||||||
|
.ClickSearchButton() |
||||||
|
.Search("Throne") |
||||||
|
.SelectSearchEntity("Throne"); |
||||||
|
// .GetName(out var name); |
||||||
|
|
||||||
|
// TestReport.CheckPassed(name.Equals("Throne"), "Couldn't find Throne via search."); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
using System.Text; |
||||||
|
using Newtonsoft.Json; |
||||||
|
|
||||||
|
namespace TestAutomation; |
||||||
|
|
||||||
|
[SetUpFixture] |
||||||
|
public class Tests : BaseTest |
||||||
|
{ |
||||||
|
[OneTimeSetUp] |
||||||
|
public void Setup() |
||||||
|
{ |
||||||
|
Website.WebDriver.Navigate().GoToUrl(WebsiteUrl); |
||||||
|
Website.WebDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15); |
||||||
|
} |
||||||
|
|
||||||
|
[OneTimeTearDown] |
||||||
|
public void TearDown() |
||||||
|
{ |
||||||
|
HttpClient HttpClient = new(); |
||||||
|
|
||||||
|
Website.WebDriver.Quit(); |
||||||
|
|
||||||
|
var message = new |
||||||
|
{ |
||||||
|
content = "Test Report " + DateTime.Now.ToString("dd/MM/yyyy"), |
||||||
|
embeds = TestReport.GetMessages() |
||||||
|
}; |
||||||
|
|
||||||
|
var content = new StringContent(JsonConvert.SerializeObject(message), Encoding.UTF8, "application/json"); |
||||||
|
|
||||||
|
if (Environment.GetEnvironmentVariable("TEST_HOOK") == null) return; |
||||||
|
|
||||||
|
HttpClient.PostAsync(Environment.GetEnvironmentVariable("TEST_HOOK"), content).Wait(); |
||||||
|
} |
||||||
|
} |
||||||
@ -1,6 +1,7 @@ |
|||||||
namespace TestAutomation.Utils; |
namespace TestAutomation.Utils; |
||||||
|
|
||||||
public class Test { |
public class Test |
||||||
|
{ |
||||||
public string Name { get; set; } = "Name..."; |
public string Name { get; set; } = "Name..."; |
||||||
public bool Result { get; set; } = true; |
public bool Result { get; set; } = true; |
||||||
public IList<TestMessage> Messages { get; set; } = new List<TestMessage>(); |
public IList<TestMessage> Messages { get; set; } = new List<TestMessage>(); |
||||||
|
|||||||
@ -1,11 +1,13 @@ |
|||||||
namespace TestAutomation.Utils; |
namespace TestAutomation.Utils; |
||||||
|
|
||||||
public class TestMessage { |
public class TestMessage |
||||||
|
{ |
||||||
public string Title { get; set; } = "Name..."; |
public string Title { get; set; } = "Name..."; |
||||||
public string Description { get; set; } = ""; |
public string Description { get; set; } = ""; |
||||||
public string Color { get; set; } = "FFFFFF"; |
public string Color { get; set; } = "FFFFFF"; |
||||||
|
|
||||||
public static TestMessage CreateFailedMessage(string description) { |
public static TestMessage CreateFailedMessage(string description) |
||||||
|
{ |
||||||
return new TestMessage { Title = "Check Failed", Description = description, Color = "FF0000" }; |
return new TestMessage { Title = "Check Failed", Description = description, Color = "FF0000" }; |
||||||
} |
} |
||||||
} |
} |
||||||
Loading…
Reference in new issue