mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added InventoryPageTests
This commit is contained in:
144
tests/Berufsschule_HAM.E2ETests/InventoryPageTests.cs
Normal file
144
tests/Berufsschule_HAM.E2ETests/InventoryPageTests.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using Berufsschule_HAM.E2ETests.Helper;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Chrome;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Berufsschule_HAM.E2ETests;
|
||||
|
||||
public class InventoryPageTests : IDisposable
|
||||
{
|
||||
private readonly ChromeDriver _driver;
|
||||
public Uri serverUri;
|
||||
public string serverUrl;
|
||||
public Process serverProcess;
|
||||
|
||||
public InventoryPageTests()
|
||||
{
|
||||
serverUrl = AppHelper.ServerUrl;
|
||||
serverUri = AppHelper.ServerUri;
|
||||
Task<Process> app = AppHelper.StartApp(serverUrl);
|
||||
_driver = AppHelper.GetChromeDriver();
|
||||
serverProcess = app.Result;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InventoryPage_ShouldShowButtons()
|
||||
{
|
||||
AppHelper.Login(_driver);
|
||||
_driver.Navigate().GoToUrl(new Uri(serverUri, "/Home/Inventory"));
|
||||
_driver.FindElement(By.CssSelector("a[href=\"/Home/Assets?CreateModal=true\"]"));
|
||||
_driver.FindElement(By.Id("barcodeInput"));
|
||||
_driver.FindElement(By.Id("enterAssetIdManuallyButton"));
|
||||
_driver.FindElement(By.Id("scanBarcodeButton"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InventoryPage_ShouldShowCompleteViewModal()
|
||||
{
|
||||
AppHelper.Login(_driver);
|
||||
_driver.Navigate().GoToUrl(new Uri(serverUri, "/Home/Inventory"));
|
||||
IWebElement assetIdInputField = _driver.FindElement(By.Id("barcodeInput"));
|
||||
assetIdInputField.SendKeys("1");
|
||||
IWebElement scanBarcode = _driver.FindElement(By.Id("enterAssetIdManuallyButton"));
|
||||
scanBarcode.Click();
|
||||
Thread.Sleep(500);
|
||||
IWebElement viewModal = _driver.FindElement(By.Id("viewAssetModal"));
|
||||
Assert.True(viewModal.Displayed);
|
||||
Assert.True(_driver.FindElement(By.CssSelector("svg[class=\"form-control\"]")).Displayed);
|
||||
Thread.Sleep(500);
|
||||
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailName")).GetAttribute("value") ?? "");
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailLocation")).GetAttribute("value") ?? "");
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailOwner")).GetAttribute("value") ?? "");
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailSerialNumber")).GetAttribute("value") ?? "");
|
||||
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailType")).GetAttribute("value") ?? "");
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailMake")).GetAttribute("value") ?? "");
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailModel")).GetAttribute("value") ?? "");
|
||||
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailPurchaseDate")).GetAttribute("value") ?? "");
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailPurchaseValue")).GetAttribute("value") ?? "");
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailPurchaseAt")).GetAttribute("value") ?? "");
|
||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailPurchaseBy")).GetAttribute("value") ?? "");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InventoryPage_ShouldShowSuccessToastOnInformationCorrect()
|
||||
{
|
||||
AppHelper.Login(_driver);
|
||||
_driver.Navigate().GoToUrl(new Uri(serverUri, "/Home/Inventory"));
|
||||
IWebElement assetIdInputField = _driver.FindElement(By.Id("barcodeInput"));
|
||||
assetIdInputField.SendKeys("1");
|
||||
IWebElement scanBarcode = _driver.FindElement(By.Id("enterAssetIdManuallyButton"));
|
||||
scanBarcode.Click();
|
||||
Thread.Sleep(500);
|
||||
IWebElement viewModal = _driver.FindElement(By.Id("viewAssetModal"));
|
||||
Assert.True(viewModal.Displayed);
|
||||
IWebElement okButton = _driver.FindElement(By.CssSelector("#viewAssetModal button.btn.btn-primary[data-bs-dismiss=\"modal\"]"));
|
||||
okButton.Click();
|
||||
Thread.Sleep(500);
|
||||
IWebElement successToast = _driver.FindElement(By.CssSelector("#toastContainer div.bg-success"));
|
||||
Assert.True(successToast.Displayed);
|
||||
try
|
||||
{
|
||||
IWebElement failToast = _driver.FindElement(By.CssSelector("#toastContainer div.bg-danger"));
|
||||
Assert.False(failToast.Displayed);
|
||||
} catch (Exception) {}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InventoryPage_ShouldShowSuccessToastOnInformationUpdate()
|
||||
{
|
||||
AppHelper.Login(_driver);
|
||||
_driver.Navigate().GoToUrl(new Uri(serverUri, "/Home/Inventory"));
|
||||
IWebElement assetIdInputField = _driver.FindElement(By.Id("barcodeInput"));
|
||||
assetIdInputField.SendKeys("1");
|
||||
IWebElement scanBarcode = _driver.FindElement(By.Id("enterAssetIdManuallyButton"));
|
||||
scanBarcode.Click();
|
||||
Thread.Sleep(500);
|
||||
IWebElement viewModal = _driver.FindElement(By.Id("viewAssetModal"));
|
||||
Assert.True(viewModal.Displayed);
|
||||
IWebElement updateButton = _driver.FindElement(By.CssSelector("#viewAssetModal button.btn.btn-warning[data-bs-dismiss=\"modal\"]"));
|
||||
updateButton.Click();
|
||||
Thread.Sleep(1000);
|
||||
IWebElement okButton = _driver.FindElement(By.CssSelector("#updateAssetModal button.btn.btn-warning[type=\"submit\"]"));
|
||||
okButton.Click();
|
||||
Thread.Sleep(500);
|
||||
IWebElement successToast = _driver.FindElement(By.CssSelector("#toastContainer div.bg-success"));
|
||||
Assert.True(successToast.Displayed);
|
||||
try
|
||||
{
|
||||
IWebElement failToast = _driver.FindElement(By.CssSelector("#toastContainer div.bg-danger"));
|
||||
Assert.False(failToast.Displayed);
|
||||
} catch (Exception) {}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InventoryPage_ShouldLeadToAssetPage()
|
||||
{
|
||||
AppHelper.Login(_driver);
|
||||
_driver.Navigate().GoToUrl(new Uri(serverUri, "/Home/Inventory"));
|
||||
IWebElement link = _driver.FindElement(By.CssSelector("a[href=\"/Home/Assets?CreateModal=true\"]"));
|
||||
link.Click();
|
||||
Thread.Sleep(500);
|
||||
Assert.Contains("/Home/Assets", _driver.Url);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InventoryPage_ShouldShowPrintModal()
|
||||
{
|
||||
AppHelper.Login(_driver);
|
||||
_driver.Navigate().GoToUrl(new Uri(serverUri, "/Home/Inventory"));
|
||||
IWebElement openPrintModalButton = _driver.FindElement(By.Id("openPrintModal"));
|
||||
openPrintModalButton.Click();
|
||||
Thread.Sleep(500);
|
||||
IWebElement printModal = _driver.FindElement(By.Id("printModal"));
|
||||
Assert.True(printModal.Displayed);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_driver.Quit();
|
||||
serverProcess.Kill();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user