From 3f15930d61f360d6349cd4ef7040ac88ae64ec0d Mon Sep 17 00:00:00 2001 From: Zaprit Date: Fri, 11 Jul 2025 10:38:20 +0100 Subject: [PATCH] Fix race condition in test --- .../Integration/AuthenticationTests.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse.Tests.WebsiteTests/Integration/AuthenticationTests.cs b/ProjectLighthouse.Tests.WebsiteTests/Integration/AuthenticationTests.cs index 1fa9feff..ce6316a7 100644 --- a/ProjectLighthouse.Tests.WebsiteTests/Integration/AuthenticationTests.cs +++ b/ProjectLighthouse.Tests.WebsiteTests/Integration/AuthenticationTests.cs @@ -26,7 +26,11 @@ public class AuthenticationTests : LighthouseWebTest string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray()); UserEntity user = await database.CreateUser($"unitTestUser{CryptoHelper.GenerateRandomInt32()}", CryptoHelper.BCryptHash(CryptoHelper.Sha256Hash(password))); - this.Driver.Navigate().GoToUrl(this.BaseAddress + "/login"); + // Sometimes not having this causes a race condition + // ReSharper disable once MethodHasAsyncOverload + database.SaveChanges(); + + await this.Driver.Navigate().GoToUrlAsync(this.BaseAddress + "/login"); this.Driver.FindElement(By.Id("text")).SendKeys(user.Username); this.Driver.FindElement(By.Id("password")).SendKeys(password);