Lidarr/src/NzbDrone.Automation.Test/AutomationTest.cs

94 lines
2.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
2013-11-12 03:25:54 +00:00
using System.Linq;
using FluentAssertions;
using NLog;
using NLog.Config;
using NLog.Targets;
using NUnit.Framework;
using NzbDrone.Automation.Test.PageModel;
2013-11-12 03:25:54 +00:00
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
2013-11-12 06:18:57 +00:00
using OpenQA.Selenium.Remote;
2013-11-12 03:25:54 +00:00
namespace NzbDrone.Automation.Test
{
[TestFixture]
[AutomationTest]
public abstract class AutomationTest
{
private NzbDroneRunner _runner;
2013-11-12 06:18:57 +00:00
protected RemoteWebDriver driver;
2013-11-12 03:25:54 +00:00
public AutomationTest()
{
2013-11-26 06:53:36 +00:00
new StartupContext();
2013-11-12 03:25:54 +00:00
LogManager.Configuration = new LoggingConfiguration();
var consoleTarget = new ConsoleTarget { Layout = "${level}: ${message} ${exception}" };
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
2016-12-09 02:06:56 +00:00
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Trace, consoleTarget));
2013-11-12 03:25:54 +00:00
}
[OneTimeSetUp]
2013-11-12 03:25:54 +00:00
public void SmokeTestSetup()
{
var options = new ChromeOptions();
New: Set up CI with Azure Pipelines (#897) * Set up CI with Azure Pipelines [skip ci] * Remove Travis, Build Multiple Environments * Change Task Type to Bash * Checkout submodules * Remove Appveyor Tests, Add Azure Tests * Oops Forget Steps * bad name * test script fixes * add tests to build job * fixup tests * name test runs * fpcalc and artifacts * Try to fix installer * Publish separately * Try publish * Another go at artifacts * Tidy up * Add sentry, assembly info patching and bump version * Only patch one AssemblyInfo; set node version 10 * Try pipeline artifacts again * Tidy up - pipeline artifact seems to be way forward * Fix installer publish * first go at test job seperation * job names and depends/consitions for tests * pusblish single file test artifact * pipeline artifact for test * blitz the pattern filter * windows test jobs * mac tests, checkout on test jobs * try to download build artifact to test job * download and extract artifact * Set LD_LIBRARY_PATH and print some sqlite debug info on mac tests * fixup! tests * integration test fixes * fixup! integration test fixes * fixup! integration test fixes * more fixup * use bash cp * test fixups * mkdir before copy * linux works! add osx integration tests * im tooo tired * coverage attempt * coverage seperate stage * windows paths for integration test * switch coverage to windows where opencover actually works * fix test script * one last go * Simplify installer, try to fix name * Try to parallelize backend and frontend build * Try adding a matrix * Try matrix jobs not stages * Try to fix package step * Remove opencover install * Try to fix tests * coverage fixes * revert build.sh changes * triggers so we don't double build * Publish coverage package so we can debug * try coverage no build, output artifact * use the full pipeline workspace from build job * fix automation tests for new ui * Assorted fix attempts * Another go * MacOS debug * Tidy up, try to fix mac * Fix mac fpcalc, add mac integration tests * Add cross platform automation tests * Fix packages * Try to fix Automation tests * Don't wait on the installer to create standard packages * Fixes * delete logentries reference * run automation tests in headless mode * try install firefox mac * Revert "try install firefox mac" This reverts commit 4684bb19018747cb00407e1d8df64391f44f5183. * test sonarcloud prepare outputs * basic analyze and upload * don't limit fetch depth on analyze * manual scanner do front and backend? * full analyize with tests, coverage * should depend on tests, coverage * no need for condition on coverage * Fix up build numbering * Try to fix sonar * Separate coverage calculation and publication * Try to fix coverage upload
2019-08-13 17:15:59 +00:00
options.AddArguments("--headless");
var service = ChromeDriverService.CreateDefaultService();
// Timeout as windows automation tests seem to take alot longer to get going
driver = new ChromeDriver(service, options, new TimeSpan(0, 3, 0));
2013-11-12 03:25:54 +00:00
driver.Manage().Window.Size = new System.Drawing.Size(1920, 1080);
_runner = new NzbDroneRunner(LogManager.GetCurrentClassLogger(), null);
2013-11-12 03:25:54 +00:00
_runner.KillAll();
_runner.Start();
2017-03-31 18:55:07 +00:00
driver.Url = "http://localhost:8686";
2013-11-12 03:25:54 +00:00
var page = new PageBase(driver);
page.WaitForNoSpinner();
2013-11-12 03:25:54 +00:00
New: Set up CI with Azure Pipelines (#897) * Set up CI with Azure Pipelines [skip ci] * Remove Travis, Build Multiple Environments * Change Task Type to Bash * Checkout submodules * Remove Appveyor Tests, Add Azure Tests * Oops Forget Steps * bad name * test script fixes * add tests to build job * fixup tests * name test runs * fpcalc and artifacts * Try to fix installer * Publish separately * Try publish * Another go at artifacts * Tidy up * Add sentry, assembly info patching and bump version * Only patch one AssemblyInfo; set node version 10 * Try pipeline artifacts again * Tidy up - pipeline artifact seems to be way forward * Fix installer publish * first go at test job seperation * job names and depends/consitions for tests * pusblish single file test artifact * pipeline artifact for test * blitz the pattern filter * windows test jobs * mac tests, checkout on test jobs * try to download build artifact to test job * download and extract artifact * Set LD_LIBRARY_PATH and print some sqlite debug info on mac tests * fixup! tests * integration test fixes * fixup! integration test fixes * fixup! integration test fixes * more fixup * use bash cp * test fixups * mkdir before copy * linux works! add osx integration tests * im tooo tired * coverage attempt * coverage seperate stage * windows paths for integration test * switch coverage to windows where opencover actually works * fix test script * one last go * Simplify installer, try to fix name * Try to parallelize backend and frontend build * Try adding a matrix * Try matrix jobs not stages * Try to fix package step * Remove opencover install * Try to fix tests * coverage fixes * revert build.sh changes * triggers so we don't double build * Publish coverage package so we can debug * try coverage no build, output artifact * use the full pipeline workspace from build job * fix automation tests for new ui * Assorted fix attempts * Another go * MacOS debug * Tidy up, try to fix mac * Fix mac fpcalc, add mac integration tests * Add cross platform automation tests * Fix packages * Try to fix Automation tests * Don't wait on the installer to create standard packages * Fixes * delete logentries reference * run automation tests in headless mode * try install firefox mac * Revert "try install firefox mac" This reverts commit 4684bb19018747cb00407e1d8df64391f44f5183. * test sonarcloud prepare outputs * basic analyze and upload * don't limit fetch depth on analyze * manual scanner do front and backend? * full analyize with tests, coverage * should depend on tests, coverage * no need for condition on coverage * Fix up build numbering * Try to fix sonar * Separate coverage calculation and publication * Try to fix coverage upload
2019-08-13 17:15:59 +00:00
driver.ExecuteScript("window.Lidarr.NameViews = true;");
2015-02-04 19:09:34 +00:00
2013-11-12 03:25:54 +00:00
GetPageErrors().Should().BeEmpty();
}
protected IEnumerable<string> GetPageErrors()
{
return driver.FindElements(By.CssSelector("#errors div"))
.Select(e => e.Text);
}
protected void TakeScreenshot(string name)
{
try
{
Screenshot image = ((ITakesScreenshot)driver).GetScreenshot();
image.SaveAsFile($"./{name}_test_screenshot.png", ScreenshotImageFormat.Png);
}
catch (Exception ex)
{
Console.WriteLine($"Failed to save screenshot {name}, {ex.Message}");
}
}
[OneTimeTearDown]
2013-11-12 03:25:54 +00:00
public void SmokeTestTearDown()
{
_runner.KillAll();
2013-11-12 06:18:57 +00:00
driver.Quit();
2013-11-12 03:25:54 +00:00
}
2013-11-12 06:18:57 +00:00
[TearDown]
public void AutomationTearDown()
2013-11-12 03:25:54 +00:00
{
2013-11-12 06:18:57 +00:00
GetPageErrors().Should().BeEmpty();
2013-11-12 03:25:54 +00:00
}
}
}