diff --git a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs index 00a15e2a..3537e4cb 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Layouts/BaseLayout.cshtml.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Collections.Generic; +using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Localization; using LBPUnion.ProjectLighthouse.Localization.StringLists; using LBPUnion.ProjectLighthouse.PlayerData.Profiles; @@ -47,6 +48,8 @@ public class BaseLayout : PageModel private string getLanguage() { + if (ServerStatics.IsUnitTesting) return "en-US"; + IRequestCultureFeature? requestCulture = Request.HttpContext.Features.Get(); if (requestCulture == null) return LocalizationManager.DefaultLang; diff --git a/ProjectLighthouse.Tests.WebsiteTests/Tests/AuthenticationTests.cs b/ProjectLighthouse.Tests.WebsiteTests/Tests/AuthenticationTests.cs index 35a20bb4..af4c9af2 100644 --- a/ProjectLighthouse.Tests.WebsiteTests/Tests/AuthenticationTests.cs +++ b/ProjectLighthouse.Tests.WebsiteTests/Tests/AuthenticationTests.cs @@ -78,7 +78,7 @@ public class AuthenticationTests : LighthouseWebTest [DatabaseFact] public async Task ShouldLoginWithInjectedCookie() { - const string loggedInAsUsernameTextXPath = "/html/body/div/div/div/p[1]/b"; + const string loggedInAsUsernameTextXPath = "/html/body/div/div/div/p[1]"; await using Database database = new(); Random random = new(); @@ -96,10 +96,10 @@ public class AuthenticationTests : LighthouseWebTest INavigation navigation = this.Driver.Navigate(); navigation.GoToUrl(this.BaseAddress + "/"); + Assert.DoesNotContain(user.Username, this.Driver.FindElement(By.XPath(loggedInAsUsernameTextXPath)).Text); this.Driver.Manage().Cookies.AddCookie(new Cookie("LighthouseToken", webToken.UserToken)); - Assert.Throws(() => this.Driver.FindElement(By.XPath(loggedInAsUsernameTextXPath))); navigation.Refresh(); - Assert.True(this.Driver.FindElement(By.XPath(loggedInAsUsernameTextXPath)).Text == user.Username); + Assert.Contains(user.Username, this.Driver.FindElement(By.XPath(loggedInAsUsernameTextXPath)).Text); await database.RemoveUser(user); }