mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-02 10:08:39 +00:00
Fix unit test failures
This commit is contained in:
parent
27663c0554
commit
2dcf8dd390
2 changed files with 6 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using LBPUnion.ProjectLighthouse.Configuration;
|
||||||
using LBPUnion.ProjectLighthouse.Localization;
|
using LBPUnion.ProjectLighthouse.Localization;
|
||||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||||
|
@ -47,6 +48,8 @@ public class BaseLayout : PageModel
|
||||||
|
|
||||||
private string getLanguage()
|
private string getLanguage()
|
||||||
{
|
{
|
||||||
|
if (ServerStatics.IsUnitTesting) return "en-US";
|
||||||
|
|
||||||
IRequestCultureFeature? requestCulture = Request.HttpContext.Features.Get<IRequestCultureFeature>();
|
IRequestCultureFeature? requestCulture = Request.HttpContext.Features.Get<IRequestCultureFeature>();
|
||||||
|
|
||||||
if (requestCulture == null) return LocalizationManager.DefaultLang;
|
if (requestCulture == null) return LocalizationManager.DefaultLang;
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class AuthenticationTests : LighthouseWebTest
|
||||||
[DatabaseFact]
|
[DatabaseFact]
|
||||||
public async Task ShouldLoginWithInjectedCookie()
|
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();
|
await using Database database = new();
|
||||||
Random random = new();
|
Random random = new();
|
||||||
|
@ -96,10 +96,10 @@ public class AuthenticationTests : LighthouseWebTest
|
||||||
INavigation navigation = this.Driver.Navigate();
|
INavigation navigation = this.Driver.Navigate();
|
||||||
|
|
||||||
navigation.GoToUrl(this.BaseAddress + "/");
|
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));
|
this.Driver.Manage().Cookies.AddCookie(new Cookie("LighthouseToken", webToken.UserToken));
|
||||||
Assert.Throws<NoSuchElementException>(() => this.Driver.FindElement(By.XPath(loggedInAsUsernameTextXPath)));
|
|
||||||
navigation.Refresh();
|
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);
|
await database.RemoveUser(user);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue