From f66b444009494ba30b14f2d4a96ead57c1d36a47 Mon Sep 17 00:00:00 2001 From: "Steven T. Cramer" Date: Sun, 24 Mar 2024 10:17:43 +0700 Subject: [PATCH 1/2] Remove TestCafe and Selenium Tests Going to go with Playwright and can't maintain all. --- .../Tests/EndToEnd.Selenium.Tests/BaseTest.cs | 49 -------- .../CounterPageTests.cs | 60 ---------- .../ExecutionSideTests.cs | 56 --------- .../FetchDataPageTests.cs | 39 ------- .../Infrastructure/AspNetEnvironment.cs | 8 -- .../Infrastructure/BrowserFixture.cs | 52 --------- .../ClientLoaderTestConfiguration.cs | 10 -- .../Infrastructure/DirectoryService.cs | 29 ----- .../Infrastructure/GitService.cs | 36 ------ .../Infrastructure/SeleniumStandalone.cs | 47 -------- .../Infrastructure/ServerFixture.cs | 110 ------------------ .../Infrastructure/TestingConvention.cs | 73 ------------ .../Infrastructure/WaitAndAssert.cs | 70 ----------- .../EndToEnd.Selenium.Tests/JsInteropTests.cs | 72 ------------ ...Warp.Blazor.EndToEnd.Selenium.Tests.csproj | 13 --- .../Tests/EndToEnd.TestCafe.Tests/.npmrc | 1 - .../EndToEnd.TestCafe.Tests.csproj | 11 -- .../Tests/EndToEnd.TestCafe.Tests/README.md | 13 --- .../EndToEnd.TestCafe.Tests/package.json | 10 -- .../tests/ChangeRouteShould.ts | 17 --- .../tests/CounterShouldCount.ts | 31 ----- .../tests/ExecutionSide.ts | 83 ------------- .../tests/WeatherForecastPage.ts | 11 -- .../util/LocalStorage.ts | 18 --- 24 files changed, 919 deletions(-) delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/BaseTest.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/CounterPageTests.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/ExecutionSideTests.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/FetchDataPageTests.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/AspNetEnvironment.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/BrowserFixture.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/ClientLoaderTestConfiguration.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/DirectoryService.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/GitService.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/SeleniumStandalone.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/ServerFixture.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/TestingConvention.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/WaitAndAssert.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/JsInteropTests.cs delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/TimeWarp.Blazor.EndToEnd.Selenium.Tests.csproj delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/.npmrc delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/EndToEnd.TestCafe.Tests.csproj delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/README.md delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/package.json delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/ChangeRouteShould.ts delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/CounterShouldCount.ts delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/ExecutionSide.ts delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/WeatherForecastPage.ts delete mode 100644 Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/util/LocalStorage.ts diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/BaseTest.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/BaseTest.cs deleted file mode 100644 index 04f397e1..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/BaseTest.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests -{ - using OpenQA.Selenium; - using OpenQA.Selenium.Support.UI; - using System; - using TimeWarp.Architecture.EndToEnd.Tests.Infrastructure; - - public abstract class BaseTest - { - protected readonly IJavaScriptExecutor JavaScriptExecutor; - private readonly ServerFixture ServerFixture; - protected TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(15); - protected IWebDriver WebDriver { get; } - - public BaseTest(IWebDriver aWebDriver, ServerFixture aServerFixture) - { - WebDriver = aWebDriver; - ServerFixture = aServerFixture; - JavaScriptExecutor = WebDriver as IJavaScriptExecutor; - } - - protected void Navigate(string aRelativeUrl, bool aReload = true) - { - var absoluteUrl = new Uri(ServerFixture.RootUri, aRelativeUrl); - - if (!aReload && string.Equals(WebDriver.Url, absoluteUrl.AbsoluteUri, StringComparison.Ordinal)) - return; - - WebDriver.Navigate().GoToUrl("about:blank"); - WebDriver.Navigate().GoToUrl(absoluteUrl); - } - - protected void WaitUntilClientCached() - { - new WebDriverWait(WebDriver, Timeout) - .Until(aWebDriver => - JavaScriptExecutor.ExecuteScript("return window.localStorage.getItem('clientApplication');") != null - ); - } - - protected void WaitUntilLoaded() - { - new WebDriverWait(WebDriver, Timeout) - .Until(aWebDriver => - JavaScriptExecutor.ExecuteScript("return window.jsonRequestHandler;") != null - ); - } - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/CounterPageTests.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/CounterPageTests.cs deleted file mode 100644 index 8ee24e30..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/CounterPageTests.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests -{ - using OpenQA.Selenium; - using Shouldly; - using TimeWarp.Architecture.EndToEnd.Tests.Infrastructure; - using static Infrastructure.WaitAndAssert; - - public class CounterPageTests : BaseTest - { - /// - /// - /// - /// - /// - /// Is a dependency as the server needs to be running - /// but is not referenced otherwise thus the injected item is NOT stored - /// - public CounterPageTests(IWebDriver aWebDriver, ServerFixture aServerFixture) - : base(aWebDriver, aServerFixture) - { - aServerFixture.Environment = AspNetEnvironment.Development; - aServerFixture.CreateHostBuilderDelegate = Server.Program.CreateHostBuilder; - - Navigate("/", aReload: true); - WaitUntilLoaded(); - } - - public void HasCounterPage() - { - // Navigate to "Counter" - WebDriver.FindElement(By.LinkText("Counter")).Click(); - - WaitAndAssertEqual - ( - aExpected: "Counter Page", - aActual: () => WebDriver.FindElement(By.TagName("h1")).Text - ); - - // Observe the initial value is 3 - IWebElement countDisplayElement1 = WebDriver.FindElement(By.CssSelector("[data-qa='Counter1'] p")); - countDisplayElement1.Text.ShouldBe("Current count: 3"); - - IWebElement countDisplayElement2 = WebDriver.FindElement(By.CssSelector("[data-qa='Counter2'] p")); - countDisplayElement2.Text.ShouldBe("Current count: 3"); - - // Click the button; see it increment by 5 - IWebElement button1 = WebDriver.FindElement(By.CssSelector("[data-qa='Counter1'] button")); - IWebElement button2 = WebDriver.FindElement(By.CssSelector("[data-qa='Counter2'] button")); - button1.Click(); - WaitAndAssertEqual("Current count: 8", () => countDisplayElement1.Text); - WaitAndAssertEqual("Current count: 8", () => countDisplayElement2.Text); - button2.Click(); - WaitAndAssertEqual("Current count: 13", () => countDisplayElement1.Text); - WaitAndAssertEqual("Current count: 13", () => countDisplayElement2.Text); - button1.Click(); - WaitAndAssertEqual("Current count: 18", () => countDisplayElement1.Text); - WaitAndAssertEqual("Current count: 18", () => countDisplayElement2.Text); - } - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/ExecutionSideTests.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/ExecutionSideTests.cs deleted file mode 100644 index b6e56cc1..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/ExecutionSideTests.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests -{ - using OpenQA.Selenium; - using TimeWarp.Architecture.EndToEnd.Tests.Infrastructure; - using static Infrastructure.WaitAndAssert; - - public class ExecutionSideTests : BaseTest - { - /// - /// - /// - /// - /// - /// Is a dependency as the server needs to be running - /// but is not referenced otherwise thus the injected item is NOT stored - /// - public ExecutionSideTests(IWebDriver aWebDriver, ServerFixture aServerFixture) - : base(aWebDriver, aServerFixture) - { - aServerFixture.Environment = AspNetEnvironment.Development; - aServerFixture.CreateHostBuilderDelegate = Server.Program.CreateHostBuilder; - - Navigate("/", aReload: true); - WaitUntilLoaded(); - } - - public void LoadsClientSide() - { - WaitUntilClientCached(); - JavaScriptExecutor.ExecuteScript("window.localStorage.setItem('executionSide','client');"); - - Navigate("/", aReload: true); - WaitUntilClientCached(); - - WaitAndAssertEqual - ( - aExpected: "Client Side", - aActual: () => WebDriver.FindElement(By.CssSelector("[data-qa='BlazorLocation']")).Text - ); - } - - public void LoadsServerSide() - { - JavaScriptExecutor.ExecuteScript("window.localStorage.setItem('executionSide','server');"); - - Navigate("/", aReload: true); - WaitUntilLoaded(); - - WaitAndAssertEqual - ( - aExpected: "Server Side", - aActual: () => WebDriver.FindElement(By.CssSelector("[data-qa='BlazorLocation']")).Text - ); - } - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/FetchDataPageTests.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/FetchDataPageTests.cs deleted file mode 100644 index eeeca4ec..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/FetchDataPageTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests -{ - using OpenQA.Selenium; - using TimeWarp.Architecture.EndToEnd.Tests.Infrastructure; - using static Infrastructure.WaitAndAssert; - - public class FetchDataPageTests : BaseTest - { - /// - /// Test that the FetchData link is available from the root page - /// The page loads - /// And the page Loads data. - /// - /// - /// - /// Is a dependency as the server needs to be running - /// but is not referenced otherwise thus the injected item is NOT stored - /// - public FetchDataPageTests(IWebDriver aWebDriver, ServerFixture aServerFixture) - : base(aWebDriver, aServerFixture) - { - aServerFixture.Environment = AspNetEnvironment.Development; - aServerFixture.CreateHostBuilderDelegate = Server.Program.CreateHostBuilder; - - Navigate("/", aReload: true); - WaitUntilLoaded(); - } - - public void HasFetchDataPage() - { - // Navigate to "Fetch data" - WebDriver.FindElement(By.LinkText("Fetch data")).Click(); - WaitAndAssertEqual("Weather forecast", () => WebDriver.FindElement(By.TagName("h1")).Text); - - // There should be rows in the table - WaitAndAssertNotEmpty(() => WebDriver.FindElements(By.CssSelector("[data-qa='WeatherForecastTable'] tr"))); - } - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/AspNetEnvironment.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/AspNetEnvironment.cs deleted file mode 100644 index 2165ad2e..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/AspNetEnvironment.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests.Infrastructure -{ - public enum AspNetEnvironment - { - Development, - Production - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/BrowserFixture.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/BrowserFixture.cs deleted file mode 100644 index 288ef793..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/BrowserFixture.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests.Infrastructure -{ - using OpenQA.Selenium; - using OpenQA.Selenium.Chrome; - using OpenQA.Selenium.Remote; - using System; - - public class BrowserFixture : IDisposable - { - public ILogs Logs { get; } - - public IWebDriver WebDriver { get; } - - public BrowserFixture() - { - var chromeOptions = new ChromeOptions(); - - // Comment this out if you want to watch or interact with the browser (e.g., for debugging or fun) - // chromeOptions.AddArgument("--headless"); - - // Log errors - chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All); - - // On Windows/Linux, we don't need to set opts.BinaryLocation - // But for Travis and Mac builds we do - string binaryLocation = Environment.GetEnvironmentVariable("TEST_CHROME_BINARY"); - if (!string.IsNullOrEmpty(binaryLocation)) - { - chromeOptions.BinaryLocation = binaryLocation; - Console.WriteLine($"Set {nameof(ChromeOptions)}.{nameof(chromeOptions.BinaryLocation)} to {binaryLocation}"); - } - - try - { - var driver = new RemoteWebDriver(chromeOptions); - driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1); - WebDriver = driver; - WaitAndAssert.WebDriver = driver; - Logs = new RemoteLogs(driver); - } - catch (WebDriverException ex) - { - string message = - "Failed to connect to the web driver. Please see the readme and follow the instructions to install selenium." + - "Remember to start the web driver with `selenium-standalone start` before running the end-to-end tests."; - throw new InvalidOperationException(message, ex); - } - } - - public void Dispose() => WebDriver.Dispose(); - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/ClientLoaderTestConfiguration.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/ClientLoaderTestConfiguration.cs deleted file mode 100644 index ad0630c9..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/ClientLoaderTestConfiguration.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests.Infrastructure -{ - using System; - using TimeWarp.Architecture.Features.ClientLoaders; - - public class TestClientLoaderConfiguration : IClientLoaderConfiguration - { - public TimeSpan DelayTimeSpan => TimeSpan.FromMilliseconds(10); - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/DirectoryService.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/DirectoryService.cs deleted file mode 100644 index bd099521..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/DirectoryService.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests.Infrastructure -{ - using System; - using System.IO; - - /// - /// Helper tools related to git - /// - public class DirectoryService - { - /// - /// Find the parent directory that contains the Solution file . - /// - /// DirectoryInfo of the directory that contains the target directory or returns null if not in a git repository - public DirectoryInfo FindSolutionRoot() - { - const string SolutionFileName = "TimeWarp.Architecture.sln"; - var directory = new DirectoryInfo(Environment.CurrentDirectory); - bool found = directory.GetFiles(SolutionFileName).Length > 0; - while (!found && directory.Parent != null) - { - directory = directory.Parent; - found = directory.GetFiles(SolutionFileName).Length > 0; - } - - return directory; - } - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/GitService.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/GitService.cs deleted file mode 100644 index 2521a71c..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/GitService.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests.Infrastructure -{ - using System; - using System.IO; - using System.Linq; - - /// - /// Helper tools related to git - /// - public class GitService - { - /// - /// Finds root folder of the current git repository. - /// - /// DirectoryInfo of the directory that contains the ".git" directory or returns null if not in a git repository - public DirectoryInfo GitRootDirectoryInfo() - { - var directory = new DirectoryInfo(Environment.CurrentDirectory); - bool found = IsGitDirectory(directory); - while (!found && directory.Parent != null) - { - directory = directory.Parent; - found = IsGitDirectory(directory); - } - - return directory; - } - - /// - /// Determines whether or not the specified directory is the root of a git repository - /// - /// The directory to check - public bool IsGitDirectory(DirectoryInfo aDirectoryInfo) => - aDirectoryInfo.GetDirectories(".git").Any() || aDirectoryInfo.GetDirectories(".template.config").Any(); - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/SeleniumStandalone.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/SeleniumStandalone.cs deleted file mode 100644 index df1a8d05..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/SeleniumStandalone.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests.Infrastructure -{ - using System; - using System.Diagnostics; - using System.Net.Http; - - public class SeleniumStandAlone : IDisposable - { - private const string SeleniumRequestUri = "http://localhost:4444/wd/hub"; - - public Process Process { get; } - - public SeleniumStandAlone() - { - Process = new Process() - { - StartInfo = new ProcessStartInfo - { - FileName = "selenium-standalone", - Arguments = "start", - UseShellExecute = true - } - }; - Process.Start(); - WaitForSelenium().Wait(); - } - - public void Dispose() => Process?.Close(); - - internal async System.Threading.Tasks.Task WaitForSelenium() - { - using var httpClient = new HttpClient(); - - try - { - HttpResponseMessage response = await httpClient.GetAsync(SeleniumRequestUri); - response.EnsureSuccessStatusCode(); - } - catch (Exception) - { - Console.WriteLine("First connect attempt failed."); - HttpResponseMessage secondResponse = await httpClient.GetAsync(SeleniumRequestUri); - secondResponse.EnsureSuccessStatusCode(); - } - } - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/ServerFixture.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/ServerFixture.cs deleted file mode 100644 index fad07530..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/ServerFixture.cs +++ /dev/null @@ -1,110 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests.Infrastructure -{ - using Microsoft.AspNetCore.Hosting; - using Microsoft.AspNetCore.Hosting.Server; - using Microsoft.AspNetCore.Hosting.Server.Features; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.DependencyInjection.Extensions; - using Microsoft.Extensions.Hosting; - using System; - using System.IO; - using System.Linq; - using System.Threading; - using TimeWarp.Architecture.Features.ClientLoaders; - - public class ServerFixture - { - private readonly Lazy LazyUri; - - public CreateHostBuilder CreateHostBuilderDelegate { get; set; } - - public AspNetEnvironment Environment { get; set; } = AspNetEnvironment.Production; - - public Uri RootUri => LazyUri.Value; - - private IHost Host; - - public ServerFixture() - { - LazyUri = new Lazy(() => - new Uri(StartAndGetRootUri())); - } - - public delegate IHostBuilder CreateHostBuilder(string[] aArgumentArray); - - /// - /// Find the path to the server that you are testing. - /// - /// - /// The Path to the project - protected static string FindSitePath(string aProjectName) - { - DirectoryInfo gitRootDirectory = new DirectoryService().FindSolutionRoot(); - string path = Path.Combine(gitRootDirectory.FullName, "Source", "Server"); - return path; - } - - protected static void RunInBackgroundThread(Action aAction) - { - using var isDone = new ManualResetEvent(false); - - new Thread(() => - { - aAction(); - isDone.Set(); - }).Start(); - - isDone.WaitOne(); - } - - protected IHost CreateWebHost() - { - if (CreateHostBuilderDelegate == null) - { - throw new InvalidOperationException - ( - $"No value was provided for {nameof(CreateHostBuilderDelegate)}" - ); - } - - string sitePath = FindSitePath(CreateHostBuilderDelegate.Method.DeclaringType.Assembly.GetName().Name); - - IHostBuilder hostBuilder = CreateHostBuilderDelegate - ( - new[] - { - "--urls", "http://127.0.0.1:0", - "--contentroot", sitePath, - "--environment", Environment.ToString(), - } - ); - - hostBuilder.ConfigureServices(ConfigureServices); - - IHost host = hostBuilder.Build(); - - return host; - } - - protected string StartAndGetRootUri() - { - Host = CreateWebHost(); - // Configure services here to override any - RunInBackgroundThread(Host.Start); - return Host - .Services - .GetRequiredService() - .Features - .Get() - .Addresses.Single(); - } - - /// - /// Special configuration for Testing with the Test Server - /// - /// - private void ConfigureServices(IServiceCollection aServiceCollection) => - aServiceCollection - .Replace(ServiceDescriptor.Scoped()); - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/TestingConvention.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/TestingConvention.cs deleted file mode 100644 index 125c85a4..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/TestingConvention.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests -{ - using Fixie; - using Microsoft.Extensions.DependencyInjection; - using System; - using TimeWarp.Architecture.EndToEnd.Tests.Infrastructure; - - public class TestingConvention : Discovery, Execution, IDisposable - { - private BrowserFixture BrowserFixture; - - private SeleniumStandAlone SeleniumStandAlone; - - private IServiceScopeFactory ServiceScopeFactory; - - public TestingConvention() - { - Methods.Where(aMethodExpression => aMethodExpression.Name != nameof(Setup)); - } - - public void Dispose() - { - BrowserFixture?.WebDriver?.Quit(); - SeleniumStandAlone?.Dispose(); - } - - public void Execute(TestClass aTestClass) - { - if (ServiceScopeFactory == null) - { - ConfigureServiceProvider(); - } - - aTestClass.RunCases(aCase => - { - using IServiceScope serviceScope = ServiceScopeFactory.CreateScope(); - object instance = serviceScope.ServiceProvider.GetService(aTestClass.Type); - Setup(instance); - aCase.Execute(instance); - }); - } - - private static void Setup(object aInstance) - { - System.Reflection.MethodInfo method = aInstance.GetType().GetMethod(nameof(Setup)); - method?.Execute(aInstance); - } - - private void ConfigureServiceProvider() - { - var testServices = new ServiceCollection(); - ConfigureTestServices(testServices); - ServiceProvider serviceProvider = testServices.BuildServiceProvider(); - ServiceScopeFactory = serviceProvider.GetService(); - } - - private void ConfigureTestServices(ServiceCollection aServiceCollection) - { - SeleniumStandAlone = new SeleniumStandAlone(); - BrowserFixture = new BrowserFixture(); - aServiceCollection.AddSingleton(BrowserFixture.WebDriver); - aServiceCollection.AddSingleton(); - // TODO: should use the same collection as `Classes` here - aServiceCollection.Scan(aTypeSourceSelector => aTypeSourceSelector - // Start with all non abstract types in this assembly - .FromAssemblyOf() - // Add all the classes that end in Tests - .AddClasses(action: (aClasses) => aClasses.TypeName().EndsWith("Tests")) - .AsSelf() - .WithScopedLifetime()); - } - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/WaitAndAssert.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/WaitAndAssert.cs deleted file mode 100644 index 1fe5fc90..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/Infrastructure/WaitAndAssert.cs +++ /dev/null @@ -1,70 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests.Infrastructure -{ - using OpenQA.Selenium; - using OpenQA.Selenium.Support.UI; - using Shouldly; - using System; - using System.Collections.Generic; - - /// - /// Shouldly assertions, but hooked into Selenium's WebDriverWait mechanism - /// - public class WaitAndAssert - { - public static IWebDriver WebDriver; - private static readonly TimeSpan s_DefaultTimeout = TimeSpan.FromSeconds(10); - - //public static void Collection(Func> actualValues, params Action[] elementInspectors) - // => WaitAssertCore(() => Assert.Collection(actualValues(), elementInspectors)); - - public static void False(Func aActual) - => WaitAssertCore(() => aActual().ShouldBeFalse()); - - public static void Single(Func> aActualValues) - => WaitAssertCore(() => aActualValues().ShouldHaveSingleItem()); - - public static void True(Func aActual) - => WaitAssertCore(() => aActual().ShouldBeTrue()); - - public static void WaitAndAssertContains(string aExpectedSubstring, Func aActualString) - => WaitAssertCore(() => aActualString().ShouldContain(aExpectedSubstring)); - - public static void WaitAndAssertEmpty(Func> aActualValues) - => WaitAssertCore(() => aActualValues().ShouldBeEmpty()); - - public static void WaitAndAssertEqual(T aExpected, Func aActual) - => WaitAssertCore(() => aActual().ShouldBe(aExpected)); - - public static void WaitAndAssertNotEmpty(Func> aActualValues) - => WaitAssertCore(() => aActualValues().ShouldNotBeEmpty()); - - private static void WaitAssertCore(Action aAssertion, TimeSpan aTimeout = default) - { - if (aTimeout == default) - { - aTimeout = s_DefaultTimeout; - } - - try - { - new WebDriverWait(WebDriver, aTimeout).Until(aWebDriver => - { - try - { - aAssertion(); - return true; - } - catch - { - return false; - } - }); - } - catch (WebDriverTimeoutException) - { - // Instead of reporting it as a timeout, report the exception - aAssertion(); - } - } - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/JsInteropTests.cs b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/JsInteropTests.cs deleted file mode 100644 index 3f7b8d13..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/JsInteropTests.cs +++ /dev/null @@ -1,72 +0,0 @@ -namespace TimeWarp.Architecture.EndToEnd.Tests -{ - using OpenQA.Selenium; - using Shouldly; - using TimeWarp.Architecture.EndToEnd.Tests.Infrastructure; - - public class JsInteropTests : BaseTest - { - /// - /// - /// - /// - /// - /// Is a dependency as the server needs to be running - /// but is not referenced otherwise thus the injected item is NOT stored - /// - public JsInteropTests(IWebDriver aWebDriver, ServerFixture aServerFixture) - : base(aWebDriver, aServerFixture) - { - aServerFixture.Environment = AspNetEnvironment.Development; - aServerFixture.CreateHostBuilderDelegate = Server.Program.CreateHostBuilder; - - Navigate("/", aReload: true); - WaitUntilClientCached(); - - object clientApplication = JavaScriptExecutor.ExecuteScript("return window.localStorage.getItem('clientApplication');"); - clientApplication.ShouldBe("TimeWarp.Architecture.0.0.1"); - } - - public void InitalizationWorkedClientSide() - { - JavaScriptExecutor.ExecuteScript("window.localStorage.setItem('executionSide','client');"); - - Navigate("/", aReload: true); - WaitUntilLoaded(); - InitalizationWorked(); - } - - public void InitalizationWorkedServerSide() - { - JavaScriptExecutor.ExecuteScript("window.localStorage.setItem('executionSide','server');"); - - Navigate("/", aReload: true); - WaitUntilLoaded(); - InitalizationWorked(); - } - - private void InitalizationWorked() - { - object blazorState = JavaScriptExecutor.ExecuteScript("return window.BlazorState;"); - blazorState.ShouldNotBeNull(); - - object initializeJavaScriptInterop = JavaScriptExecutor.ExecuteScript("return window.InitializeJavaScriptInterop;"); - initializeJavaScriptInterop.ShouldNotBeNull(); - - object reduxDevToolsFactory = JavaScriptExecutor.ExecuteScript("return window.ReduxDevToolsFactory;"); - reduxDevToolsFactory.ShouldNotBeNull(); - - object reduxDevTools = JavaScriptExecutor.ExecuteScript("return window.reduxDevTools;"); - reduxDevTools.ShouldNotBeNull(); - - object jsonRequestHandler = JavaScriptExecutor.ExecuteScript("return window.jsonRequestHandler;"); - jsonRequestHandler.ShouldNotBeNull(); - } - - //public void CanCallCsharpFromJs() - //{ - // // Redux Dev tool use this ability. - // // TODO set up a handler to be launched from JS - //} - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/TimeWarp.Blazor.EndToEnd.Selenium.Tests.csproj b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/TimeWarp.Blazor.EndToEnd.Selenium.Tests.csproj deleted file mode 100644 index bc6f5595..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.Selenium.Tests/TimeWarp.Blazor.EndToEnd.Selenium.Tests.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/.npmrc b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/.npmrc deleted file mode 100644 index 43c97e71..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/EndToEnd.TestCafe.Tests.csproj b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/EndToEnd.TestCafe.Tests.csproj deleted file mode 100644 index d2da1729..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/EndToEnd.TestCafe.Tests.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - false - - - - - - - \ No newline at end of file diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/README.md b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/README.md deleted file mode 100644 index 2881276f..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# TestApp.EndToEnd.TestCafe.Tests - -End to End tests using TestCafe - -## Install - -Run `npm install` from the test project directory, the same directory this README.md is in. - -## Execute - -Run `npm test` from the test project directory, same directory this README.md is in. - -Or run `testcafe.ps1` from the sln directory. \ No newline at end of file diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/package.json b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/package.json deleted file mode 100644 index 350a1977..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "test-app.end-to-end.test-cafe.tests", - "scripts": { - "server": "dotnet run --no-build --project ../../Source/Server/TimeWarp.Architecture.Server.csproj --urls https://localhost:5011", - "test": "testcafe edge tests/ --app \"npm run server > NUL\" --app-init-delay 5000" - }, - "devDependencies": { - "testcafe": "1.9.4" - } -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/ChangeRouteShould.ts b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/ChangeRouteShould.ts deleted file mode 100644 index bef7b1f5..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/ChangeRouteShould.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { ClientFunction, Selector } from 'testcafe'; - -fixture `CounterPage` - .page `https://localhost:5011/`; - -test('Change Route Should Change Route', async t => { - await t - .click(Selector('a').withText('Counter')); - - const changeRouteButton = Selector('[data-qa="ChangeRoute"]'); - const homeHeader = Selector('[data-qa="HomeHeader"]'); - - await t - .click(changeRouteButton) - .expect(homeHeader.exists).ok(); - -}); diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/CounterShouldCount.ts b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/CounterShouldCount.ts deleted file mode 100644 index dfb3d1a8..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/CounterShouldCount.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Selector } from 'testcafe'; - -fixture`CounterPage` - .page`https://localhost:5011/`; - -test('Counter Should Count even via js interop', async t => { - await t - .click(Selector('a').withText('Counter')); - - const Button1 = Selector('[data-qa="Counter1"]').find('button'); - const Button2 = Selector('[data-qa="Counter2"]').find('button'); - const Button3 = Selector('[data-qa="JsInterop"]'); - const CounterDisplay1 = Selector('[data-qa="Counter1"]').find('p'); - const CounterDisplay2 = Selector('[data-qa="Counter2"]').find('p'); - - await t - .expect(CounterDisplay1.textContent).eql("Current count: 3") - .expect(CounterDisplay2.textContent).eql("Current count: 3") - .click(Button1) - .expect(CounterDisplay1.textContent).eql("Current count: 8") - .expect(CounterDisplay2.textContent).eql("Current count: 8") - .click(Button2) - .expect(CounterDisplay1.textContent).eql("Current count: 13") - .expect(CounterDisplay2.textContent).eql("Current count: 13") - .click(Button1) - .expect(CounterDisplay1.textContent).eql("Current count: 18") - .expect(CounterDisplay2.textContent).eql("Current count: 18") - .click(Button3) - .expect(CounterDisplay1.textContent).eql("Current count: 25") - .expect(CounterDisplay2.textContent).eql("Current count: 25"); -}); diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/ExecutionSide.ts b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/ExecutionSide.ts deleted file mode 100644 index 4547f7a6..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/ExecutionSide.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { ClientFunction, Selector } from "testcafe"; - -import { getLocalStorage, setLocalStorage } from "../util/LocalStorage"; - -enum ExecutionSide { - Server = "server", - Client = "client" -} - -fixture`HomePage`.page`https://localhost:5011/`; - -test("Should Load Server Side", async t => { - const defaultExecutionSideValue = "To force a side set this to client/server"; - const executionSideKey = "executionSide"; - - let executionSide = await getLocalStorage(executionSideKey); - await t.expect(executionSide).eql(defaultExecutionSideValue); - - await setLocalStorage(executionSideKey, ExecutionSide.Server); - await t.eval(() => location.reload()); - - executionSide = await getLocalStorage(executionSideKey); - await t.expect(executionSide).eql(ExecutionSide.Server); - - const blazorLocation = Selector('[data-qa="BlazorLocation"]'); - - await t.expect(blazorLocation.textContent).eql("Server Side"); - - await ValidateInitialization(t); -}); - -test("Should Load Client Side", async t => { - const defaultExecutionSideValue = "To force a side set this to client/server"; - const executionSideKey = "executionSide"; - - let executionSide = await getLocalStorage(executionSideKey); - await t.expect(executionSide).eql(defaultExecutionSideValue); - - await setLocalStorage(executionSideKey, ExecutionSide.Client); - await t.eval(() => location.reload(true)); - - executionSide = await getLocalStorage(executionSideKey); - await t.expect(executionSide).eql(ExecutionSide.Client); - - const blazorLocation = Selector('[data-qa="BlazorLocation"]'); - - const timeToLetClientSideLoad = 5000; // will originally render server side. 5 sec should be enough to switch. - await t - .wait(timeToLetClientSideLoad) - .expect(blazorLocation.textContent) - .eql("Client Side"); - - await ValidateInitialization(t); -}); - -const ValidateInitialization = async(t: TestController): Promise => { - const hasBlazorState = ClientFunction(() => - window.hasOwnProperty("BlazorState") - ); - const hasInitializeJavaScriptInterop = ClientFunction(() => - window.hasOwnProperty("InitializeJavaScriptInterop") - ); - const hasReduxDevToolsFactory = ClientFunction(() => - window.hasOwnProperty("ReduxDevToolsFactory") - ); - const hasReduxDevTools = ClientFunction(() => - window.hasOwnProperty("reduxDevTools") - ); - const hasJsonRequestHandler = ClientFunction(() => - window.hasOwnProperty("jsonRequestHandler") - ); - await t - .expect(hasBlazorState()) - .ok() - .expect(hasInitializeJavaScriptInterop()) - .ok() - .expect(hasReduxDevToolsFactory()) - .ok() - .expect(hasReduxDevTools()) - .ok() - .expect(hasJsonRequestHandler()) - .ok(); -} diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/WeatherForecastPage.ts b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/WeatherForecastPage.ts deleted file mode 100644 index d6e839e5..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/tests/WeatherForecastPage.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Selector } from "testcafe"; - -fixture`WeatherForecastsPage`.page`https://localhost:5011/weatherforecasts`; - -test("Should have data", async t => { - const weatherForecastTableRows = Selector('[data-qa="WeatherForecastTable"] tr') - .with({visibilityCheck: true}); - - const minimumNumberOfRowsExpected = 5; - await t.expect(weatherForecastTableRows.count).gt(minimumNumberOfRowsExpected); -}); diff --git a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/util/LocalStorage.ts b/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/util/LocalStorage.ts deleted file mode 100644 index 21e9eefb..00000000 --- a/Source/TimeWarp.Architecture.Template/templates/TimeWarp.Architecture/Tests/EndToEnd.TestCafe.Tests/util/LocalStorage.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ClientFunction } from "testcafe"; -export const getLocalStorage = ClientFunction((key: string) => { - return new Promise(resolve => { - const result = localStorage.getItem(key); - resolve(result); - }); -}); - -export const setLocalStorage = ClientFunction((key: string, value: string) => { - return new Promise((resolve, reject) => { - try { - localStorage.setItem(key, value); - resolve(); - } catch (error) { - reject(error); - } - }); -}); From 0514f35ac5524c50ca40440dc2d280ccb2453653 Mon Sep 17 00:00:00 2001 From: "Steven T. Cramer" Date: Sun, 24 Mar 2024 10:29:00 +0700 Subject: [PATCH 2/2] We don't need to add dotnet 8 to the agent it is there by default --- .github/workflows/timewarp-architecture.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/timewarp-architecture.yml b/.github/workflows/timewarp-architecture.yml index 6899abd3..534fba6f 100644 --- a/.github/workflows/timewarp-architecture.yml +++ b/.github/workflows/timewarp-architecture.yml @@ -17,7 +17,7 @@ jobs: - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - name: Check out repository code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - run: echo "🖥️ The workflow is now ready to test your code on the runner." @@ -26,16 +26,12 @@ jobs: ls ${{ github.workspace }} - run: echo "🍏 This job's status is ${{ job.status }}." - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 7.0.x - env: - NUGET_AUTH_TOKEN: ${{secrets.PUBLISH_TO_NUGET_ORG}} # <-- This is the token for the GitHub account you want to use. - - name: Pack run: | cd Source/TimeWarp.Architecture.Template/ dotnet build -c Release + - name: Publish run: dotnet nuget push Source/TimeWarp.Architecture.Template/bin/Release/TimeWarp.Architecture.*.nupkg --skip-duplicate --no-symbols --source https://api.nuget.org/v3/index.json --api-key ${{secrets.PUBLISH_TO_NUGET_ORG}} + env: + NUGET_AUTH_TOKEN: ${{secrets.PUBLISH_TO_NUGET_ORG}} \ No newline at end of file