From 61de77f6be8c603a36a3f078362d32529c542df1 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Mon, 27 Sep 2021 16:52:44 +0200 Subject: [PATCH 01/29] Implemented debug dashboard with hardcoded data --- .../components/application/umb-drawer.less | 25 +++++++---- .../common/drawers/help/help.controller.js | 40 ++++++++++++------ .../src/views/common/drawers/help/help.html | 41 +++++++++++++++++++ 3 files changed, 87 insertions(+), 19 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/less/components/application/umb-drawer.less b/src/Umbraco.Web.UI.Client/src/less/components/application/umb-drawer.less index 5c77a15ec702..7660e930a5d1 100644 --- a/src/Umbraco.Web.UI.Client/src/less/components/application/umb-drawer.less +++ b/src/Umbraco.Web.UI.Client/src/less/components/application/umb-drawer.less @@ -101,9 +101,9 @@ } /* Make sure typography looks good */ -.umb-help-article h1, -.umb-help-article h2, -.umb-help-article h3, +.umb-help-article h1, +.umb-help-article h2, +.umb-help-article h3, .umb-help-article h4 { line-height: 1.3em; font-weight: bold; @@ -138,7 +138,7 @@ } .umb-help-section__title { - margin:0 0 10px; + margin:0 0 10px; } /* Help list */ @@ -147,10 +147,10 @@ list-style: none; margin-left: 0; margin-bottom: 0; - background: @white; + background: @white; border-radius: 3px; box-shadow: 0 1px 1px 0 rgba(0,0,0,0.16); - + [data-element*="help-tours"] & { margin-bottom:5px; } @@ -166,9 +166,20 @@ border: 0 none; } + .umb-help-list-item:last-child { border-bottom: none; } +.umb-help-list-item__title-wrapper { + display:flex; + justify-content: space-between; + align-items: center; + + .umb-help-list-item { + flex: 1 0 auto; + width: auto; + } +} .umb-help-list-item__group-title i { margin-right:2px; @@ -185,7 +196,7 @@ .umb-help-list-item:hover, .umb-help-list-item:focus, .umb-help-list-item:active, -.umb-help-list-item > a:hover, +.umb-help-list-item > a:hover, .umb-help-list-item > a:focus, .umb-help-list-item > a:active { text-decoration: none; diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js index c212a0895190..78adf1038524 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js @@ -1,11 +1,10 @@ (function () { "use strict"; - function HelpDrawerController($scope, $routeParams, $timeout, dashboardResource, localizationService, userService, eventsService, helpService, appState, tourService, $filter, editorState) { + function HelpDrawerController($scope, $routeParams, $timeout, dashboardResource, localizationService, userService, eventsService, helpService, appState, tourService, $filter, editorState, notificationsService) { var vm = this; var evts = []; - vm.title = ""; vm.subtitle = "Umbraco version" + " " + Umbraco.Sys.ServerVariables.application.version; vm.section = $routeParams.section; @@ -13,16 +12,20 @@ vm.sectionName = ""; vm.customDashboard = null; vm.tours = []; + vm.systemInfoDisplay = false; vm.closeDrawer = closeDrawer; vm.startTour = startTour; vm.getTourGroupCompletedPercentage = getTourGroupCompletedPercentage; vm.showTourButton = showTourButton; + vm.copyInformation = copyInformation; vm.showDocTypeTour = false; vm.docTypeTours = []; + vm.systemInfo = [{name : "Umbraco Version", data : "9.0.0-rc004"}, {name : "Operating System", data : "Windows"}, {name : "Current Culture", data : "en-US"}, {name : "Current UI Culture", data : "dn-DK"}, + {name : "Webserver", data : "Kestrel"}, {name : "Packages", data : "Umbraco.TheStarterKit, uSync"}, {name : "Browser", data : "Electron"}] vm.nodeName = ''; - + function startTour(tour) { tourService.startTour(tour); closeDrawer(); @@ -52,11 +55,11 @@ setSectionName(); userService.getCurrentUser().then(function (user) { - + vm.userType = user.userType; vm.userLang = user.locale; - vm.hasAccessToSettings = _.contains(user.allowedSections, 'settings'); + vm.hasAccessToSettings = _.contains(user.allowedSections, 'settings'); evts.push(eventsService.on("appState.treeState.changed", function (e, args) { handleSectionChange(); @@ -72,7 +75,7 @@ }); setDocTypeTour(editorState.getCurrent()); - + // check if a tour is running - if it is open the matching group var currentTour = tourService.getCurrentTour(); @@ -89,7 +92,7 @@ function handleSectionChange() { $timeout(function () { if (vm.section !== $routeParams.section || vm.tree !== $routeParams.tree) { - + vm.section = $routeParams.section; vm.tree = $routeParams.tree; @@ -107,7 +110,7 @@ vm.topics = topics; }); } - + var rq = {}; rq.section = vm.section; @@ -134,7 +137,7 @@ helpService.findVideos(rq).then(function (videos) { vm.videos = videos; }); - } + } } function setSectionName() { @@ -190,7 +193,7 @@ tourService.getToursForDoctype(node.contentTypeAlias).then(function (data) { if (data && data.length > 0) { vm.docTypeTours = data; - var currentVariant = _.find(node.variants, (x) => x.active); + var currentVariant = _.find(node.variants, (x) => x.active); vm.nodeName = currentVariant.name; vm.showDocTypeTour = true; } @@ -198,7 +201,20 @@ } } } - + function copyInformation(){ + let copyText = "\n\n\n\nCategory | Data\n-- | --\n"; + vm.systemInfo.forEach(function (info){ + copyText += info.name + " | " + info.data + "\n"; + }); + copyText += "\n\n\n" + navigator.clipboard.writeText(copyText); + if(copyText != null || copyText != ""){ + notificationsService.success("Copied!", "Your system information is now in your clipboard"); + } + else{ + notificationsService.error("Sadge", "something failed"); + } + } evts.push(eventsService.on("appState.tour.complete", function (event, tour) { tourService.getGroupedTours().then(function(groupedTours) { vm.tours = groupedTours; @@ -206,7 +222,7 @@ getTourGroupCompletedPercentage(); }); })); - + $scope.$on('$destroy', function () { for (var e in evts) { eventsService.unsubscribe(evts[e]); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html index 82a37e6efbff..6f32e89988fd 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.html @@ -149,6 +149,47 @@
+ +
+ +
System Information
+
+
+ + +
+
+ + + + + + + + + +
CategoryData
{{info.name}}{{info.data}}
+
+
+
From 4ea1f46f2b3b26f0ca3fa3f4fa4517ecab217db6 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Thu, 30 Sep 2021 13:09:04 +0200 Subject: [PATCH 02/29] Implemented variable data instead of hardcoded --- .../DependencyInjection/UmbracoBuilder.cs | 3 + src/Umbraco.Core/Models/UserData.cs | 19 ++++ src/Umbraco.Core/Services/IUserDataService.cs | 10 +++ src/Umbraco.Core/Services/UserDataService.cs | 57 ++++++++++++ .../Controllers/CurrentUserController.cs | 11 ++- .../common/resources/currentuser.resource.js | 9 +- .../src/common/services/platform.service.js | 87 ++++++++++++++++--- .../common/drawers/help/help.controller.js | 43 +++++++-- 8 files changed, 214 insertions(+), 25 deletions(-) create mode 100644 src/Umbraco.Core/Models/UserData.cs create mode 100644 src/Umbraco.Core/Services/IUserDataService.cs create mode 100644 src/Umbraco.Core/Services/UserDataService.cs diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs index 6f6a53df66b3..5185e5387ae4 100644 --- a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs @@ -26,6 +26,8 @@ using Umbraco.Cms.Core.Logging; using Umbraco.Cms.Core.Mail; using Umbraco.Cms.Core.Manifest; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Models.Membership; using Umbraco.Cms.Core.Models.PublishedContent; using Umbraco.Cms.Core.Notifications; using Umbraco.Cms.Core.PropertyEditors; @@ -179,6 +181,7 @@ private void AddCoreServices() Services.AddUnique(); Services.AddUnique(); + Services.AddUnique(); // will be injected in controllers when needed to invoke rest endpoints on Our Services.AddUnique(); diff --git a/src/Umbraco.Core/Models/UserData.cs b/src/Umbraco.Core/Models/UserData.cs new file mode 100644 index 000000000000..07b45b3c547b --- /dev/null +++ b/src/Umbraco.Core/Models/UserData.cs @@ -0,0 +1,19 @@ +using System.Runtime.Serialization; + +namespace Umbraco.Cms.Core.Models +{ + [DataContract] + public class UserData + { + [DataMember(Name = "name")] + public string Name { get; } + [DataMember(Name = "data")] + public string Data { get; } + + public UserData(string name, string data) + { + Name = name; + Data = data; + } + } +} diff --git a/src/Umbraco.Core/Services/IUserDataService.cs b/src/Umbraco.Core/Services/IUserDataService.cs new file mode 100644 index 000000000000..e63ee3f6973c --- /dev/null +++ b/src/Umbraco.Core/Services/IUserDataService.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using Umbraco.Cms.Core.Models; + +namespace Umbraco.Cms.Core.Services +{ + public interface IUserDataService + { + IEnumerable GetUserData(); + } +} diff --git a/src/Umbraco.Core/Services/UserDataService.cs b/src/Umbraco.Core/Services/UserDataService.cs new file mode 100644 index 000000000000..87a92d199f63 --- /dev/null +++ b/src/Umbraco.Core/Services/UserDataService.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Threading; +using Umbraco.Cms.Core.Configuration; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Web; +using Umbraco.Extensions; + +namespace Umbraco.Cms.Core.Services +{ + public class UserDataService : IUserDataService + { + private IUmbracoVersion _version; + public UserDataService(IUmbracoVersion version) + { + _version = version; + } + + public IEnumerable GetUserData() + { + + var userDataList = new List + { + + new UserData("Server OS", Environment.OSVersion.VersionString), + new UserData("Umbraco Version", _version.SemanticVersion.ToSemanticStringWithoutBuild()), + new UserData("Current Culture", Thread.CurrentThread.CurrentCulture.ToString()), + new UserData("Current UI Culture", Thread.CurrentThread.CurrentUICulture.ToString()), + new UserData("Current Webserver", GetCurrentWebServer()) + }; + return userDataList; + } + + public string GetCurrentWebServer() + { + if (IsRunningInProcessIIS()) + { + return "IIS"; + } + + return "Kestrel"; + } + public bool IsRunningInProcessIIS() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return false; + } + + string processName = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().ProcessName); + return (processName.Contains("w3wp") || processName.Contains("iisexpress")); + } + } +} diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index ba6ca3608583..b7e4612b6e15 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -22,9 +22,7 @@ using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; -using Umbraco.Cms.Web.BackOffice.Extensions; using Umbraco.Cms.Web.BackOffice.Filters; -using Umbraco.Cms.Web.Common.ActionsResults; using Umbraco.Cms.Web.Common.Attributes; using Umbraco.Cms.Web.Common.Authorization; using Umbraco.Cms.Web.Common.Security; @@ -47,11 +45,11 @@ public class CurrentUserController : UmbracoAuthorizedJsonController private readonly IUserService _userService; private readonly IUmbracoMapper _umbracoMapper; private readonly IBackOfficeUserManager _backOfficeUserManager; - private readonly ILoggerFactory _loggerFactory; private readonly ILocalizedTextService _localizedTextService; private readonly AppCaches _appCaches; private readonly IShortStringHelper _shortStringHelper; private readonly IPasswordChanger _passwordChanger; + private readonly IUserDataService _userDataService; public CurrentUserController( MediaFileManager mediaFileManager, @@ -62,11 +60,11 @@ public CurrentUserController( IUserService userService, IUmbracoMapper umbracoMapper, IBackOfficeUserManager backOfficeUserManager, - ILoggerFactory loggerFactory, ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, - IPasswordChanger passwordChanger) + IPasswordChanger passwordChanger, + IUserDataService userDataService) { _mediaFileManager = mediaFileManager; _contentSettings = contentSettings.Value; @@ -76,11 +74,11 @@ public CurrentUserController( _userService = userService; _umbracoMapper = umbracoMapper; _backOfficeUserManager = backOfficeUserManager; - _loggerFactory = loggerFactory; _localizedTextService = localizedTextService; _appCaches = appCaches; _shortStringHelper = shortStringHelper; _passwordChanger = passwordChanger; + _userDataService = userDataService; } @@ -166,6 +164,7 @@ public IEnumerable GetUserTours() var userTours = JsonConvert.DeserializeObject>(_backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.TourData); return userTours; } + public IEnumerable GetUserData() => _userDataService.GetUserData(); /// /// When a user is invited and they click on the invitation link, they will be partially logged in diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js index a3be6996b1b8..23870d882f17 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/currentuser.resource.js @@ -51,7 +51,6 @@ function currentUserResource($q, $http, umbRequestHelper, umbDataFormatter) { [{ permissionToCheck: permission }, { nodeId: id }])), 'Failed to check permission for item ' + id); }, - getCurrentUserLinkedLogins: function () { return umbRequestHelper.resourcePromise( @@ -61,6 +60,14 @@ function currentUserResource($q, $http, umbRequestHelper, umbDataFormatter) { "GetCurrentUserLinkedLogins")), 'Server call failed for getting current users linked logins'); }, + getUserData: function () { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "currentUserApiBaseUrl", + "GetUserData")), + 'Server call failed for getting current user data'); + }, saveTourStatus: function (tourStatus) { diff --git a/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js b/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js index 7834c2f781ab..acd953315152 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/platform.service.js @@ -1,23 +1,84 @@ -(function() { - 'use strict'; +(function () { + 'use strict'; - function platformService() { + function platformService() { + const userAgentRules = [ + ['Aol', /AOLShield\/([0-9\._]+)/], + ['Edge', /Edge\/([0-9\._]+)/], + ['Edge-ios', /EdgiOS\/([0-9\._]+)/], + ['Yandexbrowser', /YaBrowser\/([0-9\._]+)/], + ['Kakaotalk', /KAKAOTALK\s([0-9\.]+)/], + ['Samsung', /SamsungBrowser\/([0-9\.]+)/], + ['Silk', /\bSilk\/([0-9._-]+)\b/], + ['MiUI', /MiuiBrowser\/([0-9\.]+)$/], + ['Beaker', /BeakerBrowser\/([0-9\.]+)/], + ['Edge-chromium', /EdgA?\/([0-9\.]+)/], + ['chromium-webview', /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ['Chrome', /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ['PhantomJS', /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ['Crios', /CriOS\/([0-9\.]+)(:?\s|$)/], + ['Firefox', /Firefox\/([0-9\.]+)(?:\s|$)/], + ['FxiOS', /FxiOS\/([0-9\.]+)/], + ['Opera-mini', /Opera Mini.*Version\/([0-9\.]+)/], + ['Opera', /Opera\/([0-9\.]+)(?:\s|$)/], + ['Opera', /OPR\/([0-9\.]+)(:?\s|$)/], + ['IE', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ['IE', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ['IE', /MSIE\s(7\.0)/], + ['BB10', /BB10;\sTouch.*Version\/([0-9\.]+)/], + ['Android', /Android\s([0-9\.]+)/], + ['iOS', /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ['Safari', /Version\/([0-9\._]+).*Safari/], + ['Facebook', /FB[AS]V\/([0-9\.]+)/], + ['Instagram', /Instagram\s([0-9\.]+)/], + ['iOS-webview', /AppleWebKit\/([0-9\.]+).*Mobile/], + ['iOS-webview', /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ['Curl', /^curl\/([0-9\.]+)$/] + ]; - function isMac() { - return navigator.platform.toUpperCase().indexOf('MAC')>=0; - } + function isMac() { + return navigator.platform.toUpperCase().indexOf('MAC') >= 0; + } - //////////// - - var service = { - isMac: isMac + function getBrowserInfo(){ + let data = matchUserAgent(navigator.userAgent); + console.log(data); + if(data){ + const test = data[1]; + return { + name : data[0], + version : test[1] }; + } + return null; + } + + function matchUserAgent(ua) { + return (ua !== '' && userAgentRules.reduce ( + (matched, [browser, regex]) => { + if (matched) { + return matched; + } + const uaMatch = regex.exec(ua); + return !!uaMatch && [browser, uaMatch]; + }, + false + ) + ); + } + + //////////// + + var service = { + isMac: isMac, + getBrowserInfo : getBrowserInfo + }; - return service; + return service; - } + } - angular.module('umbraco.services').factory('platformService', platformService); + angular.module('umbraco.services').factory('platformService', platformService); })(); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js index 78adf1038524..f58d42f22d3c 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js @@ -1,7 +1,7 @@ (function () { "use strict"; - function HelpDrawerController($scope, $routeParams, $timeout, dashboardResource, localizationService, userService, eventsService, helpService, appState, tourService, $filter, editorState, notificationsService) { + function HelpDrawerController($scope, $routeParams, $timeout, dashboardResource, localizationService, userService, eventsService, helpService, appState, tourService, $filter, editorState, notificationsService, currentUserResource, platformService) { var vm = this; var evts = []; @@ -22,8 +22,7 @@ vm.showDocTypeTour = false; vm.docTypeTours = []; - vm.systemInfo = [{name : "Umbraco Version", data : "9.0.0-rc004"}, {name : "Operating System", data : "Windows"}, {name : "Current Culture", data : "en-US"}, {name : "Current UI Culture", data : "dn-DK"}, - {name : "Webserver", data : "Kestrel"}, {name : "Packages", data : "Umbraco.TheStarterKit, uSync"}, {name : "Browser", data : "Electron"}] + vm.systemInfo = []; vm.nodeName = ''; function startTour(tour) { @@ -37,7 +36,14 @@ localizationService.localize("general_help").then(function(data){ vm.title = data; }); - + currentUserResource.getUserData().then(function(systemInfo){ + vm.systemInfo = systemInfo; + let browserInfo = platformService.getBrowserInfo(); + if(browserInfo != null){ + vm.systemInfo.push({name :"Browser", data: browserInfo.name + " " + browserInfo.version}); + } + vm.systemInfo.push({name :"User OS", data: getPlatform()}); + }); tourService.getGroupedTours().then(function(groupedTours) { vm.tours = groupedTours; getTourGroupCompletedPercentage(); @@ -208,13 +214,40 @@ }); copyText += "\n\n\n" navigator.clipboard.writeText(copyText); - if(copyText != null || copyText != ""){ + if(copyText != null){ notificationsService.success("Copied!", "Your system information is now in your clipboard"); } else{ notificationsService.error("Sadge", "something failed"); } } + function getPlatform() { + const allPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE', 'Android', 'iPhone', 'iPad', 'iPod']; + return allPlatforms.find(item => item === window.navigator.platform); + } + function getCurrentBrowser(){ + let sBrowser, sUsrAg = window.navigator.userAgent; + if (sUsrAg.indexOf("Firefox") > -1) { + sBrowser = "Mozilla Firefox"; + } else if (sUsrAg.indexOf("SamsungBrowser") > -1) { + sBrowser = "Samsung Internet"; + } else if (sUsrAg.indexOf("Opera") > -1 || sUsrAg.indexOf("OPR") > -1) { + sBrowser = "Opera"; + } else if (sUsrAg.indexOf("Trident") > -1) { + sBrowser = "Microsoft Internet Explorer"; + } else if (sUsrAg.indexOf("Edge") > -1) { + sBrowser = "Microsoft Edge (Legacy)"; + } else if (sUsrAg.indexOf("Edg") > -1) { + sBrowser = "Microsoft Edge (Chromium)"; + } else if (sUsrAg.indexOf("Chrome") > -1) { + sBrowser = "Google Chrome or Chromium"; + } else if (sUsrAg.indexOf("Safari") > -1) { + sBrowser = "Apple Safari"; + } else { + sBrowser = "unknown"; + } + return sBrowser; + } evts.push(eventsService.on("appState.tour.complete", function (event, tour) { tourService.getGroupedTours().then(function(groupedTours) { vm.tours = groupedTours; From 95568b21af5597a31e415342c3a86d711ad5bcc8 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Thu, 30 Sep 2021 13:36:54 +0200 Subject: [PATCH 03/29] Updated to display framework --- src/Umbraco.Core/Services/UserDataService.cs | 5 ++--- .../Controllers/CurrentUserController.cs | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Services/UserDataService.cs b/src/Umbraco.Core/Services/UserDataService.cs index 87a92d199f63..52c88070194a 100644 --- a/src/Umbraco.Core/Services/UserDataService.cs +++ b/src/Umbraco.Core/Services/UserDataService.cs @@ -21,11 +21,10 @@ public UserDataService(IUmbracoVersion version) public IEnumerable GetUserData() { - var userDataList = new List { - - new UserData("Server OS", Environment.OSVersion.VersionString), + new UserData("Server OS", RuntimeInformation.OSDescription), + new UserData("Server Framework", RuntimeInformation.FrameworkDescription), new UserData("Umbraco Version", _version.SemanticVersion.ToSemanticStringWithoutBuild()), new UserData("Current Culture", Thread.CurrentThread.CurrentCulture.ToString()), new UserData("Current UI Culture", Thread.CurrentThread.CurrentUICulture.ToString()), diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index b7e4612b6e15..b584a0693068 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -164,7 +165,12 @@ public IEnumerable GetUserTours() var userTours = JsonConvert.DeserializeObject>(_backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.TourData); return userTours; } - public IEnumerable GetUserData() => _userDataService.GetUserData(); + public IEnumerable GetUserData() + { + var variablesFeature = HttpContext.Features.Get(); + return _userDataService.GetUserData(); + + } /// /// When a user is invited and they click on the invitation link, they will be partially logged in From c4e14d183d5697544915a1497e2c4394373ba81c Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Thu, 30 Sep 2021 14:21:14 +0200 Subject: [PATCH 04/29] Updated to display default language --- src/Umbraco.Core/Services/UserDataService.cs | 5 +++- .../common/drawers/help/help.controller.js | 25 +------------------ 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/Umbraco.Core/Services/UserDataService.cs b/src/Umbraco.Core/Services/UserDataService.cs index 52c88070194a..5af7374a5f9d 100644 --- a/src/Umbraco.Core/Services/UserDataService.cs +++ b/src/Umbraco.Core/Services/UserDataService.cs @@ -14,9 +14,11 @@ namespace Umbraco.Cms.Core.Services public class UserDataService : IUserDataService { private IUmbracoVersion _version; - public UserDataService(IUmbracoVersion version) + private readonly ILocalizationService _localizationService; + public UserDataService(IUmbracoVersion version, ILocalizationService localizationService) { _version = version; + _localizationService = localizationService; } public IEnumerable GetUserData() @@ -25,6 +27,7 @@ public IEnumerable GetUserData() { new UserData("Server OS", RuntimeInformation.OSDescription), new UserData("Server Framework", RuntimeInformation.FrameworkDescription), + new UserData("Default Language", _localizationService.GetDefaultLanguageIsoCode()), new UserData("Umbraco Version", _version.SemanticVersion.ToSemanticStringWithoutBuild()), new UserData("Current Culture", Thread.CurrentThread.CurrentCulture.ToString()), new UserData("Current UI Culture", Thread.CurrentThread.CurrentUICulture.ToString()), diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js index f58d42f22d3c..ac1b0ac1a1d9 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js @@ -42,7 +42,7 @@ if(browserInfo != null){ vm.systemInfo.push({name :"Browser", data: browserInfo.name + " " + browserInfo.version}); } - vm.systemInfo.push({name :"User OS", data: getPlatform()}); + vm.systemInfo.push({name :"Browser OS", data: getPlatform()}); }); tourService.getGroupedTours().then(function(groupedTours) { vm.tours = groupedTours; @@ -225,29 +225,6 @@ const allPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE', 'Android', 'iPhone', 'iPad', 'iPod']; return allPlatforms.find(item => item === window.navigator.platform); } - function getCurrentBrowser(){ - let sBrowser, sUsrAg = window.navigator.userAgent; - if (sUsrAg.indexOf("Firefox") > -1) { - sBrowser = "Mozilla Firefox"; - } else if (sUsrAg.indexOf("SamsungBrowser") > -1) { - sBrowser = "Samsung Internet"; - } else if (sUsrAg.indexOf("Opera") > -1 || sUsrAg.indexOf("OPR") > -1) { - sBrowser = "Opera"; - } else if (sUsrAg.indexOf("Trident") > -1) { - sBrowser = "Microsoft Internet Explorer"; - } else if (sUsrAg.indexOf("Edge") > -1) { - sBrowser = "Microsoft Edge (Legacy)"; - } else if (sUsrAg.indexOf("Edg") > -1) { - sBrowser = "Microsoft Edge (Chromium)"; - } else if (sUsrAg.indexOf("Chrome") > -1) { - sBrowser = "Google Chrome or Chromium"; - } else if (sUsrAg.indexOf("Safari") > -1) { - sBrowser = "Apple Safari"; - } else { - sBrowser = "unknown"; - } - return sBrowser; - } evts.push(eventsService.on("appState.tour.complete", function (event, tour) { tourService.getGroupedTours().then(function(groupedTours) { vm.tours = groupedTours; From 22ca2908849b90b5b57dbd68df3614945f178e2c Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Thu, 30 Sep 2021 15:51:21 +0200 Subject: [PATCH 05/29] Added Unit Tests --- src/Umbraco.Core/Services/UserDataService.cs | 4 +- .../Services/UserDataServiceTests.cs | 112 ++++++++++++++++++ .../Controllers/CurrentUserController.cs | 4 - 3 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs diff --git a/src/Umbraco.Core/Services/UserDataService.cs b/src/Umbraco.Core/Services/UserDataService.cs index 5af7374a5f9d..b76d9e3ae3d7 100644 --- a/src/Umbraco.Core/Services/UserDataService.cs +++ b/src/Umbraco.Core/Services/UserDataService.cs @@ -1,12 +1,10 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Threading; using Umbraco.Cms.Core.Configuration; using Umbraco.Cms.Core.Models; -using Umbraco.Cms.Core.Web; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Services diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs new file mode 100644 index 000000000000..23db68513e7f --- /dev/null +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs @@ -0,0 +1,112 @@ +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Threading; +using Moq; +using NUnit.Framework; +using Umbraco.Cms.Core.Configuration; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Semver; +using Umbraco.Cms.Core.Services; + +namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services +{ + [TestFixture] + public class UserDataServiceTests + { + private IUmbracoVersion _umbracoVersion; + private ILocalizationService _localizationService; + + [SetUp] + public void CreateMocks() + { + CreateUmbracoVersion(9, 0, 0); + } + + [Test] + [TestCase("en-US")] + [TestCase("de-DE")] + [TestCase("en-NZ")] + [TestCase("sv-SE")] + public void GetCorrectDefaultLanguageTest(string culture) + { + CreateLocalizationVersion(culture); + var userDataService = new UserDataService(_umbracoVersion, _localizationService); + var defaultLanguage = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Default Language"); + Assert.Multiple(() => + { + Assert.IsNotNull(defaultLanguage); + Assert.AreEqual(culture, defaultLanguage.Data); + }); + } + + [Test] + [TestCase("en-US")] + [TestCase("de-DE")] + [TestCase("en-NZ")] + [TestCase("sv-SE")] + public void GetCorrectCultureTest(string culture) + { + Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); + CreateLocalizationVersion(culture); + var userDataService = new UserDataService(_umbracoVersion, _localizationService); + var currentCulture = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Current Culture"); + Assert.Multiple(() => + { + Assert.IsNotNull(currentCulture); + Assert.AreEqual(culture, currentCulture.Data); + }); + } + + [Test] + [TestCase("en-US")] + [TestCase("de-DE")] + [TestCase("en-NZ")] + [TestCase("sv-SE")] + public void GetCorrectUICultureTest(string culture) + { + Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); + CreateLocalizationVersion(culture); + var userDataService = new UserDataService(_umbracoVersion, _localizationService); + var currentCulture = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Current UI Culture"); + Assert.Multiple(() => + { + Assert.IsNotNull(currentCulture); + Assert.AreEqual(culture, currentCulture.Data); + }); + } + + [Test] + [TestCase("en-US")] + [TestCase("de-DE")] + [TestCase("en-NZ")] + [TestCase("sv-SE")] + public void RunTimeInformationNotNullTest(string culture) + { + CreateLocalizationVersion(culture); + var userDataService = new UserDataService(_umbracoVersion, _localizationService); + IEnumerable userData = userDataService.GetUserData(); + Assert.Multiple(() => + { + Assert.IsNotNull(userData.FirstOrDefault(x => x.Name == "Server OS")); + Assert.IsNotNull(userData.FirstOrDefault(x => x.Name == "Server Framework")); + Assert.IsNotNull(userData.FirstOrDefault(x => x.Name == "Current Webserver")); + }); + } + + private void CreateLocalizationVersion(string culture) + { + var localizationService = new Mock(); + localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns(culture); + _localizationService = localizationService.Object; + } + + private void CreateUmbracoVersion(int major, int minor, int patch) + { + var umbracoVersion = new Mock(); + var semVersion = new SemVersion(major, minor, patch); + umbracoVersion.Setup(x => x.SemanticVersion).Returns(semVersion); + _umbracoVersion = umbracoVersion.Object; + } + } +} diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index b584a0693068..b1ade72b0eab 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -5,9 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json; using Umbraco.Cms.Core; @@ -167,9 +165,7 @@ public IEnumerable GetUserTours() } public IEnumerable GetUserData() { - var variablesFeature = HttpContext.Features.Get(); return _userDataService.GetUserData(); - } /// From d42b51d6f473fe1c8e163ab282cbf17f7f65bbea Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Fri, 1 Oct 2021 10:56:34 +0200 Subject: [PATCH 06/29] Created Cypress test and renamed folder --- .../integration/{Tabs => HelpPanel}/tabs.ts | 0 .../integration/Tour/systemInformation.ts | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+) rename src/Umbraco.Tests.AcceptanceTest/cypress/integration/{Tabs => HelpPanel}/tabs.ts (100%) create mode 100644 src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/systemInformation.ts diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/tabs.ts similarity index 100% rename from src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts rename to src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/tabs.ts diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/systemInformation.ts new file mode 100644 index 000000000000..fe51f9e8899e --- /dev/null +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/systemInformation.ts @@ -0,0 +1,39 @@ +/// + +function openSystemInformation(){ + cy.get('[data-element="global-help"]').click(); + cy.get('.umb-help-list-item').should('be.visible').click(); + cy.get('.umb-drawer-content').scrollTo('bottom', {ensureScrollable : false}); +} + +context('System Information', () => { + + beforeEach(() => { + //arrange + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + }); + + it('Check System Info Displays', () => { + openSystemInformation(); + cy.get('.table').find('tr').should('have.length', 10) + }); + + it('Checks language displays correctly after switching', () => { + //Navigate to edit user and change language + cy.get('[data-element="global-user"]').click(); + cy.get('[alias="editUser"]').click(); + cy.get('.input-block-level').last().select('Danish (Denmark)'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Refresh site to display new language + cy.reload(); + openSystemInformation(); + //Assert + cy.contains('Current Culture').parent().should('contain', 'da-DK'); + cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); + + //Clean + cy.get('.input-block-level').last().select('English (United States)'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + cy.reload(); + }); +}); \ No newline at end of file From ef8a70580d8a772e21ce9132624ff1b69b46c86c Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Fri, 1 Oct 2021 11:20:57 +0200 Subject: [PATCH 07/29] Update help.controller.js --- .../src/views/common/drawers/help/help.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js index ac1b0ac1a1d9..51497d145dcf 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js @@ -218,7 +218,7 @@ notificationsService.success("Copied!", "Your system information is now in your clipboard"); } else{ - notificationsService.error("Sadge", "something failed"); + notificationsService.error("Error", "Could not copy system information"); } } function getPlatform() { From 17e53e497cc5ecb7a7235d52f0bf723c939c5f6f Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Mon, 4 Oct 2021 11:29:14 +0200 Subject: [PATCH 08/29] Fixed Folder structure Signed-off-by: Nikolaj Geisle --- .../cypress/integration/HelpPanel/tabs.ts | 552 ------------------ .../integration/Tour/backofficeTour.ts | 103 ---- .../integration/Tour/systemInformation.ts | 39 -- 3 files changed, 694 deletions(-) delete mode 100644 src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/tabs.ts delete mode 100644 src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts delete mode 100644 src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/systemInformation.ts diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/tabs.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/tabs.ts deleted file mode 100644 index 77729912a6b0..000000000000 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/tabs.ts +++ /dev/null @@ -1,552 +0,0 @@ -/// -import { - DocumentTypeBuilder, - AliasHelper -} from 'umbraco-cypress-testhelpers'; - -const tabsDocTypeName = 'Tabs Test Document'; -const tabsDocTypeAlias = AliasHelper.toAlias(tabsDocTypeName); - -context('Tabs', () => { - - beforeEach(() => { - cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false); - }); - - afterEach(() => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName) - }); - - function OpenDocTypeFolder(){ - cy.umbracoSection('settings'); - cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); - cy.get('.umb-tree-item__inner > .umb-tree-item__arrow').eq(0).click(); - cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(tabsDocTypeName).click(); - } - - function CreateDocWithTabAndNavigate(){ - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - } - - it('Create tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - cy.deleteAllContent(); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addGroup() - .withName('Tabs1Group') - .addUrlPickerProperty() - .withAlias('picker') - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Create a tab - cy.get('.umb-group-builder__tabs__add-tab').click(); - cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 1'); - //Create a 2nd tab manually - cy.get('.umb-group-builder__tabs__add-tab').click(); - cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 2'); - //Create a textstring property - cy.get('[aria-hidden="false"] > .umb-box-content > .umb-group-builder__group-add-property').click(); - cy.get('.editor-label').type('property name'); - cy.get('[data-element="editor-add"]').click(); - - //Search for textstring - cy.get('#datatype-search').type('Textstring'); - - // Choose first item - cy.get('[title="Textstring"]').closest("li").click(); - - // Save property - cy.get('.btn-success').last().click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="tab1"]').should('be.visible'); - cy.get('[title="tab2"]').should('be.visible'); - }); - - it('Delete tabs', () => { - CreateDocWithTabAndNavigate(); - //Check if tab is there, else if it wasnt created, this test would always pass - cy.get('[title="aTab 1"]').should('be.visible'); - //Delete a tab - cy.get('.btn-reset > .icon-trash').click(); - cy.get('.umb-button > .btn').last().click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.get('[title="aTab 1"]').should('not.exist'); - //Clean - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - }); - - it('Delete property in tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .done() - .addContentPickerProperty() - .withAlias('picker') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[aria-label="Delete property"]').last().click(); - cy.umbracoButtonByLabelKey('actions_delete').click(); - cy.umbracoButtonByLabelKey('buttons_save').click() - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title=urlPicker]').should('be.visible'); - cy.get('[title=picker]').should('not.exist'); - }); - - it('Delete group in tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .done() - .done() - .addGroup() - .withName('Content Picker Group') - .addContentPickerProperty() - .withAlias('picker') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Delete group - cy.get('.umb-group-builder__group-remove > .icon-trash').eq(1).click(); - cy.umbracoButtonByLabelKey('actions_delete').click(); - cy.umbracoButtonByLabelKey('buttons_save').click() - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title=picker]').should('be.visible'); - cy.get('[title=urlPicker]').should('not.exist'); - }); - - it('Reorders tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group 1') - .addUrlPickerProperty() - .withLabel('Url picker 1') - .withAlias("urlPicker") - .done() - .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group 2') - .addUrlPickerProperty() - .withLabel('Url picker 2') - .withAlias("pickerTab 2") - .done() - .done() - .done() - .addTab() - .withName('Tab 3') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withLabel('Url picker 3') - .withAlias('pickerTab3') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Check if there are any tabs - cy.get('ng-form.ng-valid-required > .umb-group-builder__group-title-input').should('be.visible'); - cy.get('[alias="reorder"]').click(); - //Type order in - cy.get('.umb-group-builder__tab-sort-order > .umb-property-editor-tiny').first().type('3'); - cy.get('[alias="reorder"]').click(); - //Assert - cy.get('.umb-group-builder__group-title-input').eq(0).invoke('attr', 'title').should('eq', 'aTab 2') - cy.get('.umb-group-builder__group-title-input').eq(1).invoke('attr', 'title').should('eq', 'aTab 3') - cy.get('.umb-group-builder__group-title-input').eq(2).invoke('attr', 'title').should('eq', 'aTab 1') - }); - - it('Reorders groups in a tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group 1') - .addUrlPickerProperty() - .withLabel('Url picker 1') - .withAlias("urlPicker") - .done() - .done() - .addGroup() - .withName('Tab group 2') - .addUrlPickerProperty() - .withLabel('Url picker 2') - .withAlias('urlPickerTwo') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - cy.get('.umb-property-editor-tiny').eq(2).type('1'); - - cy.get('[alias="reorder"]').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('.umb-group-builder__group-title-input').eq(2) - .invoke('attr', 'title').should('eq', 'aTab 1/aTab group 2'); - }); - - it('Reorders properties in a tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withLabel('PickerOne') - .withAlias("urlPicker") - .done() - .addUrlPickerProperty() - .withLabel('PickerTwo') - .withAlias('urlPickerTwo') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Reorder - cy.get('[alias="reorder"]').click(); - cy.get('.umb-group-builder__group-sort-value').first().type('2'); - cy.get('[alias="reorder"]').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('.umb-locked-field__input').last().invoke('attr', 'title').should('eq', 'urlPicker'); - }); - - it('Tab name cannot be empty', () => { - CreateDocWithTabAndNavigate(); - cy.get('.umb-group-builder__group-title-input').first().clear(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoErrorNotification().should('be.visible'); - }); - - it('Two tabs cannot have the same name', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - //Create a 2nd tab manually - cy.get('.umb-group-builder__tabs__add-tab').click(); - cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 1'); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoErrorNotification().should('be.visible'); - }); - - it('Group name cannot be empty', () => { - CreateDocWithTabAndNavigate(); - cy.get('.clearfix > .-placeholder').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoErrorNotification().should('be.visible'); - }); - - it('Group name cannot have the same name', () => { - CreateDocWithTabAndNavigate(); - cy.get('.clearfix > .-placeholder').click(); - cy.get('.umb-group-builder__group-title-input').last().type('Tab group'); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoErrorNotification().should('be.visible'); - }); - - it('Drag a group into another tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .done() - .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group tab 2') - .addUrlPickerProperty() - .withAlias('urlPickerTabTwo') - .done() - .done() - .addGroup() - .withName('Tab group 2') - .addUrlPickerProperty() - .withAlias('urlPickerTwo') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - cy.get('body') - .then(($body) => { - while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ - cy.click(); - } - }); - cy.get('.umb-group-builder__tab').last().click(); - cy.get('.umb-group-builder__group-title-icon').last().trigger('mousedown', { which: 1 }) - cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); - cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active').trigger('mouseup', {force:true}); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="aTab 1/aTab group 2"]').should('be.visible'); - }); - - it('Drag and drop reorders a tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .done() - .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group tab 2') - .addUrlPickerProperty() - .withAlias('urlPickerTabTwo') - .done() - .done() - .addGroup() - .withName('Tab group 2') - .addUrlPickerProperty() - .withAlias('urlPickerTwo') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - //Scroll right so we can see tab 2 - cy.get('body') - .then(($body) => { - while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ - cy.click(); - } - }); - cy.get('.umb-group-builder__tab-title-icon').eq(1).trigger('mousedown', { which: 1 }) - cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); - cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active').trigger('mouseup', {force:true}); - cy.get('[alias="reorder"]').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="aTab 2"]').should('be.visible'); - }); - - it('Drags and drops a property in a tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .withLabel('UrlPickerOne') - .done() - .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group tab 2') - .addUrlPickerProperty() - .withAlias('urlPickerTabTwo') - .withLabel('UrlPickerTabTwo') - .done() - .addUrlPickerProperty() - .withAlias('urlPickerTwo') - .withLabel('UrlPickerTwo') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - //Scroll so we are sure we see tab 2 - cy.get('body') - .then(($body) => { - while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ - cy.click(); - } - }); - //Navigate to tab 2 - cy.get('.umb-group-builder__tab').last().click(); - cy.get('.umb-group-builder__property-meta > .flex > .icon').eq(1).trigger('mousedown', {which: 1}) - cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); - cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active'); - cy.get('.umb-group-builder__property') - .first().trigger('mousemove', {which: 1, force: true}).trigger('mouseup', {which: 1, force:true}); - cy.get('[alias="reorder"]').click(); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="urlPickerTabTwo"]').should('be.visible'); - }); - - it('Drags and drops a group and converts to tab', () => { - cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); - const tabsDocType = new DocumentTypeBuilder() - .withName(tabsDocTypeName) - .withAlias(tabsDocTypeAlias) - .withAllowAsRoot(true) - .withDefaultTemplate(tabsDocTypeAlias) - .addTab() - .withName('Tab 1') - .addGroup() - .withName('Tab group') - .addUrlPickerProperty() - .withAlias("urlPicker") - .withLabel('UrlPickerOne') - .done() - .done() - .addGroup() - .withName('Tab group 2') - .addUrlPickerProperty() - .withAlias('urlPickerTwo') - .withLabel('UrlPickerTwo') - .done() - .done() - .done() - .addTab() - .withName('Tab 2') - .addGroup() - .withName('Tab group tab 2') - .addUrlPickerProperty() - .withAlias('urlPickerTabTwo') - .withLabel('UrlPickerTabTwo') - .done() - .done() - .done() - .build(); - cy.saveDocumentType(tabsDocType); - OpenDocTypeFolder(); - cy.get('[alias="reorder"]').click(); - cy.get('.umb-group-builder__group-title-icon').eq(1).trigger('mousedown', {which: 1}) - cy.get('.umb-group-builder__convert-dropzone').trigger('mousemove', {which: 1, force: true}); - cy.get('.umb-group-builder__convert-dropzone').trigger('mouseup', {which: 1, force:true}); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Assert - cy.umbracoSuccessNotification().should('be.visible'); - cy.get('[title="tabGroup"]').should('be.visible'); - }); -}); \ No newline at end of file diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts deleted file mode 100644 index d3950d7d1928..000000000000 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/backofficeTour.ts +++ /dev/null @@ -1,103 +0,0 @@ -/// - -context('Backoffice Tour', () => { - var timeout = 60000; - beforeEach(() => { - //arrange - cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); - resetTourData(); - }); - - it('Backoffice introduction tour should run', () => { - //act - cy.umbracoGlobalHelp().should("be.visible"); - cy.umbracoGlobalHelp().click(); - runBackOfficeIntroTour(0, 'Start'); - - //assert - cy.get('[data-element="help-tours"]').should("be.visible"); - cy.get('[data-element="help-tours"]').click(); - getPercentage(17, timeout); - }); - - it('Backoffice introduction tour should run then rerun', () => { - //act - cy.umbracoGlobalHelp().should("be.visible"); - cy.umbracoGlobalHelp().click(); - runBackOfficeIntroTour(0, 'Start', timeout); - runBackOfficeIntroTour(17, 'Rerun', timeout); - - //assert - cy.get('[data-element="help-tours"]').should("be.visible"); - cy.get('[data-element="help-tours"]').click(); - cy.umbracoGlobalHelp().should("be.visible"); - getPercentage(17, timeout); - }); - - afterEach(() => { - //cleanup - resetTourData(); - }); -}); - -function getPercentage(percentage, timeout) { - cy.get('[data-element="help-tours"] .umb-progress-circle', { timeout: timeout }).get('[percentage]').contains(percentage + '%'); -} - -function resetTourData() { - var tourStatus = - { - "alias": "umbIntroIntroduction", - "completed": false, - "disabled": true - }; - - cy.getCookie('UMB-XSRF-TOKEN', { log: false }).then((token) => { - cy.request({ - method: 'POST', - url: '/umbraco/backoffice/UmbracoApi/CurrentUser/PostSetUserTour', - followRedirect: false, - headers: { - ContentType: 'application/json', - 'X-UMB-XSRF-TOKEN': token.value, - }, - body: tourStatus, - }).then((resp) => { - return; - }); - }) -} - -function runBackOfficeIntroTour(percentageComplete, buttonText, timeout) { - cy.get('[data-element="help-tours"]').should("be.visible"); - cy.get('[data-element="help-tours"]').click(); - cy.get('[data-element="help-tours"] .umb-progress-circle', { timeout: timeout }).get('[percentage]').contains(percentageComplete + '%', { timeout: timeout }); - cy.get('[data-element="help-tours"]').click(); - cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').should("be.visible"); - cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').contains(buttonText); - cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').click(); - //act - cy.get('.umb-tour-step', { timeout: timeout }).should('be.visible'); - cy.get('.umb-tour-step__footer').should('be.visible'); - cy.get('.umb-tour-step__counter').should('be.visible'); - - for (let i = 1; i < 7; i++) { - cy.get('.umb-tour-step__counter').contains(i + '/12'); - cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); - } - cy.umbracoGlobalUser().click() - cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('8/12'); - cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); - cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('9/12'); - cy.get('.umb-overlay-drawer__align-right .umb-button').should('be.visible').click(); - cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('10/12'); - cy.umbracoGlobalHelp().click() - - for (let i = 11; i < 13; i++) { - cy.get('.umb-tour-step__counter', { timeout: timeout }).contains(i + '/12'); - cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); - } - cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); - - cy.umbracoGlobalHelp().should("be.visible"); -} diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/systemInformation.ts deleted file mode 100644 index fe51f9e8899e..000000000000 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tour/systemInformation.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -function openSystemInformation(){ - cy.get('[data-element="global-help"]').click(); - cy.get('.umb-help-list-item').should('be.visible').click(); - cy.get('.umb-drawer-content').scrollTo('bottom', {ensureScrollable : false}); -} - -context('System Information', () => { - - beforeEach(() => { - //arrange - cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); - }); - - it('Check System Info Displays', () => { - openSystemInformation(); - cy.get('.table').find('tr').should('have.length', 10) - }); - - it('Checks language displays correctly after switching', () => { - //Navigate to edit user and change language - cy.get('[data-element="global-user"]').click(); - cy.get('[alias="editUser"]').click(); - cy.get('.input-block-level').last().select('Danish (Denmark)'); - cy.umbracoButtonByLabelKey('buttons_save').click(); - //Refresh site to display new language - cy.reload(); - openSystemInformation(); - //Assert - cy.contains('Current Culture').parent().should('contain', 'da-DK'); - cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); - - //Clean - cy.get('.input-block-level').last().select('English (United States)'); - cy.umbracoButtonByLabelKey('buttons_save').click(); - cy.reload(); - }); -}); \ No newline at end of file From 45badbd36b40b5982e5e64286b063de2dec501e5 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Mon, 4 Oct 2021 11:31:38 +0200 Subject: [PATCH 09/29] Apply suggestions from code review Co-authored-by: Mole --- src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs | 2 -- src/Umbraco.Core/Services/UserDataService.cs | 2 +- .../Umbraco.Core/Services/UserDataServiceTests.cs | 7 ++----- .../Controllers/CurrentUserController.cs | 1 + 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs index 5185e5387ae4..4d09b32a2853 100644 --- a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs @@ -26,8 +26,6 @@ using Umbraco.Cms.Core.Logging; using Umbraco.Cms.Core.Mail; using Umbraco.Cms.Core.Manifest; -using Umbraco.Cms.Core.Models; -using Umbraco.Cms.Core.Models.Membership; using Umbraco.Cms.Core.Models.PublishedContent; using Umbraco.Cms.Core.Notifications; using Umbraco.Cms.Core.PropertyEditors; diff --git a/src/Umbraco.Core/Services/UserDataService.cs b/src/Umbraco.Core/Services/UserDataService.cs index b76d9e3ae3d7..c76b70e19b3e 100644 --- a/src/Umbraco.Core/Services/UserDataService.cs +++ b/src/Umbraco.Core/Services/UserDataService.cs @@ -11,7 +11,7 @@ namespace Umbraco.Cms.Core.Services { public class UserDataService : IUserDataService { - private IUmbracoVersion _version; + private readonly IUmbracoVersion _version; private readonly ILocalizationService _localizationService; public UserDataService(IUmbracoVersion version, ILocalizationService localizationService) { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs index 23db68513e7f..602b972a6519 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs @@ -17,11 +17,8 @@ public class UserDataServiceTests private IUmbracoVersion _umbracoVersion; private ILocalizationService _localizationService; - [SetUp] - public void CreateMocks() - { - CreateUmbracoVersion(9, 0, 0); - } + [OneTimeSetUp] + public void CreateMocks() => CreateUmbracoVersion(9, 0, 0); [Test] [TestCase("en-US")] diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index b1ade72b0eab..6a836130175f 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -163,6 +163,7 @@ public IEnumerable GetUserTours() var userTours = JsonConvert.DeserializeObject>(_backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.TourData); return userTours; } + public IEnumerable GetUserData() { return _userDataService.GetUserData(); From e4e1d7f8733881e1c9fd9c2820ace9162ec5a6d6 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Mon, 4 Oct 2021 11:35:22 +0200 Subject: [PATCH 10/29] Fixed folders Signed-off-by: Nikolaj Geisle --- .../HelpPanel/systemInformation.ts | 39 ++ .../cypress/integration/Tabs/tabs.ts | 552 ++++++++++++++++++ .../integration/Tours/backofficeTour.ts | 103 ++++ 3 files changed, 694 insertions(+) create mode 100644 src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts create mode 100644 src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts create mode 100644 src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tours/backofficeTour.ts diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts new file mode 100644 index 000000000000..fe51f9e8899e --- /dev/null +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -0,0 +1,39 @@ +/// + +function openSystemInformation(){ + cy.get('[data-element="global-help"]').click(); + cy.get('.umb-help-list-item').should('be.visible').click(); + cy.get('.umb-drawer-content').scrollTo('bottom', {ensureScrollable : false}); +} + +context('System Information', () => { + + beforeEach(() => { + //arrange + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + }); + + it('Check System Info Displays', () => { + openSystemInformation(); + cy.get('.table').find('tr').should('have.length', 10) + }); + + it('Checks language displays correctly after switching', () => { + //Navigate to edit user and change language + cy.get('[data-element="global-user"]').click(); + cy.get('[alias="editUser"]').click(); + cy.get('.input-block-level').last().select('Danish (Denmark)'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Refresh site to display new language + cy.reload(); + openSystemInformation(); + //Assert + cy.contains('Current Culture').parent().should('contain', 'da-DK'); + cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); + + //Clean + cy.get('.input-block-level').last().select('English (United States)'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + cy.reload(); + }); +}); \ No newline at end of file diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts new file mode 100644 index 000000000000..92365d742610 --- /dev/null +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tabs/tabs.ts @@ -0,0 +1,552 @@ +/// +import { + DocumentTypeBuilder, + AliasHelper + } from 'umbraco-cypress-testhelpers'; + + const tabsDocTypeName = 'Tabs Test Document'; + const tabsDocTypeAlias = AliasHelper.toAlias(tabsDocTypeName); + + context('Tabs', () => { + + beforeEach(() => { + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'), false); + }); + + afterEach(() => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName) + }); + + function OpenDocTypeFolder(){ + cy.umbracoSection('settings'); + cy.get('li .umb-tree-root:contains("Settings")').should("be.visible"); + cy.get('.umb-tree-item__inner > .umb-tree-item__arrow').eq(0).click(); + cy.get('.umb-tree-item__inner > .umb-tree-item__label').contains(tabsDocTypeName).click(); + } + + function CreateDocWithTabAndNavigate(){ + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + } + + it('Create tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + cy.deleteAllContent(); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addGroup() + .withName('Tabs1Group') + .addUrlPickerProperty() + .withAlias('picker') + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Create a tab + cy.get('.umb-group-builder__tabs__add-tab').click(); + cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 1'); + //Create a 2nd tab manually + cy.get('.umb-group-builder__tabs__add-tab').click(); + cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 2'); + //Create a textstring property + cy.get('[aria-hidden="false"] > .umb-box-content > .umb-group-builder__group-add-property').click(); + cy.get('.editor-label').type('property name'); + cy.get('[data-element="editor-add"]').click(); + + //Search for textstring + cy.get('#datatype-search').type('Textstring'); + + // Choose first item + cy.get('[title="Textstring"]').closest("li").click(); + + // Save property + cy.get('.btn-success').last().click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="tab1"]').should('be.visible'); + cy.get('[title="tab2"]').should('be.visible'); + }); + + it('Delete tabs', () => { + CreateDocWithTabAndNavigate(); + //Check if tab is there, else if it wasnt created, this test would always pass + cy.get('[title="aTab 1"]').should('be.visible'); + //Delete a tab + cy.get('.btn-reset > .icon-trash').click(); + cy.get('.umb-button > .btn').last().click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.get('[title="aTab 1"]').should('not.exist'); + //Clean + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + }); + + it('Delete property in tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .addContentPickerProperty() + .withAlias('picker') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[aria-label="Delete property"]').last().click(); + cy.umbracoButtonByLabelKey('actions_delete').click(); + cy.umbracoButtonByLabelKey('buttons_save').click() + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title=urlPicker]').should('be.visible'); + cy.get('[title=picker]').should('not.exist'); + }); + + it('Delete group in tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .done() + .addGroup() + .withName('Content Picker Group') + .addContentPickerProperty() + .withAlias('picker') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Delete group + cy.get('.umb-group-builder__group-remove > .icon-trash').eq(1).click(); + cy.umbracoButtonByLabelKey('actions_delete').click(); + cy.umbracoButtonByLabelKey('buttons_save').click() + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title=picker]').should('be.visible'); + cy.get('[title=urlPicker]').should('not.exist'); + }); + + it('Reorders tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group 1') + .addUrlPickerProperty() + .withLabel('Url picker 1') + .withAlias("urlPicker") + .done() + .done() + .done() + .addTab() + .withName('Tab 2') + .addGroup() + .withName('Tab group 2') + .addUrlPickerProperty() + .withLabel('Url picker 2') + .withAlias("pickerTab 2") + .done() + .done() + .done() + .addTab() + .withName('Tab 3') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withLabel('Url picker 3') + .withAlias('pickerTab3') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Check if there are any tabs + cy.get('ng-form.ng-valid-required > .umb-group-builder__group-title-input').should('be.visible'); + cy.get('[alias="reorder"]').click(); + //Type order in + cy.get('.umb-group-builder__tab-sort-order > .umb-property-editor-tiny').first().type('3'); + cy.get('[alias="reorder"]').click(); + //Assert + cy.get('.umb-group-builder__group-title-input').eq(0).invoke('attr', 'title').should('eq', 'aTab 2') + cy.get('.umb-group-builder__group-title-input').eq(1).invoke('attr', 'title').should('eq', 'aTab 3') + cy.get('.umb-group-builder__group-title-input').eq(2).invoke('attr', 'title').should('eq', 'aTab 1') + }); + + it('Reorders groups in a tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group 1') + .addUrlPickerProperty() + .withLabel('Url picker 1') + .withAlias("urlPicker") + .done() + .done() + .addGroup() + .withName('Tab group 2') + .addUrlPickerProperty() + .withLabel('Url picker 2') + .withAlias('urlPickerTwo') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + cy.get('.umb-property-editor-tiny').eq(2).type('1'); + + cy.get('[alias="reorder"]').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('.umb-group-builder__group-title-input').eq(2) + .invoke('attr', 'title').should('eq', 'aTab 1/aTab group 2'); + }); + + it('Reorders properties in a tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withLabel('PickerOne') + .withAlias("urlPicker") + .done() + .addUrlPickerProperty() + .withLabel('PickerTwo') + .withAlias('urlPickerTwo') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Reorder + cy.get('[alias="reorder"]').click(); + cy.get('.umb-group-builder__group-sort-value').first().type('2'); + cy.get('[alias="reorder"]').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('.umb-locked-field__input').last().invoke('attr', 'title').should('eq', 'urlPicker'); + }); + + it('Tab name cannot be empty', () => { + CreateDocWithTabAndNavigate(); + cy.get('.umb-group-builder__group-title-input').first().clear(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoErrorNotification().should('be.visible'); + }); + + it('Two tabs cannot have the same name', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + //Create a 2nd tab manually + cy.get('.umb-group-builder__tabs__add-tab').click(); + cy.get('ng-form.ng-invalid > .umb-group-builder__group-title-input').type('Tab 1'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoErrorNotification().should('be.visible'); + }); + + it('Group name cannot be empty', () => { + CreateDocWithTabAndNavigate(); + cy.get('.clearfix > .-placeholder').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoErrorNotification().should('be.visible'); + }); + + it('Group name cannot have the same name', () => { + CreateDocWithTabAndNavigate(); + cy.get('.clearfix > .-placeholder').click(); + cy.get('.umb-group-builder__group-title-input').last().type('Tab group'); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoErrorNotification().should('be.visible'); + }); + + it('Drag a group into another tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .done() + .done() + .addTab() + .withName('Tab 2') + .addGroup() + .withName('Tab group tab 2') + .addUrlPickerProperty() + .withAlias('urlPickerTabTwo') + .done() + .done() + .addGroup() + .withName('Tab group 2') + .addUrlPickerProperty() + .withAlias('urlPickerTwo') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + cy.get('body') + .then(($body) => { + while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ + cy.click(); + } + }); + cy.get('.umb-group-builder__tab').last().click(); + cy.get('.umb-group-builder__group-title-icon').last().trigger('mousedown', { which: 1 }) + cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); + cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active').trigger('mouseup', {force:true}); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="aTab 1/aTab group 2"]').should('be.visible'); + }); + + it('Drag and drop reorders a tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .done() + .done() + .done() + .addTab() + .withName('Tab 2') + .addGroup() + .withName('Tab group tab 2') + .addUrlPickerProperty() + .withAlias('urlPickerTabTwo') + .done() + .done() + .addGroup() + .withName('Tab group 2') + .addUrlPickerProperty() + .withAlias('urlPickerTwo') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + //Scroll right so we can see tab 2 + cy.get('body') + .then(($body) => { + while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ + cy.click(); + } + }); + cy.get('.umb-group-builder__tab-title-icon').eq(1).trigger('mousedown', { which: 1 }) + cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); + cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active').trigger('mouseup', {force:true}); + cy.get('[alias="reorder"]').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="aTab 2"]').should('be.visible'); + }); + + it('Drags and drops a property in a tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .withLabel('UrlPickerOne') + .done() + .done() + .done() + .addTab() + .withName('Tab 2') + .addGroup() + .withName('Tab group tab 2') + .addUrlPickerProperty() + .withAlias('urlPickerTabTwo') + .withLabel('UrlPickerTabTwo') + .done() + .addUrlPickerProperty() + .withAlias('urlPickerTwo') + .withLabel('UrlPickerTwo') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + //Scroll so we are sure we see tab 2 + cy.get('body') + .then(($body) => { + while($body.find('.umb-group-builder__tabs-overflow--right > .caret').hasClass('active')){ + cy.click(); + } + }); + //Navigate to tab 2 + cy.get('.umb-group-builder__tab').last().click(); + cy.get('.umb-group-builder__property-meta > .flex > .icon').eq(1).trigger('mousedown', {which: 1}) + cy.get('.umb-group-builder__tab').eq(1).trigger('mousemove', {which: 1, force: true}); + cy.get('.umb-group-builder__tab').eq(1).should('have.class', 'is-active'); + cy.get('.umb-group-builder__property') + .first().trigger('mousemove', {which: 1, force: true}).trigger('mouseup', {which: 1, force:true}); + cy.get('[alias="reorder"]').click(); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="urlPickerTabTwo"]').should('be.visible'); + }); + + it('Drags and drops a group and converts to tab', () => { + cy.umbracoEnsureDocumentTypeNameNotExists(tabsDocTypeName); + const tabsDocType = new DocumentTypeBuilder() + .withName(tabsDocTypeName) + .withAlias(tabsDocTypeAlias) + .withAllowAsRoot(true) + .withDefaultTemplate(tabsDocTypeAlias) + .addTab() + .withName('Tab 1') + .addGroup() + .withName('Tab group') + .addUrlPickerProperty() + .withAlias("urlPicker") + .withLabel('UrlPickerOne') + .done() + .done() + .addGroup() + .withName('Tab group 2') + .addUrlPickerProperty() + .withAlias('urlPickerTwo') + .withLabel('UrlPickerTwo') + .done() + .done() + .done() + .addTab() + .withName('Tab 2') + .addGroup() + .withName('Tab group tab 2') + .addUrlPickerProperty() + .withAlias('urlPickerTabTwo') + .withLabel('UrlPickerTabTwo') + .done() + .done() + .done() + .build(); + cy.saveDocumentType(tabsDocType); + OpenDocTypeFolder(); + cy.get('[alias="reorder"]').click(); + cy.get('.umb-group-builder__group-title-icon').eq(1).trigger('mousedown', {which: 1}) + cy.get('.umb-group-builder__convert-dropzone').trigger('mousemove', {which: 1, force: true}); + cy.get('.umb-group-builder__convert-dropzone').trigger('mouseup', {which: 1, force:true}); + cy.umbracoButtonByLabelKey('buttons_save').click(); + //Assert + cy.umbracoSuccessNotification().should('be.visible'); + cy.get('[title="tabGroup"]').should('be.visible'); + }); + }); \ No newline at end of file diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tours/backofficeTour.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tours/backofficeTour.ts new file mode 100644 index 000000000000..8bdd052e94fd --- /dev/null +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/Tours/backofficeTour.ts @@ -0,0 +1,103 @@ +/// + +context('Backoffice Tour', () => { + var timeout = 60000; + beforeEach(() => { + //arrange + cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + resetTourData(); + }); + + it('Backoffice introduction tour should run', () => { + //act + cy.umbracoGlobalHelp().should("be.visible"); + cy.umbracoGlobalHelp().click(); + runBackOfficeIntroTour(0, 'Start'); + + //assert + cy.get('[data-element="help-tours"]').should("be.visible"); + cy.get('[data-element="help-tours"]').click(); + getPercentage(17, timeout); + }); + + it('Backoffice introduction tour should run then rerun', () => { + //act + cy.umbracoGlobalHelp().should("be.visible"); + cy.umbracoGlobalHelp().click(); + runBackOfficeIntroTour(0, 'Start', timeout); + runBackOfficeIntroTour(17, 'Rerun', timeout); + + //assert + cy.get('[data-element="help-tours"]').should("be.visible"); + cy.get('[data-element="help-tours"]').click(); + cy.umbracoGlobalHelp().should("be.visible"); + getPercentage(17, timeout); + }); + + afterEach(() => { + //cleanup + resetTourData(); + }); +}); + +function getPercentage(percentage, timeout) { + cy.get('[data-element="help-tours"] .umb-progress-circle', { timeout: timeout }).get('[percentage]').contains(percentage + '%'); +} + +function resetTourData() { + var tourStatus = + { + "alias": "umbIntroIntroduction", + "completed": false, + "disabled": true + }; + + cy.getCookie('UMB-XSRF-TOKEN', { log: false }).then((token) => { + cy.request({ + method: 'POST', + url: '/umbraco/backoffice/UmbracoApi/CurrentUser/PostSetUserTour', + followRedirect: false, + headers: { + ContentType: 'application/json', + 'X-UMB-XSRF-TOKEN': token.value, + }, + body: tourStatus, + }).then((resp) => { + return; + }); + }) +} + +function runBackOfficeIntroTour(percentageComplete, buttonText, timeout) { + cy.get('[data-element="help-tours"]').should("be.visible"); + cy.get('[data-element="help-tours"]').click(); + cy.get('[data-element="help-tours"] .umb-progress-circle', { timeout: timeout }).get('[percentage]').contains(percentageComplete + '%', { timeout: timeout }); + cy.get('[data-element="help-tours"]').click(); + cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').should("be.visible"); + cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').contains(buttonText); + cy.get('[data-element="tour-umbIntroIntroduction"] .umb-button').click(); + //act + cy.get('.umb-tour-step', { timeout: timeout }).should('be.visible'); + cy.get('.umb-tour-step__footer').should('be.visible'); + cy.get('.umb-tour-step__counter').should('be.visible'); + + for (let i = 1; i < 7; i++) { + cy.get('.umb-tour-step__counter').contains(i + '/12'); + cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); + } + cy.umbracoGlobalUser().click() + cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('8/12'); + cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); + cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('9/12'); + cy.get('.umb-overlay-drawer__align-right .umb-button').should('be.visible').click(); + cy.get('.umb-tour-step__counter', { timeout: timeout }).contains('10/12'); + cy.umbracoGlobalHelp().click() + + for (let i = 11; i < 13; i++) { + cy.get('.umb-tour-step__counter', { timeout: timeout }).contains(i + '/12'); + cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); + } + cy.get('.umb-tour-step__footer .umb-button').should('be.visible').click(); + + cy.umbracoGlobalHelp().should("be.visible"); +} \ No newline at end of file From 9c39cc4583dabac20b3405a548dbe395544040c4 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Mon, 4 Oct 2021 11:38:33 +0200 Subject: [PATCH 11/29] Updated based on review Signed-off-by: Nikolaj Geisle --- src/Umbraco.Core/Services/UserDataService.cs | 24 ++++++-------- .../HelpPanel/systemInformation.ts | 14 +++++++-- .../Services/UserDataServiceTests.cs | 31 ++++++++++--------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/Umbraco.Core/Services/UserDataService.cs b/src/Umbraco.Core/Services/UserDataService.cs index c76b70e19b3e..f0dcf78c607b 100644 --- a/src/Umbraco.Core/Services/UserDataService.cs +++ b/src/Umbraco.Core/Services/UserDataService.cs @@ -13,6 +13,7 @@ public class UserDataService : IUserDataService { private readonly IUmbracoVersion _version; private readonly ILocalizationService _localizationService; + public UserDataService(IUmbracoVersion version, ILocalizationService localizationService) { _version = version; @@ -23,26 +24,19 @@ public IEnumerable GetUserData() { var userDataList = new List { - new UserData("Server OS", RuntimeInformation.OSDescription), - new UserData("Server Framework", RuntimeInformation.FrameworkDescription), - new UserData("Default Language", _localizationService.GetDefaultLanguageIsoCode()), - new UserData("Umbraco Version", _version.SemanticVersion.ToSemanticStringWithoutBuild()), - new UserData("Current Culture", Thread.CurrentThread.CurrentCulture.ToString()), - new UserData("Current UI Culture", Thread.CurrentThread.CurrentUICulture.ToString()), - new UserData("Current Webserver", GetCurrentWebServer()) + new("Server OS", RuntimeInformation.OSDescription), + new("Server Framework", RuntimeInformation.FrameworkDescription), + new("Default Language", _localizationService.GetDefaultLanguageIsoCode()), + new("Umbraco Version", _version.SemanticVersion.ToSemanticStringWithoutBuild()), + new("Current Culture", Thread.CurrentThread.CurrentCulture.ToString()), + new("Current UI Culture", Thread.CurrentThread.CurrentUICulture.ToString()), + new("Current Webserver", GetCurrentWebServer()) }; return userDataList; } - public string GetCurrentWebServer() - { - if (IsRunningInProcessIIS()) - { - return "IIS"; - } + private string GetCurrentWebServer() => IsRunningInProcessIIS() ? "IIS" : "Kestrel"; - return "Kestrel"; - } public bool IsRunningInProcessIIS() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index fe51f9e8899e..44e5d1833e90 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -2,7 +2,7 @@ function openSystemInformation(){ cy.get('[data-element="global-help"]').click(); - cy.get('.umb-help-list-item').should('be.visible').click(); + cy.get('.umb-help-list-item').last().should('be.visible').click(); cy.get('.umb-drawer-content').scrollTo('bottom', {ensureScrollable : false}); } @@ -15,11 +15,16 @@ context('System Information', () => { it('Check System Info Displays', () => { openSystemInformation(); - cy.get('.table').find('tr').should('have.length', 10) + cy.get('.table').find('tr').should('have.length', 10); + }); it('Checks language displays correctly after switching', () => { //Navigate to edit user and change language + openSystemInformation(); + cy.contains('Current Culture').parent().should('contain', 'en-US'); + cy.contains('Current UI Culture').parent().should('contain', 'en-US'); + cy.get('.umb-button__content').click(); cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); cy.get('.input-block-level').last().select('Danish (Denmark)'); @@ -32,8 +37,11 @@ context('System Information', () => { cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); //Clean + cy.get('.umb-button__content').click(); + cy.get('[data-element="global-user"]').click(); + cy.get('[alias="editUser"]').click(); cy.get('.input-block-level').last().select('English (United States)'); cy.umbracoButtonByLabelKey('buttons_save').click(); cy.reload(); }); -}); \ No newline at end of file +}); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs index 602b972a6519..74179763697e 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/UserDataServiceTests.cs @@ -15,7 +15,6 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services public class UserDataServiceTests { private IUmbracoVersion _umbracoVersion; - private ILocalizationService _localizationService; [OneTimeSetUp] public void CreateMocks() => CreateUmbracoVersion(9, 0, 0); @@ -27,8 +26,7 @@ public class UserDataServiceTests [TestCase("sv-SE")] public void GetCorrectDefaultLanguageTest(string culture) { - CreateLocalizationVersion(culture); - var userDataService = new UserDataService(_umbracoVersion, _localizationService); + var userDataService = CreateUserDataService(culture); var defaultLanguage = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Default Language"); Assert.Multiple(() => { @@ -45,8 +43,7 @@ public void GetCorrectDefaultLanguageTest(string culture) public void GetCorrectCultureTest(string culture) { Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); - CreateLocalizationVersion(culture); - var userDataService = new UserDataService(_umbracoVersion, _localizationService); + var userDataService = CreateUserDataService(culture); var currentCulture = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Current Culture"); Assert.Multiple(() => { @@ -63,8 +60,7 @@ public void GetCorrectCultureTest(string culture) public void GetCorrectUICultureTest(string culture) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); - CreateLocalizationVersion(culture); - var userDataService = new UserDataService(_umbracoVersion, _localizationService); + var userDataService = CreateUserDataService(culture); var currentCulture = userDataService.GetUserData().FirstOrDefault(x => x.Name == "Current UI Culture"); Assert.Multiple(() => { @@ -80,22 +76,27 @@ public void GetCorrectUICultureTest(string culture) [TestCase("sv-SE")] public void RunTimeInformationNotNullTest(string culture) { - CreateLocalizationVersion(culture); - var userDataService = new UserDataService(_umbracoVersion, _localizationService); - IEnumerable userData = userDataService.GetUserData(); + var userDataService = CreateUserDataService(culture); + IEnumerable userData = userDataService.GetUserData().ToList(); Assert.Multiple(() => { - Assert.IsNotNull(userData.FirstOrDefault(x => x.Name == "Server OS")); - Assert.IsNotNull(userData.FirstOrDefault(x => x.Name == "Server Framework")); - Assert.IsNotNull(userData.FirstOrDefault(x => x.Name == "Current Webserver")); + Assert.IsNotNull(userData.Select(x => x.Name == "Server OS")); + Assert.IsNotNull(userData.Select(x => x.Name == "Server Framework")); + Assert.IsNotNull(userData.Select(x => x.Name == "Current Webserver")); }); } - private void CreateLocalizationVersion(string culture) + private UserDataService CreateUserDataService(string culture) + { + var localizationService = CreateILocalizationService(culture); + return new UserDataService(_umbracoVersion, localizationService); + } + + private ILocalizationService CreateILocalizationService(string culture) { var localizationService = new Mock(); localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns(culture); - _localizationService = localizationService.Object; + return localizationService.Object; } private void CreateUmbracoVersion(int major, int minor, int patch) From 9214db8cde60379e3f4e5829004d65faf7ffc10d Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Mon, 4 Oct 2021 13:06:04 +0200 Subject: [PATCH 12/29] fixed cypress test Signed-off-by: Nikolaj Geisle --- .../cypress/integration/HelpPanel/systemInformation.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 44e5d1833e90..d44959f3bb49 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -35,12 +35,11 @@ context('System Information', () => { //Assert cy.contains('Current Culture').parent().should('contain', 'da-DK'); cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); - + cy.reload(); //Clean - cy.get('.umb-button__content').click(); cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); - cy.get('.input-block-level').last().select('English (United States)'); + cy.get('.input-block-level', {timeout: 10000}).last().select('English (United States)'); cy.umbracoButtonByLabelKey('buttons_save').click(); cy.reload(); }); From 92429942b8a77b69ca47b75a9d52e204f5b91bab Mon Sep 17 00:00:00 2001 From: nikolajlauridsen Date: Mon, 4 Oct 2021 14:54:38 +0200 Subject: [PATCH 13/29] Don't search in array --- .../src/views/common/drawers/help/help.controller.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js index 51497d145dcf..5b9626c676ff 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/drawers/help/help.controller.js @@ -222,8 +222,7 @@ } } function getPlatform() { - const allPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE', 'Android', 'iPhone', 'iPad', 'iPod']; - return allPlatforms.find(item => item === window.navigator.platform); + return window.navigator.platform; } evts.push(eventsService.on("appState.tour.complete", function (event, tour) { tourService.getGroupedTours().then(function(groupedTours) { From 9a041508979f63b14b26091ecd59ebf474acc1bc Mon Sep 17 00:00:00 2001 From: nikolajlauridsen Date: Mon, 4 Oct 2021 15:32:35 +0200 Subject: [PATCH 14/29] Try and make input block more specific --- .../cypress/integration/HelpPanel/systemInformation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index d44959f3bb49..8da550184000 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -27,7 +27,7 @@ context('System Information', () => { cy.get('.umb-button__content').click(); cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); - cy.get('.input-block-level').last().select('Danish (Denmark)'); + cy.get('[name="culture"]').select('Danish (Denmark)', {timeout: 10000}); cy.umbracoButtonByLabelKey('buttons_save').click(); //Refresh site to display new language cy.reload(); From 8330dec85fd2f3cbb4df25816cfed1427dea540f Mon Sep 17 00:00:00 2001 From: nikolajlauridsen Date: Mon, 4 Oct 2021 18:31:13 +0200 Subject: [PATCH 15/29] Make system information run locally on linux --- .../cypress/integration/HelpPanel/systemInformation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 8da550184000..0bd0375d4031 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -27,7 +27,7 @@ context('System Information', () => { cy.get('.umb-button__content').click(); cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); - cy.get('[name="culture"]').select('Danish (Denmark)', {timeout: 10000}); + cy.get('[name="culture"]').select('Danish (Denmark)', {timeout: 10000, force: true}); cy.umbracoButtonByLabelKey('buttons_save').click(); //Refresh site to display new language cy.reload(); @@ -39,7 +39,7 @@ context('System Information', () => { //Clean cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); - cy.get('.input-block-level', {timeout: 10000}).last().select('English (United States)'); + cy.get('.input-block-level', {timeout: 10000}).last().select('English (United States)', {timeout: 10000, force: true}); cy.umbracoButtonByLabelKey('buttons_save').click(); cy.reload(); }); From 1deab9a9ad30dc30e79829074e7bb439684a15ec Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Tue, 5 Oct 2021 08:48:03 +0200 Subject: [PATCH 16/29] Fixed flaky test Signed-off-by: Nikolaj Geisle --- .../cypress/integration/HelpPanel/systemInformation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 0bd0375d4031..60d8b9c1d676 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -27,7 +27,7 @@ context('System Information', () => { cy.get('.umb-button__content').click(); cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); - cy.get('[name="culture"]').select('Danish (Denmark)', {timeout: 10000, force: true}); + cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); cy.umbracoButtonByLabelKey('buttons_save').click(); //Refresh site to display new language cy.reload(); @@ -39,7 +39,7 @@ context('System Information', () => { //Clean cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); - cy.get('.input-block-level', {timeout: 10000}).last().select('English (United States)', {timeout: 10000, force: true}); + cy.get('.input-block-level', {timeout: 10000}).last().select('string:en-US', {timeout: 10000, force: true}); cy.umbracoButtonByLabelKey('buttons_save').click(); cy.reload(); }); From 8a6d028ddf4d209920830686434019cb8064445c Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Tue, 5 Oct 2021 09:12:48 +0200 Subject: [PATCH 17/29] Fixed flaky test v2 Signed-off-by: Nikolaj Geisle --- .../cypress/integration/HelpPanel/systemInformation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 60d8b9c1d676..561842f6a8a0 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -28,7 +28,7 @@ context('System Information', () => { cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); - cy.umbracoButtonByLabelKey('buttons_save').click(); + cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); //Refresh site to display new language cy.reload(); openSystemInformation(); @@ -40,7 +40,7 @@ context('System Information', () => { cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); cy.get('.input-block-level', {timeout: 10000}).last().select('string:en-US', {timeout: 10000, force: true}); - cy.umbracoButtonByLabelKey('buttons_save').click(); + cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); cy.reload(); }); }); From 44f14c9c19d3282e4f20a7cf34ab4f177f3fb2b3 Mon Sep 17 00:00:00 2001 From: Zeegaan <70372949+zeegaan@users.noreply.github.com> Date: Tue, 5 Oct 2021 09:39:07 +0200 Subject: [PATCH 18/29] Added more stability to test Signed-off-by: Nikolaj Geisle --- .../cypress/integration/HelpPanel/systemInformation.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 561842f6a8a0..6c797b63cac9 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -35,6 +35,7 @@ context('System Information', () => { //Assert cy.contains('Current Culture').parent().should('contain', 'da-DK'); cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); + cy.get('.umb-button__content').last().click(); cy.reload(); //Clean cy.get('[data-element="global-user"]').click(); From e3ff40be50d5eb33887224869471a809c9e286ea Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Tue, 5 Oct 2021 11:31:02 +0200 Subject: [PATCH 19/29] Tried to fix stability Signed-off-by: Nikolaj Geisle --- .../HelpPanel/systemInformation.ts | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 6c797b63cac9..6575654c0cf4 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -18,30 +18,36 @@ context('System Information', () => { cy.get('.table').find('tr').should('have.length', 10); }); - - it('Checks language displays correctly after switching', () => { - //Navigate to edit user and change language - openSystemInformation(); - cy.contains('Current Culture').parent().should('contain', 'en-US'); - cy.contains('Current UI Culture').parent().should('contain', 'en-US'); - cy.get('.umb-button__content').click(); - cy.get('[data-element="global-user"]').click(); - cy.get('[alias="editUser"]').click(); - cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); - cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); - //Refresh site to display new language - cy.reload(); - openSystemInformation(); - //Assert - cy.contains('Current Culture').parent().should('contain', 'da-DK'); - cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); - cy.get('.umb-button__content').last().click(); - cy.reload(); - //Clean - cy.get('[data-element="global-user"]').click(); - cy.get('[alias="editUser"]').click(); - cy.get('.input-block-level', {timeout: 10000}).last().select('string:en-US', {timeout: 10000, force: true}); - cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); - cy.reload(); + + context('Language switching', () => { + + afterEach(() => { + cy.get('[data-element="global-user"]').click(); + cy.get('[alias="editUser"]').click({timeout: 10000}); + cy.get('.input-block-level', {timeout: 10000}).last().select('string:en-US', {timeout: 10000, force: true}); + cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); + cy.reload(); + }); + + it('Checks language displays correctly after switching', () => { + + //Navigate to edit user and change language + openSystemInformation(); + cy.contains('Current Culture').parent().should('contain', 'en-US'); + cy.contains('Current UI Culture').parent().should('contain', 'en-US'); + cy.get('.umb-button__content').click(); + cy.get('[data-element="global-user"]').click(); + cy.get('[alias="editUser"]').click(); + cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); + cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); + //Refresh site to display new language + cy.reload(); + openSystemInformation(); + //Assert + cy.contains('Current Culture').parent().should('contain', 'da-DK'); + cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); + cy.get('.umb-button__content').last().click(); + cy.reload(); + }); }); }); From fa6f96d6fa6b6450d73454a575bef875fe4e8a90 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Tue, 5 Oct 2021 11:37:18 +0200 Subject: [PATCH 20/29] stability wait Signed-off-by: Nikolaj Geisle --- .../cypress/integration/HelpPanel/systemInformation.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 6575654c0cf4..4716c1337bd7 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -1,7 +1,8 @@ /// function openSystemInformation(){ - cy.get('[data-element="global-help"]').click(); + //We have to wait for page to load, if the site is slow + cy.get('[data-element="global-help"]').should('be.visible', {timeout:10000}).click(); cy.get('.umb-help-list-item').last().should('be.visible').click(); cy.get('.umb-drawer-content').scrollTo('bottom', {ensureScrollable : false}); } @@ -18,7 +19,7 @@ context('System Information', () => { cy.get('.table').find('tr').should('have.length', 10); }); - + context('Language switching', () => { afterEach(() => { From c05d6b774f4b23cfeffaa574b85639faa34f0d77 Mon Sep 17 00:00:00 2001 From: nikolajlauridsen Date: Tue, 5 Oct 2021 12:57:04 +0200 Subject: [PATCH 21/29] Move timeout --- .../cypress/integration/HelpPanel/systemInformation.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 4716c1337bd7..a21a7073ed07 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -21,17 +21,17 @@ context('System Information', () => { }); context('Language switching', () => { - + afterEach(() => { - cy.get('[data-element="global-user"]').click(); - cy.get('[alias="editUser"]').click({timeout: 10000}); + cy.get('[data-element="global-user"]', {timeout: 10000}).click(); + cy.get('[alias="editUser"]').click(); cy.get('.input-block-level', {timeout: 10000}).last().select('string:en-US', {timeout: 10000, force: true}); cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); cy.reload(); }); - + it('Checks language displays correctly after switching', () => { - + //Navigate to edit user and change language openSystemInformation(); cy.contains('Current Culture').parent().should('contain', 'en-US'); From 0d90a786e441d44846f4c50caf9dc1d89f971f24 Mon Sep 17 00:00:00 2001 From: nikolajlauridsen Date: Tue, 5 Oct 2021 14:15:43 +0200 Subject: [PATCH 22/29] Try and fix acceptance tests take 1000 --- .../cypress/integration/HelpPanel/systemInformation.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index a21a7073ed07..0709e8925a08 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -17,13 +17,15 @@ context('System Information', () => { it('Check System Info Displays', () => { openSystemInformation(); cy.get('.table').find('tr').should('have.length', 10); - + cy.contains('Current Culture').parent().should('contain', 'en-US'); + cy.contains('Current UI Culture').parent().should('contain', 'en-US'); }); context('Language switching', () => { afterEach(() => { - cy.get('[data-element="global-user"]', {timeout: 10000}).click(); + cy.reload() + cy.get('[data-element="global-user"]', {timeout: 10000}).should('be.visible', {timeout: 10000}).click(); cy.get('[alias="editUser"]').click(); cy.get('.input-block-level', {timeout: 10000}).last().select('string:en-US', {timeout: 10000, force: true}); cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); @@ -33,10 +35,6 @@ context('System Information', () => { it('Checks language displays correctly after switching', () => { //Navigate to edit user and change language - openSystemInformation(); - cy.contains('Current Culture').parent().should('contain', 'en-US'); - cy.contains('Current UI Culture').parent().should('contain', 'en-US'); - cy.get('.umb-button__content').click(); cy.get('[data-element="global-user"]').click(); cy.get('[alias="editUser"]').click(); cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); From be66e2ea618a359c0369a93cf11520bce62d4578 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Wed, 6 Oct 2021 13:53:33 +0200 Subject: [PATCH 23/29] Updated cypress test to use newly created helper method --- .../HelpPanel/systemInformation.ts | 44 +++++++------------ src/Umbraco.Tests.AcceptanceTest/package.json | 2 +- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 0709e8925a08..358b4bfe8a0d 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -12,6 +12,7 @@ context('System Information', () => { beforeEach(() => { //arrange cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); + cy.umbracoSetCurrentUserLanguage('en-US'); }); it('Check System Info Displays', () => { @@ -20,33 +21,20 @@ context('System Information', () => { cy.contains('Current Culture').parent().should('contain', 'en-US'); cy.contains('Current UI Culture').parent().should('contain', 'en-US'); }); - - context('Language switching', () => { - - afterEach(() => { - cy.reload() - cy.get('[data-element="global-user"]', {timeout: 10000}).should('be.visible', {timeout: 10000}).click(); - cy.get('[alias="editUser"]').click(); - cy.get('.input-block-level', {timeout: 10000}).last().select('string:en-US', {timeout: 10000, force: true}); - cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); - cy.reload(); - }); - - it('Checks language displays correctly after switching', () => { - - //Navigate to edit user and change language - cy.get('[data-element="global-user"]').click(); - cy.get('[alias="editUser"]').click(); - cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); - cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); - //Refresh site to display new language - cy.reload(); - openSystemInformation(); - //Assert - cy.contains('Current Culture').parent().should('contain', 'da-DK'); - cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); - cy.get('.umb-button__content').last().click(); - cy.reload(); - }); + + it('Checks language displays correctly after switching', () => { + + //Navigate to edit user and change language + cy.get('[data-element="global-user"]').click(); + cy.get('[alias="editUser"]').click(); + cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); + cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); + //Refresh site to display new language + cy.reload(); + openSystemInformation(); + //Assert + cy.contains('Current Culture').parent().should('contain', 'da-DK'); + cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); + cy.get('.umb-button__content').last().click(); }); }); diff --git a/src/Umbraco.Tests.AcceptanceTest/package.json b/src/Umbraco.Tests.AcceptanceTest/package.json index 2b85faaf9c0e..20a5a774e097 100644 --- a/src/Umbraco.Tests.AcceptanceTest/package.json +++ b/src/Umbraco.Tests.AcceptanceTest/package.json @@ -11,7 +11,7 @@ "del": "^6.0.0", "ncp": "^2.0.0", "prompt": "^1.0.0", - "umbraco-cypress-testhelpers": "^1.0.0-beta-57" + "umbraco-cypress-testhelpers": "^1.0.0-beta-58" }, "dependencies": { "typescript": "^3.9.2" From 0be61212a5744c37eb60cb4dfd48994804bebce8 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Wed, 6 Oct 2021 14:07:08 +0200 Subject: [PATCH 24/29] Updated test to actually cleanup --- .../cypress/integration/HelpPanel/systemInformation.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 358b4bfe8a0d..e11324616c4a 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -36,5 +36,7 @@ context('System Information', () => { cy.contains('Current Culture').parent().should('contain', 'da-DK'); cy.contains('Current UI Culture').parent().should('contain', 'da-DK'); cy.get('.umb-button__content').last().click(); + //Clean + cy.umbracoSetCurrentUserLanguage('en-US'); }); }); From 861be7288977892408e8d652340f23ce1256aa8d Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Thu, 7 Oct 2021 08:18:10 +0200 Subject: [PATCH 25/29] Updated systeminformation to use more helper methods --- .../cypress/integration/HelpPanel/systemInformation.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index e11324616c4a..196eaa123148 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -2,7 +2,7 @@ function openSystemInformation(){ //We have to wait for page to load, if the site is slow - cy.get('[data-element="global-help"]').should('be.visible', {timeout:10000}).click(); + cy.umbracoGlobalUser().should('be.visible', {timeout:10000}).click(); cy.get('.umb-help-list-item').last().should('be.visible').click(); cy.get('.umb-drawer-content').scrollTo('bottom', {ensureScrollable : false}); } @@ -14,6 +14,9 @@ context('System Information', () => { cy.umbracoLogin(Cypress.env('username'), Cypress.env('password')); cy.umbracoSetCurrentUserLanguage('en-US'); }); + afterEach(() => { + cy.umbracoSetCurrentUserLanguage('en-US'); + }); it('Check System Info Displays', () => { openSystemInformation(); @@ -25,7 +28,7 @@ context('System Information', () => { it('Checks language displays correctly after switching', () => { //Navigate to edit user and change language - cy.get('[data-element="global-user"]').click(); + cy.umbracoGlobalUser().click(); cy.get('[alias="editUser"]').click(); cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); From 1a25f723f7c887ea2d243435afd73e8a2016b160 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Thu, 7 Oct 2021 08:33:06 +0200 Subject: [PATCH 26/29] Updated test for the last time i swear --- .../cypress/integration/HelpPanel/systemInformation.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts index 196eaa123148..2cb5ce70c835 100644 --- a/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts +++ b/src/Umbraco.Tests.AcceptanceTest/cypress/integration/HelpPanel/systemInformation.ts @@ -2,7 +2,7 @@ function openSystemInformation(){ //We have to wait for page to load, if the site is slow - cy.umbracoGlobalUser().should('be.visible', {timeout:10000}).click(); + cy.get('[data-element="global-help"]').should('be.visible').click(); cy.get('.umb-help-list-item').last().should('be.visible').click(); cy.get('.umb-drawer-content').scrollTo('bottom', {ensureScrollable : false}); } @@ -30,10 +30,12 @@ context('System Information', () => { //Navigate to edit user and change language cy.umbracoGlobalUser().click(); cy.get('[alias="editUser"]').click(); - cy.get('[name="culture"]').select('string:da-DK', {timeout: 10000, force: true}); + cy.get('[name="culture"]').select('string:da-DK', { force: true}); cy.umbracoButtonByLabelKey('buttons_save').click({force: true}); //Refresh site to display new language cy.reload(); + cy.get('.umb-tour-step', { timeout: 60000 }).should('be.visible'); // We now due to the api calls this will be shown, but slow computers can take a while + cy.get('.umb-tour-step__close').click(); openSystemInformation(); //Assert cy.contains('Current Culture').parent().should('contain', 'da-DK'); From 09a35ef96ce778bf9d35e7f79035c7fd603ed080 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle Date: Thu, 7 Oct 2021 09:51:04 +0200 Subject: [PATCH 27/29] Fixed breaking change --- src/Umbraco.Core/Services/UserDataService.cs | 7 ++-- .../Controllers/CurrentUserController.cs | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Services/UserDataService.cs b/src/Umbraco.Core/Services/UserDataService.cs index f0dcf78c607b..490b5af6a8a0 100644 --- a/src/Umbraco.Core/Services/UserDataService.cs +++ b/src/Umbraco.Core/Services/UserDataService.cs @@ -20,9 +20,8 @@ public UserDataService(IUmbracoVersion version, ILocalizationService localizatio _localizationService = localizationService; } - public IEnumerable GetUserData() - { - var userDataList = new List + public IEnumerable GetUserData() => + new List { new("Server OS", RuntimeInformation.OSDescription), new("Server Framework", RuntimeInformation.FrameworkDescription), @@ -32,8 +31,6 @@ public IEnumerable GetUserData() new("Current UI Culture", Thread.CurrentThread.CurrentUICulture.ToString()), new("Current Webserver", GetCurrentWebServer()) }; - return userDataList; - } private string GetCurrentWebServer() => IsRunningInProcessIIS() ? "IIS" : "Kestrel"; diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index 6a836130175f..b174f447af42 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Newtonsoft.Json; using Umbraco.Cms.Core; @@ -24,6 +25,7 @@ using Umbraco.Cms.Web.BackOffice.Filters; using Umbraco.Cms.Web.Common.Attributes; using Umbraco.Cms.Web.Common.Authorization; +using Umbraco.Cms.Web.Common.DependencyInjection; using Umbraco.Cms.Web.Common.Security; using Umbraco.Extensions; using Constants = Umbraco.Cms.Core.Constants; @@ -80,6 +82,37 @@ public CurrentUserController( _userDataService = userDataService; } + [Obsolete("This constructor is obsolete, use constructor with all values")] + public CurrentUserController( + MediaFileManager mediaFileManager, + IOptions contentSettings, + IHostingEnvironment hostingEnvironment, + IImageUrlGenerator imageUrlGenerator, + IBackOfficeSecurityAccessor backofficeSecurityAccessor, + IUserService userService, + IUmbracoMapper umbracoMapper, + IBackOfficeUserManager backOfficeUserManager, + ILocalizedTextService localizedTextService, + AppCaches appCaches, + IShortStringHelper shortStringHelper, + IPasswordChanger passwordChanger) : + this(mediaFileManager, + contentSettings, + hostingEnvironment, + imageUrlGenerator, + backofficeSecurityAccessor, + userService, + umbracoMapper, + backOfficeUserManager, + localizedTextService, + appCaches, + shortStringHelper, + passwordChanger, + StaticServiceProvider.Instance.GetRequiredService()) + { + + } + /// /// Returns permissions for all nodes passed in for the current user From 70831bb0c09215248bd1edf4c3d28c7a58ee46c8 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:46:54 +0200 Subject: [PATCH 28/29] Update src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs --- src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index b174f447af42..010957f9d8a0 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -82,7 +82,7 @@ public CurrentUserController( _userDataService = userDataService; } - [Obsolete("This constructor is obsolete, use constructor with all values")] + [Obsolete("This constructor is obsolete and will be removed in v11, use constructor with all values")] public CurrentUserController( MediaFileManager mediaFileManager, IOptions contentSettings, From ae39256a84b1ae705982681f14d3fffc81a550eb Mon Sep 17 00:00:00 2001 From: nikolajlauridsen Date: Thu, 7 Oct 2021 12:49:36 +0200 Subject: [PATCH 29/29] Specify constructor for DI --- .../Controllers/CurrentUserController.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs index 010957f9d8a0..16b6590e576f 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs @@ -52,6 +52,7 @@ public class CurrentUserController : UmbracoAuthorizedJsonController private readonly IPasswordChanger _passwordChanger; private readonly IUserDataService _userDataService; + [ActivatorUtilitiesConstructor] public CurrentUserController( MediaFileManager mediaFileManager, IOptions contentSettings, @@ -95,8 +96,8 @@ public CurrentUserController( ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, - IPasswordChanger passwordChanger) : - this(mediaFileManager, + IPasswordChanger passwordChanger) : this( + mediaFileManager, contentSettings, hostingEnvironment, imageUrlGenerator, @@ -197,10 +198,7 @@ public IEnumerable GetUserTours() return userTours; } - public IEnumerable GetUserData() - { - return _userDataService.GetUserData(); - } + public IEnumerable GetUserData() => _userDataService.GetUserData(); /// /// When a user is invited and they click on the invitation link, they will be partially logged in