From ced751318932d8a23e6aa4fbc0cbb35204084cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 18 Mar 2022 10:49:36 +0100 Subject: [PATCH 1/6] Make ShellFeaturesController AllowAnonymous. --- .../Controllers/ShellFeaturesController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lombiq.Tests.UI.Shortcuts/Controllers/ShellFeaturesController.cs b/Lombiq.Tests.UI.Shortcuts/Controllers/ShellFeaturesController.cs index e8d28a1e7..6d22994f4 100644 --- a/Lombiq.Tests.UI.Shortcuts/Controllers/ShellFeaturesController.cs +++ b/Lombiq.Tests.UI.Shortcuts/Controllers/ShellFeaturesController.cs @@ -1,4 +1,5 @@ using Lombiq.HelpfulLibraries.Libraries.Mvc; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using OrchardCore.Environment.Extensions; using OrchardCore.Environment.Extensions.Features; @@ -10,6 +11,7 @@ namespace Lombiq.Tests.UI.Shortcuts.Controllers; [DevelopmentAndLocalhostOnly] +[AllowAnonymous] public class ShellFeaturesController : Controller { private readonly IShellFeaturesManager _shellFeatureManager; From a72484fef3ab6c36257d7f96c2516744ed3c498c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Sun, 6 Mar 2022 19:30:08 +0100 Subject: [PATCH 2/6] Fix webroot argument that somehow corrupted the following environment argument. (cherry picked from commit e70011d658f26249a623c683da208dc0e17ee7a5) # Conflicts: # Lombiq.Tests.UI/Services/OrchardCoreInstance.cs --- Lombiq.Tests.UI/Services/OrchardCoreInstance.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.Tests.UI/Services/OrchardCoreInstance.cs b/Lombiq.Tests.UI/Services/OrchardCoreInstance.cs index 9a36bab9a..4577bdcd1 100644 --- a/Lombiq.Tests.UI/Services/OrchardCoreInstance.cs +++ b/Lombiq.Tests.UI/Services/OrchardCoreInstance.cs @@ -141,7 +141,7 @@ public async Task StartUpAsync() argumentsBuilder = argumentsBuilder .Add("--urls").Add(url) .Add("--contentRoot").Add(_contentRootPath) - .Add("--webroot=").Add(Path.Combine(_contentRootPath, "wwwroot")) + .Add("--webroot=" + Path.Combine(_contentRootPath, "wwwroot")) .Add("--environment").Add("Development"); if (!useExeToExecuteApp) argumentsBuilder = argumentsBuilder.Add(_configuration.AppAssemblyPath); From 74b537af566fcf314c982a2e46b108ffe97c3a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Fri, 18 Mar 2022 12:03:54 +0100 Subject: [PATCH 3/6] Fix this test we just broke. --- Lombiq.Tests.UI.Samples/Tests/BasicTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lombiq.Tests.UI.Samples/Tests/BasicTests.cs b/Lombiq.Tests.UI.Samples/Tests/BasicTests.cs index 75fb3ee58..898a33653 100644 --- a/Lombiq.Tests.UI.Samples/Tests/BasicTests.cs +++ b/Lombiq.Tests.UI.Samples/Tests/BasicTests.cs @@ -126,6 +126,9 @@ public Task ApplicationInsightsTrackingShouldBePresent(Browser browser) => ExecuteTestAfterSetupAsync( async context => { + await context.EnableFeatureDirectlyAsync("Lombiq.Privacy.ConsentBanner"); + await context.GoToHomePageAsync(); + // Now there's a bit of a pickle though: The Lombiq Privacy module is also enabled from the test recipe // and shows its privacy consent banner. For tracking to be enabled, even in offline mode, the user // needs to give consent. This is what we do now: From 1ff5bb3883c5cec24c5068657e5319eb6938d7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Mon, 21 Mar 2022 17:38:03 +0100 Subject: [PATCH 4/6] Make argument usage consistent. --- Lombiq.Tests.UI/Services/OrchardCoreInstance.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.Tests.UI/Services/OrchardCoreInstance.cs b/Lombiq.Tests.UI/Services/OrchardCoreInstance.cs index 4577bdcd1..6ad4fc531 100644 --- a/Lombiq.Tests.UI/Services/OrchardCoreInstance.cs +++ b/Lombiq.Tests.UI/Services/OrchardCoreInstance.cs @@ -141,7 +141,7 @@ public async Task StartUpAsync() argumentsBuilder = argumentsBuilder .Add("--urls").Add(url) .Add("--contentRoot").Add(_contentRootPath) - .Add("--webroot=" + Path.Combine(_contentRootPath, "wwwroot")) + .Add("--webroot").Add(Path.Combine(_contentRootPath, "wwwroot")) .Add("--environment").Add("Development"); if (!useExeToExecuteApp) argumentsBuilder = argumentsBuilder.Add(_configuration.AppAssemblyPath); From 8df0874ab40212112efecaadbd3562d187cc456e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Mon, 21 Mar 2022 22:48:51 +0100 Subject: [PATCH 5/6] Fixing TestAdminBackgroundTasksAsMonkeyRecursivelyShouldWorkWithAdminUser occasionally failing --- Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs | 15 ++++++++++++++- .../Extensions/LoggingWebDriverExtensions.cs | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs b/Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs index 6911de46f..c696ffc38 100644 --- a/Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs +++ b/Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs @@ -3,7 +3,9 @@ using Lombiq.Tests.UI.MonkeyTesting; using Lombiq.Tests.UI.MonkeyTesting.UrlFilters; using Lombiq.Tests.UI.Services; +using Shouldly; using System; +using System.Linq; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; @@ -79,7 +81,12 @@ public Task TestAdminBackgroundTasksAsMonkeyRecursivelyShouldWorkWithAdminUser(B await context.SignInDirectlyAndGoToRelativeUrlAsync("/Admin/BackgroundTasks"); await context.TestCurrentPageAsMonkeyRecursivelyAsync(monkeyTestingOptions); }, - browser); + browser, + configuration => + // This is necessary to work around this bug: https://github.com/OrchardCMS/OrchardCore/issues/11420. + configuration.AssertBrowserLog = messages => messages.ShouldNotContain( + message => IsValidAdminBrowserLogMessage(message), + messages.Where(IsValidAdminBrowserLogMessage).ToFormattedString())); // Monkey testing has its own configuration too. Check out the docs of the options too. private static MonkeyTestingOptions CreateMonkeyTestingOptions() => @@ -87,6 +94,12 @@ private static MonkeyTestingOptions CreateMonkeyTestingOptions() => { PageTestTime = TimeSpan.FromSeconds(10), }; + + private static bool IsValidAdminBrowserLogMessage(BrowserLogMessage message) => + OrchardCoreUITestExecutorConfiguration.IsValidBrowserLogMessage(message) && + !(message.Source == BrowserLogMessage.Sources.Intervention && + message.Message.ContainsOrdinalIgnoreCase( + "Blocked attempt to show a 'beforeunload' confirmation panel for a frame that never had a user gesture since its load.")); } // END OF TRAINING SECTION: Monkey tests. diff --git a/Lombiq.Tests.UI/Extensions/LoggingWebDriverExtensions.cs b/Lombiq.Tests.UI/Extensions/LoggingWebDriverExtensions.cs index 687015b31..16db3dea5 100644 --- a/Lombiq.Tests.UI/Extensions/LoggingWebDriverExtensions.cs +++ b/Lombiq.Tests.UI/Extensions/LoggingWebDriverExtensions.cs @@ -45,6 +45,7 @@ public static class Sources { public const string ConsoleApi = "console-api"; public const string Deprecation = "deprecation"; + public const string Intervention = "intervention"; public const string Javascript = "javascript"; public const string Network = "network"; public const string Recommendation = "recommendation"; From 874643bdc34998f63af9c4953e67628215958600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Mon, 21 Mar 2022 23:49:52 +0100 Subject: [PATCH 6/6] Fixing that the configuration was on the wrong test --- Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs b/Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs index c696ffc38..21d3030ec 100644 --- a/Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs +++ b/Lombiq.Tests.UI.Samples/Tests/MonkeyTests.cs @@ -60,7 +60,12 @@ public Task TestAdminPagesAsMonkeyRecursivelyShouldWorkWithAdminUser(Browser bro context => // Monkey tests needn't all start from the homepage. This one starts from the Orchard admin dashboard. context.TestAdminAsMonkeyRecursivelyAsync(CreateMonkeyTestingOptions()), - browser); + browser, + configuration => + // This is necessary to work around this bug: https://github.com/OrchardCMS/OrchardCore/issues/11420. + configuration.AssertBrowserLog = messages => messages.ShouldNotContain( + message => IsValidAdminBrowserLogMessage(message), + messages.Where(IsValidAdminBrowserLogMessage).ToFormattedString())); // Let's just test the background tasks management admin area. [Theory, Chrome] @@ -81,12 +86,7 @@ public Task TestAdminBackgroundTasksAsMonkeyRecursivelyShouldWorkWithAdminUser(B await context.SignInDirectlyAndGoToRelativeUrlAsync("/Admin/BackgroundTasks"); await context.TestCurrentPageAsMonkeyRecursivelyAsync(monkeyTestingOptions); }, - browser, - configuration => - // This is necessary to work around this bug: https://github.com/OrchardCMS/OrchardCore/issues/11420. - configuration.AssertBrowserLog = messages => messages.ShouldNotContain( - message => IsValidAdminBrowserLogMessage(message), - messages.Where(IsValidAdminBrowserLogMessage).ToFormattedString())); + browser); // Monkey testing has its own configuration too. Check out the docs of the options too. private static MonkeyTestingOptions CreateMonkeyTestingOptions() =>