mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
62 lines
1.9 KiB
C#
62 lines
1.9 KiB
C#
using Berufsschule_HAM.E2ETests.Helper;
|
|
using OpenQA.Selenium;
|
|
using OpenQA.Selenium.Chrome;
|
|
using System.Diagnostics;
|
|
|
|
namespace Berufsschule_HAM.E2ETests;
|
|
|
|
public class HomePageTests : IDisposable
|
|
{
|
|
private readonly ChromeDriver _driver;
|
|
public Uri serverUri;
|
|
public string serverUrl;
|
|
public Process serverProcess;
|
|
|
|
public HomePageTests()
|
|
{
|
|
serverUrl = "http://localhost:5275";
|
|
serverUri = new(serverUrl);
|
|
Task<Process> app = Helper.AppHelper.StartApp(serverUrl);
|
|
|
|
var options = new ChromeOptions();
|
|
//options.AddArgument("--headless");
|
|
_driver = new ChromeDriver(options);
|
|
serverProcess = app.Result;
|
|
}
|
|
|
|
[Fact]
|
|
public void HomePage_ShouldShowLoginPage()
|
|
{
|
|
_driver.Navigate().GoToUrl(serverUrl);
|
|
IWebElement loginForm = _driver.FindElement(By.CssSelector("form[action=\"/Home/Login\"]"));
|
|
Assert.True(loginForm.Displayed);
|
|
}
|
|
|
|
[Fact]
|
|
public void HomePage_ShouldSucceedLogin()
|
|
{
|
|
AppHelper.Login(_driver, serverUrl);
|
|
Assert.Contains("/Home/Index", _driver.Url);
|
|
}
|
|
|
|
[Fact]
|
|
public void HomePage_ShouldContainButtons()
|
|
{
|
|
_driver.Navigate().GoToUrl(new Uri(serverUri, "/Home/Index"));
|
|
AppHelper.Login(_driver, serverUrl);
|
|
List<IWebElement> buttons = [
|
|
_driver.FindElement(By.CssSelector("a[href=\"/Home/Inventory\"]")),
|
|
_driver.FindElement(By.CssSelector("a[href=\"/Home/Assets\"]")),
|
|
_driver.FindElement(By.CssSelector("a[href=\"/Home/Locations\"]")),
|
|
_driver.FindElement(By.CssSelector("a[href=\"/Home/Users\"]")),
|
|
_driver.FindElement(By.CssSelector("a[href=\"/Home/Groups\"]")),
|
|
];
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_driver.Quit();
|
|
serverProcess.Kill();
|
|
}
|
|
}
|