diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index 96c853b68..b3d36c370 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -384,6 +384,11 @@ namespace BTCPayServer.Tests Driver.FindElement(By.Id($"Wallet{navPages}")).Click(); } } + + public void GoToUrl(string relativeUrl) + { + Driver.Navigate().GoToUrl(new Uri(Server.PayTester.ServerUri, relativeUrl)); + } public void GoToServer(ServerNavPages navPages = ServerNavPages.Index) { diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index 531200616..b57efba9d 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -203,6 +203,46 @@ namespace BTCPayServer.Tests } } + [Fact(Timeout = TestTimeout)] + public async Task CanSetupEmailServer() + { + using (var s = SeleniumTester.Create()) + { + await s.StartAsync(); + var alice = s.RegisterNewUser(isAdmin: true); + s.Driver.Navigate().GoToUrl(s.Link("/server/emails")); + if (s.Driver.PageSource.Contains("Configured")) + { + s.Driver.FindElement(By.CssSelector("button[value=\"ResetPassword\"]")).Submit(); + s.AssertHappyMessage(); + } + CanSetupEmailCore(s); + s.CreateNewStore(); + s.GoToUrl($"stores/{s.StoreId}/emails"); + CanSetupEmailCore(s); + } + } + + private static void CanSetupEmailCore(SeleniumTester s) + { + s.Driver.FindElement(By.ClassName("dropdown-toggle")).Click(); + s.Driver.FindElement(By.ClassName("dropdown-item")).Click(); + s.Driver.FindElement(By.Id("Settings_Login")).SendKeys("test@gmail.com"); + s.Driver.FindElement(By.CssSelector("button[value=\"Save\"]")).Submit(); + s.AssertHappyMessage(); + s.Driver.FindElement(By.Id("Settings_Password")).SendKeys("mypassword"); + s.Driver.FindElement(By.CssSelector("button[value=\"Save\"]")).Submit(); + Assert.Contains("Configured", s.Driver.PageSource); + s.Driver.FindElement(By.Id("Settings_Login")).SendKeys("test_fix@gmail.com"); + s.Driver.FindElement(By.CssSelector("button[value=\"Save\"]")).Submit(); + Assert.Contains("Configured", s.Driver.PageSource); + Assert.Contains("test_fix", s.Driver.PageSource); + s.Driver.FindElement(By.CssSelector("button[value=\"ResetPassword\"]")).Submit(); + s.AssertHappyMessage(); + Assert.DoesNotContain("Configured", s.Driver.PageSource); + Assert.Contains("test_fix", s.Driver.PageSource); + } + [Fact(Timeout = TestTimeout)] public async Task CanUseDynamicDns() { diff --git a/BTCPayServer/Controllers/StoresController.Email.cs b/BTCPayServer/Controllers/StoresController.Email.cs index df5e2d5ba..1551489e2 100644 --- a/BTCPayServer/Controllers/StoresController.Email.cs +++ b/BTCPayServer/Controllers/StoresController.Email.cs @@ -59,7 +59,7 @@ namespace BTCPayServer.Controllers store.SetStoreBlob(storeBlob); await _Repo.UpdateStore(store); TempData[WellKnownTempData.SuccessMessage] = "Email server password reset"; - return RedirectToAction(nameof(UpdateStore), new + return RedirectToAction(nameof(Emails), new { storeId }); @@ -76,7 +76,7 @@ namespace BTCPayServer.Controllers store.SetStoreBlob(storeBlob); await _Repo.UpdateStore(store); TempData[WellKnownTempData.SuccessMessage] = "Email settings modified"; - return RedirectToAction(nameof(UpdateStore), new + return RedirectToAction(nameof(Emails), new { storeId });