From f31c29a1b8ec687396765343b3bf91a49ee0058e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Horv=C3=A1th?= Date: Sun, 15 May 2022 22:50:56 +0200 Subject: [PATCH 1/8] adding theme and user related extensions --- .../Controllers/AccountController.cs | 25 ++++++- .../Controllers/ThemeController.cs | 66 +++++++++++++++++++ .../Lombiq.Tests.UI.Shortcuts.csproj | 3 +- Lombiq.Tests.UI.Shortcuts/Manifest.cs | 2 +- .../ShortcutsUITestContextExtensions.cs | 15 +++++ 5 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs diff --git a/Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs b/Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs index 03c1632dd..62027a8c1 100644 --- a/Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs +++ b/Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs @@ -2,7 +2,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; +using OrchardCore.Entities; +using OrchardCore.Settings; using OrchardCore.Users; +using OrchardCore.Users.Models; using System.Threading.Tasks; namespace Lombiq.Tests.UI.Shortcuts.Controllers; @@ -12,11 +15,16 @@ public class AccountController : Controller { private readonly UserManager _userManager; private readonly SignInManager _userSignInManager; + private readonly ISiteService _siteService; - public AccountController(UserManager userManager, SignInManager userSignInManager) + public AccountController( + UserManager userManager, + SignInManager userSignInManager, + ISiteService siteService) { _userManager = userManager; _userSignInManager = userSignInManager; + _siteService = siteService; } [AllowAnonymous] @@ -37,4 +45,19 @@ public async Task SignOutDirectly() return Ok(); } + + [AllowAnonymous] + public async Task SetUserRegistrationType(UserRegistrationType type) + { + var settings = await _siteService.LoadSiteSettingsAsync(); + var registrationSettings = settings.As(); + + registrationSettings.UsersCanRegister = type; + + settings.Put(registrationSettings); + + await _siteService.UpdateSiteSettingsAsync(settings); + + return Ok(); + } } diff --git a/Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs b/Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs new file mode 100644 index 000000000..1a4788786 --- /dev/null +++ b/Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs @@ -0,0 +1,66 @@ +using Lombiq.HelpfulLibraries.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using OrchardCore.Admin; +using OrchardCore.DisplayManagement.Extensions; +using OrchardCore.Environment.Extensions; +using OrchardCore.Environment.Shell; +using OrchardCore.Modules.Manifest; +using OrchardCore.Themes.Services; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace Lombiq.Tests.UI.Shortcuts.Controllers; + +[DevelopmentAndLocalhostOnly] +public class ThemeController : Controller +{ + private readonly IShellFeaturesManager _shellFeaturesManager; + private readonly ISiteThemeService _siteThemeService; + private readonly IAdminThemeService _adminThemeService; + + public ThemeController( + IShellFeaturesManager shellFeaturesManager, + ISiteThemeService siteThemeService, + IAdminThemeService adminThemeService) + { + _shellFeaturesManager = shellFeaturesManager; + _siteThemeService = siteThemeService; + _adminThemeService = adminThemeService; + } + + [AllowAnonymous] + public async Task SelectTheme(string id) + { + var themeFeature = (await _shellFeaturesManager.GetAvailableFeaturesAsync()) + .FirstOrDefault(feature => feature.IsTheme() && feature.Id == id); + + if (themeFeature == null) + { + return NotFound(); + } + + if (IsAdminTheme(themeFeature.Extension.Manifest)) + { + await _adminThemeService.SetAdminThemeAsync(id); + } + else + { + await _siteThemeService.SetSiteThemeAsync(id); + } + + var enabledFeatures = await _shellFeaturesManager.GetEnabledFeaturesAsync(); + var isEnabled = enabledFeatures.Any(x => x.Extension.Id == themeFeature.Id); + + if (!isEnabled) + { + await _shellFeaturesManager.EnableFeaturesAsync(new[] { themeFeature }, force: true); + } + + return Ok(); + } + + private static bool IsAdminTheme(IManifestInfo manifest) => + manifest.Tags.Any(x => string.Equals(x, ManifestConstants.AdminTag, StringComparison.OrdinalIgnoreCase)); +} diff --git a/Lombiq.Tests.UI.Shortcuts/Lombiq.Tests.UI.Shortcuts.csproj b/Lombiq.Tests.UI.Shortcuts/Lombiq.Tests.UI.Shortcuts.csproj index 7ee64d9b6..f671c23e7 100644 --- a/Lombiq.Tests.UI.Shortcuts/Lombiq.Tests.UI.Shortcuts.csproj +++ b/Lombiq.Tests.UI.Shortcuts/Lombiq.Tests.UI.Shortcuts.csproj @@ -35,7 +35,8 @@ - + + diff --git a/Lombiq.Tests.UI.Shortcuts/Manifest.cs b/Lombiq.Tests.UI.Shortcuts/Manifest.cs index 184ee23e0..883908646 100644 --- a/Lombiq.Tests.UI.Shortcuts/Manifest.cs +++ b/Lombiq.Tests.UI.Shortcuts/Manifest.cs @@ -5,7 +5,7 @@ Name = "Shortcuts - Lombiq UI Testing Toolbox", Author = "Lombiq Technologies", Website = "https://github.com/Lombiq/UI-Testing-Toolbox", - Version = "2.1.1" + Version = "2.1.2-beta" )] [assembly: Feature( diff --git a/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs b/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs index 9b72c78df..957451b60 100644 --- a/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs +++ b/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs @@ -4,6 +4,7 @@ using Lombiq.Tests.UI.Shortcuts.Controllers; using Lombiq.Tests.UI.Shortcuts.Models; using OpenQA.Selenium; +using OrchardCore.Users.Models; using RestEase; using Shouldly; using System; @@ -77,6 +78,13 @@ public static async Task GetCurrentUserNameAsync(this UITestContext cont return userNameContainer["UserName: ".Length..]; } + /// + /// Sets the registration type in site settings. + /// Lombiq.Tests.UI.Shortcuts enabled. + /// + public static Task SetUserRegistrationTypeAsync(this UITestContext context, UserRegistrationType type) => + context.GoToAsync(controller => controller.SetUserRegistrationType(type)); + /// /// Enables the feature with the given ID directly, without anything else happening on the admin Features page. The /// target app needs to have Lombiq.Tests.UI.Shortcuts enabled. @@ -182,4 +190,11 @@ public interface IShortcutsApi [Get("api/ApplicationInfo")] Task GetApplicationInfoAsync(); } + + /// + /// Selects theme by id. + /// Lombiq.Tests.UI.Shortcuts enabled. + /// + public static Task SelectThemeAsync(this UITestContext context, string id) => + context.GoToAsync(controller => controller.SelectTheme(id)); } From 35df263548cb2addf34a1ce6b1a99002fb7d85b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Horv=C3=A1th?= Date: Mon, 16 May 2022 20:20:35 +0200 Subject: [PATCH 2/8] fixing html-validate error: Attribute "method" has invalid value "POST" attribute-allowed-values --- Lombiq.Tests.UI.Samples/.htmlvalidate.json | 13 ++++++++++++- Lombiq.Tests.UI/.htmlvalidate.json | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Lombiq.Tests.UI.Samples/.htmlvalidate.json b/Lombiq.Tests.UI.Samples/.htmlvalidate.json index 1b8ade5cf..1103b748a 100644 --- a/Lombiq.Tests.UI.Samples/.htmlvalidate.json +++ b/Lombiq.Tests.UI.Samples/.htmlvalidate.json @@ -15,5 +15,16 @@ "wcag/h37": "off", "wcag/h67": "off", "wcag/h71": "off" - } + }, + + "elements": [ + "html5", + { + "form": { + "attributes": { + "method": [ "get", "post", "GET", "POST" ] + } + } + } + ] } diff --git a/Lombiq.Tests.UI/.htmlvalidate.json b/Lombiq.Tests.UI/.htmlvalidate.json index 586300dca..87a12b125 100644 --- a/Lombiq.Tests.UI/.htmlvalidate.json +++ b/Lombiq.Tests.UI/.htmlvalidate.json @@ -13,5 +13,16 @@ "wcag/h37": "off", "wcag/h67": "off", "wcag/h71": "off" - } + }, + + "elements": [ + "html5", + { + "form": { + "attributes": { + "method": [ "get", "post", "GET", "POST" ] + } + } + } + ] } From 038a418eef44c9591c4d404e02f4a9f88c60c7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Horv=C3=A1th?= Date: Wed, 18 May 2022 22:56:00 +0200 Subject: [PATCH 3/8] updating manifest version --- Lombiq.Tests.UI.Shortcuts/Manifest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.Tests.UI.Shortcuts/Manifest.cs b/Lombiq.Tests.UI.Shortcuts/Manifest.cs index 883908646..0059cb6f2 100644 --- a/Lombiq.Tests.UI.Shortcuts/Manifest.cs +++ b/Lombiq.Tests.UI.Shortcuts/Manifest.cs @@ -5,7 +5,7 @@ Name = "Shortcuts - Lombiq UI Testing Toolbox", Author = "Lombiq Technologies", Website = "https://github.com/Lombiq/UI-Testing-Toolbox", - Version = "2.1.2-beta" + Version = "2.1.2-alpha" )] [assembly: Feature( From 5566e7d462ba60de5c025ce3dad04503b38c38d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Horv=C3=A1th?= Date: Wed, 25 May 2022 00:12:54 +0200 Subject: [PATCH 4/8] fixing coding style --- Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs | 7 +++---- Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs | 4 ++-- .../Extensions/ShortcutsUITestContextExtensions.cs | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs b/Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs index 62027a8c1..d4eaafb84 100644 --- a/Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs +++ b/Lombiq.Tests.UI.Shortcuts/Controllers/AccountController.cs @@ -50,11 +50,10 @@ public async Task SignOutDirectly() public async Task SetUserRegistrationType(UserRegistrationType type) { var settings = await _siteService.LoadSiteSettingsAsync(); - var registrationSettings = settings.As(); - registrationSettings.UsersCanRegister = type; - - settings.Put(registrationSettings); + settings.Alter( + nameof(RegistrationSettings), + registrationSettings => registrationSettings.UsersCanRegister = type); await _siteService.UpdateSiteSettingsAsync(settings); diff --git a/Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs b/Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs index 1a4788786..545e5d22f 100644 --- a/Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs +++ b/Lombiq.Tests.UI.Shortcuts/Controllers/ThemeController.cs @@ -51,7 +51,7 @@ public async Task SelectTheme(string id) } var enabledFeatures = await _shellFeaturesManager.GetEnabledFeaturesAsync(); - var isEnabled = enabledFeatures.Any(x => x.Extension.Id == themeFeature.Id); + var isEnabled = enabledFeatures.Any(feature => feature.Extension.Id == themeFeature.Id); if (!isEnabled) { @@ -62,5 +62,5 @@ public async Task SelectTheme(string id) } private static bool IsAdminTheme(IManifestInfo manifest) => - manifest.Tags.Any(x => string.Equals(x, ManifestConstants.AdminTag, StringComparison.OrdinalIgnoreCase)); + manifest.Tags.Any(tag => tag.EqualsOrdinalIgnoreCase(ManifestConstants.AdminTag)); } diff --git a/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs b/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs index 957451b60..aeffb24ca 100644 --- a/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs +++ b/Lombiq.Tests.UI/Extensions/ShortcutsUITestContextExtensions.cs @@ -80,7 +80,6 @@ public static async Task GetCurrentUserNameAsync(this UITestContext cont /// /// Sets the registration type in site settings. - /// Lombiq.Tests.UI.Shortcuts enabled. /// public static Task SetUserRegistrationTypeAsync(this UITestContext context, UserRegistrationType type) => context.GoToAsync(controller => controller.SetUserRegistrationType(type)); @@ -193,7 +192,6 @@ public interface IShortcutsApi /// /// Selects theme by id. - /// Lombiq.Tests.UI.Shortcuts enabled. /// public static Task SelectThemeAsync(this UITestContext context, string id) => context.GoToAsync(controller => controller.SelectTheme(id)); From a1a1df1282859766b94a697c8ccc27fd3c70ae78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Horv=C3=A1th?= Date: Fri, 27 May 2022 18:57:19 +0200 Subject: [PATCH 5/8] experimental implementation of adding things to failure dump --- .../FailureDumpUITestContextExtensions.cs | 31 ++++++++++++ Lombiq.Tests.UI/Services/UITestContext.cs | 10 ++++ .../Services/UITestExecutionSession.cs | 47 ++++++++++++++++++- 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 Lombiq.Tests.UI/Extensions/FailureDumpUITestContextExtensions.cs diff --git a/Lombiq.Tests.UI/Extensions/FailureDumpUITestContextExtensions.cs b/Lombiq.Tests.UI/Extensions/FailureDumpUITestContextExtensions.cs new file mode 100644 index 000000000..692d56e9c --- /dev/null +++ b/Lombiq.Tests.UI/Extensions/FailureDumpUITestContextExtensions.cs @@ -0,0 +1,31 @@ +using Lombiq.Tests.UI.Services; +using System; +using System.Globalization; +using System.IO; +using System.Text; +using System.Threading.Tasks; + +namespace Lombiq.Tests.UI.Extensions; + +public static class FailureDumpUITestContextExtensions +{ + public static void AppendFailureDump( + this UITestContext context, + string fileName, + Func> action) => + context.FailureDumpContainer.Add( + fileName, + () => action(context)); + + public static void AppendFailureDump( + this UITestContext context, + string fileName, + string content, + params object[] args) => + context.FailureDumpContainer.Add( + fileName, + () => Task.FromResult( + new MemoryStream( + Encoding.UTF8.GetBytes( + string.Format(CultureInfo.InvariantCulture, content, args))) as Stream)); +} diff --git a/Lombiq.Tests.UI/Services/UITestContext.cs b/Lombiq.Tests.UI/Services/UITestContext.cs index ac04c006a..8b923c722 100644 --- a/Lombiq.Tests.UI/Services/UITestContext.cs +++ b/Lombiq.Tests.UI/Services/UITestContext.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.IO; using System.Linq; using System.Threading.Tasks; @@ -76,6 +77,15 @@ public class UITestContext Justification = "Deliberately modifiable by consumer code.")] public Dictionary CustomContext { get; } = new(); + /// + /// Gets a dictionary storing some custom data for collecting in failure dump. + /// + [SuppressMessage( + "Design", + "MA0016:Prefer return collection abstraction instead of implementation", + Justification = "Deliberately modifiable by consumer code.")] + public Dictionary>> FailureDumpContainer { get; } = new(); + /// /// Gets or sets the current tenant name when testing multi-tenancy. When testing sites with multi-tenancy you /// should set the value to the tenant in question so methods (e.g. ) diff --git a/Lombiq.Tests.UI/Services/UITestExecutionSession.cs b/Lombiq.Tests.UI/Services/UITestExecutionSession.cs index a63192c27..3fe0be458 100644 --- a/Lombiq.Tests.UI/Services/UITestExecutionSession.cs +++ b/Lombiq.Tests.UI/Services/UITestExecutionSession.cs @@ -12,6 +12,7 @@ using Selenium.Axe; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; @@ -58,6 +59,7 @@ public UITestExecutionSession(UITestManifest testManifest, OrchardCoreUITestExec public async Task ExecuteAsync(int retryCount, string dumpRootPath) { var startTime = DateTime.UtcNow; + Dictionary>> failureDumpContainer = null; _testOutputHelper.WriteLineTimestampedAndDebug("Starting execution of {0}.", _testManifest.Name); @@ -105,6 +107,9 @@ public async Task ExecuteAsync(int retryCount, string dumpRootPath) _context ??= await CreateContextAsync(); + _context.FailureDumpContainer.Clear(); + failureDumpContainer = _context.FailureDumpContainer; + _context.SetDefaultBrowserSize(); await _testManifest.TestAsync(_context); @@ -119,7 +124,7 @@ public async Task ExecuteAsync(int retryCount, string dumpRootPath) if (ex is SetupFailedFastException) throw; - await CreateFailureDumpAsync(ex, dumpRootPath, retryCount); + await CreateFailureDumpAsync(ex, dumpRootPath, retryCount, failureDumpContainer); if (retryCount == _configuration.MaxRetryCount) { @@ -168,6 +173,8 @@ private async ValueTask ShutdownAsync() _context.Scope?.Dispose(); DirectoryHelper.SafelyDeleteDirectoryIfExists(DirectoryPaths.GetTempSubDirectoryPath(_context.Id)); + + _context.FailureDumpContainer.Clear(); } _sqlServerManager?.Dispose(); @@ -209,7 +216,11 @@ private Exception PrepareAndLogException(Exception ex) return ex; } - private async Task CreateFailureDumpAsync(Exception ex, string dumpRootPath, int retryCount) + private async Task CreateFailureDumpAsync( + Exception ex, + string dumpRootPath, + int retryCount, + Dictionary>> failureDumpContainer) { var dumpContainerPath = Path.Combine(dumpRootPath, $"Attempt {retryCount.ToTechnicalString()}"); var debugInformationPath = Path.Combine(dumpContainerPath, "DebugInformation"); @@ -255,6 +266,14 @@ await File.WriteAllLinesAsync( if (_dumpConfiguration.CaptureAppSnapshot) await CaptureAppSnapshotAsync(dumpContainerPath); CaptureMarkupValidationResults(ex, debugInformationPath); + + if (failureDumpContainer != null) + { + foreach (var toDump in failureDumpContainer) + { + await SaveFailureDumpFromContextAsync(debugInformationPath, toDump.Key, toDump.Value); + } + } } catch (Exception dumpException) { @@ -267,6 +286,30 @@ await File.WriteAllLinesAsync( } } + private async Task SaveFailureDumpFromContextAsync( + string debugInformationPath, + string dumpRelativePath, + Func> dumpAction) + { + try + { + using var dumpStream = await dumpAction(); + string filePath = Path.Combine(debugInformationPath, dumpRelativePath); + FileSystemHelper.EnsureDirectoryExists(Path.GetDirectoryName(filePath)); + + using var dumpFile = File.Open( + filePath, + FileMode.Create, + FileAccess.Write); + await dumpStream.CopyToAsync(dumpFile); + } + catch (Exception dumpException) + { + _testOutputHelper.WriteLineTimestampedAndDebug( + $"Saving dump({dumpRelativePath}) of the test from context failed with the following exception: {dumpException}"); + } + } + private async Task SaveTestOutputAsync(string debugInformationPath) { try From 5493753e3ede09441c61df5995c52076446a1b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Horv=C3=A1th?= Date: Fri, 27 May 2022 20:58:42 +0200 Subject: [PATCH 6/8] disabling hw acceleration in chrome driver config --- Lombiq.Tests.UI/Services/WebDriverFactory.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lombiq.Tests.UI/Services/WebDriverFactory.cs b/Lombiq.Tests.UI/Services/WebDriverFactory.cs index 7b1eaad67..cafaf0099 100644 --- a/Lombiq.Tests.UI/Services/WebDriverFactory.cs +++ b/Lombiq.Tests.UI/Services/WebDriverFactory.cs @@ -39,6 +39,9 @@ ChromeDriver CreateDriverInner(ChromeDriverService service) // https://developers.google.com/web/tools/puppeteer/troubleshooting#tips for more information. chromeConfig.Options.AddArgument("disable-dev-shm-usage"); + chromeConfig.Options.AddArgument("disable-accelerated-2d-canvas"); + chromeConfig.Options.AddArgument("disable-gpu"); + if (configuration.Headless) chromeConfig.Options.AddArgument("headless"); configuration.BrowserOptionsConfigurator?.Invoke(chromeConfig.Options); From 01363d5c0237cd2d2ef492f58be60dc7226f2229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Horv=C3=A1th?= Date: Sat, 28 May 2022 12:28:38 +0200 Subject: [PATCH 7/8] adding comments --- .../FailureDumpUITestContextExtensions.cs | 15 +++++++++++++++ Lombiq.Tests.UI/Services/WebDriverFactory.cs | 1 + 2 files changed, 16 insertions(+) diff --git a/Lombiq.Tests.UI/Extensions/FailureDumpUITestContextExtensions.cs b/Lombiq.Tests.UI/Extensions/FailureDumpUITestContextExtensions.cs index 692d56e9c..22d927e64 100644 --- a/Lombiq.Tests.UI/Extensions/FailureDumpUITestContextExtensions.cs +++ b/Lombiq.Tests.UI/Extensions/FailureDumpUITestContextExtensions.cs @@ -9,6 +9,12 @@ namespace Lombiq.Tests.UI.Extensions; public static class FailureDumpUITestContextExtensions { + /// + /// Appends stream as file content to be collected on failure dump. + /// + /// instance. + /// The name of the file. + /// Gets called in failure dump collection. public static void AppendFailureDump( this UITestContext context, string fileName, @@ -17,6 +23,15 @@ public static void AppendFailureDump( fileName, () => action(context)); + /// + /// Appends string as file content to be collected on failure dump. + /// + /// instance. + /// The name of the file. + /// + /// File content. Can be a composite format string . + /// + /// An object array that contains zero or more objects to format. public static void AppendFailureDump( this UITestContext context, string fileName, diff --git a/Lombiq.Tests.UI/Services/WebDriverFactory.cs b/Lombiq.Tests.UI/Services/WebDriverFactory.cs index cafaf0099..058bdaa01 100644 --- a/Lombiq.Tests.UI/Services/WebDriverFactory.cs +++ b/Lombiq.Tests.UI/Services/WebDriverFactory.cs @@ -39,6 +39,7 @@ ChromeDriver CreateDriverInner(ChromeDriverService service) // https://developers.google.com/web/tools/puppeteer/troubleshooting#tips for more information. chromeConfig.Options.AddArgument("disable-dev-shm-usage"); + // Disabling hardware acceleration to avoid hardware dependent issues in rendering and visual validation. chromeConfig.Options.AddArgument("disable-accelerated-2d-canvas"); chromeConfig.Options.AddArgument("disable-gpu"); From 4c37acd1bb6b1013ac7b5214e014b68b0d401a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zsef=20Horv=C3=A1th?= Date: Mon, 30 May 2022 07:34:38 +0200 Subject: [PATCH 8/8] removing unnecessary Configuration from .htmlvalidate.json removing unnecessary warning suppression --- Lombiq.Tests.UI.Samples/.htmlvalidate.json | 13 +------------ Lombiq.Tests.UI/.htmlvalidate.json | 13 +------------ Lombiq.Tests.UI/Services/UITestContext.cs | 7 ++----- Lombiq.Tests.UI/Services/UITestExecutionSession.cs | 4 ++-- 4 files changed, 6 insertions(+), 31 deletions(-) diff --git a/Lombiq.Tests.UI.Samples/.htmlvalidate.json b/Lombiq.Tests.UI.Samples/.htmlvalidate.json index 1103b748a..1b8ade5cf 100644 --- a/Lombiq.Tests.UI.Samples/.htmlvalidate.json +++ b/Lombiq.Tests.UI.Samples/.htmlvalidate.json @@ -15,16 +15,5 @@ "wcag/h37": "off", "wcag/h67": "off", "wcag/h71": "off" - }, - - "elements": [ - "html5", - { - "form": { - "attributes": { - "method": [ "get", "post", "GET", "POST" ] - } - } - } - ] + } } diff --git a/Lombiq.Tests.UI/.htmlvalidate.json b/Lombiq.Tests.UI/.htmlvalidate.json index 87a12b125..586300dca 100644 --- a/Lombiq.Tests.UI/.htmlvalidate.json +++ b/Lombiq.Tests.UI/.htmlvalidate.json @@ -13,16 +13,5 @@ "wcag/h37": "off", "wcag/h67": "off", "wcag/h71": "off" - }, - - "elements": [ - "html5", - { - "form": { - "attributes": { - "method": [ "get", "post", "GET", "POST" ] - } - } - } - ] + } } diff --git a/Lombiq.Tests.UI/Services/UITestContext.cs b/Lombiq.Tests.UI/Services/UITestContext.cs index 8b923c722..6406bf4f0 100644 --- a/Lombiq.Tests.UI/Services/UITestContext.cs +++ b/Lombiq.Tests.UI/Services/UITestContext.cs @@ -80,11 +80,8 @@ public class UITestContext /// /// Gets a dictionary storing some custom data for collecting in failure dump. /// - [SuppressMessage( - "Design", - "MA0016:Prefer return collection abstraction instead of implementation", - Justification = "Deliberately modifiable by consumer code.")] - public Dictionary>> FailureDumpContainer { get; } = new(); + public IDictionary>> FailureDumpContainer { get; } + = new Dictionary>>(); /// /// Gets or sets the current tenant name when testing multi-tenancy. When testing sites with multi-tenancy you diff --git a/Lombiq.Tests.UI/Services/UITestExecutionSession.cs b/Lombiq.Tests.UI/Services/UITestExecutionSession.cs index 3fe0be458..7ceffdef2 100644 --- a/Lombiq.Tests.UI/Services/UITestExecutionSession.cs +++ b/Lombiq.Tests.UI/Services/UITestExecutionSession.cs @@ -59,7 +59,7 @@ public UITestExecutionSession(UITestManifest testManifest, OrchardCoreUITestExec public async Task ExecuteAsync(int retryCount, string dumpRootPath) { var startTime = DateTime.UtcNow; - Dictionary>> failureDumpContainer = null; + IDictionary>> failureDumpContainer = null; _testOutputHelper.WriteLineTimestampedAndDebug("Starting execution of {0}.", _testManifest.Name); @@ -220,7 +220,7 @@ private async Task CreateFailureDumpAsync( Exception ex, string dumpRootPath, int retryCount, - Dictionary>> failureDumpContainer) + IDictionary>> failureDumpContainer) { var dumpContainerPath = Path.Combine(dumpRootPath, $"Attempt {retryCount.ToTechnicalString()}"); var debugInformationPath = Path.Combine(dumpContainerPath, "DebugInformation");