2020-02-06 02:22:11 +00:00
|
|
|
using System;
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
using OpenQA.Selenium;
|
|
|
|
using OpenQA.Selenium.Support.UI;
|
|
|
|
|
|
|
|
namespace Jackett.IntegrationTests
|
|
|
|
{
|
|
|
|
[TestClass]
|
|
|
|
public class DashboardTests
|
|
|
|
{
|
|
|
|
[TestMethod]
|
|
|
|
public void CheckTitle()
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var pageTitle = _webDriver.Title;
|
2020-02-06 02:22:11 +00:00
|
|
|
Assert.AreEqual("Jackett", pageTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void DefaultPortShown()
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var port = _webDriver.FindElement(By.CssSelector("#jackett-port")).GetAttribute("value");
|
2020-02-06 02:22:11 +00:00
|
|
|
Assert.AreEqual("9117", port);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void IndexerTableIsPresent()
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var table = _webDriver.FindElement(By.CssSelector("#configured-indexer-datatable"));
|
2020-02-06 02:22:11 +00:00
|
|
|
Assert.IsNotNull(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void AddIndexerOpens()
|
|
|
|
{
|
|
|
|
_webDriver.FindElement(By.CssSelector("#jackett-add-indexer")).Click();
|
|
|
|
WaitUntilModalIsDisplayed("#select-indexer-modal h4");
|
2020-02-10 22:16:19 +00:00
|
|
|
var modalHeading = _webDriver.FindElement(By.CssSelector("#select-indexer-modal h4")).Text;
|
2020-02-06 02:22:11 +00:00
|
|
|
Assert.AreEqual("Select an indexer to setup", modalHeading);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void CheckIndexersAreAvailableToAdd()
|
|
|
|
{
|
|
|
|
_webDriver.FindElement(By.CssSelector("#jackett-add-indexer")).Click();
|
|
|
|
WaitUntilModalIsDisplayed("#select-indexer-modal h4");
|
2020-02-10 22:16:19 +00:00
|
|
|
var indexerCount = _webDriver.FindElements(By.CssSelector("#unconfigured-indexer-datatable tbody tr")).Count;
|
2020-02-06 02:22:11 +00:00
|
|
|
Assert.IsTrue(indexerCount > 400);
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
public void ManualSearchOpens()
|
|
|
|
{
|
|
|
|
_webDriver.FindElement(By.CssSelector("#jackett-show-search")).Click();
|
|
|
|
WaitUntilModalIsDisplayed("#select-indexer-modal div.modal-body p");
|
2020-02-10 22:16:19 +00:00
|
|
|
var modalDescription = _webDriver.FindElement(By.CssSelector("#select-indexer-modal div.modal-body p")).Text;
|
2020-02-06 02:22:11 +00:00
|
|
|
Assert.AreEqual("You can search all configured indexers from this screen.", modalDescription);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[ClassInitialize]
|
|
|
|
public static void StartBrowser(TestContext testContext)
|
|
|
|
{
|
|
|
|
_webDriver = WebDriverFactory.CreateFromEnvironmentVariableSettings();
|
|
|
|
_webDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(20);
|
|
|
|
_webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
|
|
|
|
_webDriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(20);
|
|
|
|
}
|
|
|
|
|
|
|
|
[ClassCleanup]
|
|
|
|
public static void StopBrowser()
|
|
|
|
{
|
|
|
|
_webDriver?.Quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestInitialize]
|
|
|
|
public void LoadDashboard()
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var url = "http://localhost:9117/UI/Dashboard";
|
2020-02-06 02:22:11 +00:00
|
|
|
Console.WriteLine($"Url for test: {url}");
|
|
|
|
_webDriver.Navigate().GoToUrl(url);
|
|
|
|
|
2020-02-10 22:16:19 +00:00
|
|
|
var wait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(20));
|
|
|
|
var element = wait.Until(x => x.FindElement(By.CssSelector("#configured-indexer-datatable")));
|
2020-02-06 02:22:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private bool WaitUntilModalIsDisplayed(string cssSelector)
|
|
|
|
{
|
2020-02-10 22:16:19 +00:00
|
|
|
var wait = new WebDriverWait(_webDriver, TimeSpan.FromSeconds(5));
|
2020-02-06 02:22:11 +00:00
|
|
|
var element = wait.Until(condition =>
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var elementToBeDisplayed = _webDriver.FindElement(By.CssSelector(cssSelector));
|
|
|
|
return elementToBeDisplayed.Displayed;
|
|
|
|
}
|
|
|
|
catch (StaleElementReferenceException)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
catch (NoSuchElementException)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static IWebDriver _webDriver;
|
|
|
|
}
|
|
|
|
}
|