You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/NzbDrone.Automation.Test/AutomationTest.cs

94 lines
2.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using NLog;
using NLog.Config;
using NLog.Targets;
using NUnit.Framework;
using NzbDrone.Automation.Test.PageModel;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Test.Common;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Remote;
namespace NzbDrone.Automation.Test
{
[TestFixture]
[AutomationTest]
public abstract class AutomationTest
{
private NzbDroneRunner _runner;
protected RemoteWebDriver driver;
public AutomationTest()
{
new StartupContext();
LogManager.Configuration = new LoggingConfiguration();
var consoleTarget = new ConsoleTarget { Layout = "${level}: ${message} ${exception}" };
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Trace, consoleTarget));
}
[OneTimeSetUp]
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
5 years ago
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));
driver.Manage().Window.Size = new System.Drawing.Size(1920, 1080);
_runner = new NzbDroneRunner(LogManager.GetCurrentClassLogger(), null);
_runner.KillAll();
_runner.Start();
driver.Url = "http://localhost:8686";
var page = new PageBase(driver);
page.WaitForNoSpinner();
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
5 years ago
driver.ExecuteScript("window.Lidarr.NameViews = true;");
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]
public void SmokeTestTearDown()
{
_runner.KillAll();
driver.Quit();
}
[TearDown]
public void AutomationTearDown()
{
GetPageErrors().Should().BeEmpty();
}
}
}