Updated based on review
Signed-off-by: Nikolaj Geisle <niko737@edu.ucl.dk>
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Umbraco.Cms.Core.Services
|
||||
{
|
||||
private readonly IUmbracoVersion _version;
|
||||
private readonly ILocalizationService _localizationService;
|
||||
|
||||
public UserDataService(IUmbracoVersion version, ILocalizationService localizationService)
|
||||
{
|
||||
_version = version;
|
||||
@@ -23,26 +24,19 @@ namespace Umbraco.Cms.Core.Services
|
||||
{
|
||||
var userDataList = new List<UserData>
|
||||
{
|
||||
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))
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services
|
||||
[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 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services
|
||||
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 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services
|
||||
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 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Services
|
||||
[TestCase("sv-SE")]
|
||||
public void RunTimeInformationNotNullTest(string culture)
|
||||
{
|
||||
CreateLocalizationVersion(culture);
|
||||
var userDataService = new UserDataService(_umbracoVersion, _localizationService);
|
||||
IEnumerable<UserData> userData = userDataService.GetUserData();
|
||||
var userDataService = CreateUserDataService(culture);
|
||||
IEnumerable<UserData> 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<ILocalizationService>();
|
||||
localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns(culture);
|
||||
_localizationService = localizationService.Object;
|
||||
return localizationService.Object;
|
||||
}
|
||||
|
||||
private void CreateUmbracoVersion(int major, int minor, int patch)
|
||||
|
||||
Reference in New Issue
Block a user