(Refactor) : Converted Selenium test for CanSetupStoreViaGuide and CanImportWallet to playwright (#6850)

* (Test):Converted/Added Playwright Test for CanSetupStoreViaGuide

Signed-off-by: Abhijay jain <Abhijay007j@gmail.com>

* (Refactor): Removed Selenium Test for CanSetupStoreViaGuide

Signed-off-by: Abhijay jain <Abhijay007j@gmail.com>

* (Test):Converted/Added Playwright Test for CanImportWallet

Signed-off-by: Abhijay jain <Abhijay007j@gmail.com>

* (Refactor): Removed Selenium Test for CanImportWallet

Signed-off-by: Abhijay jain <Abhijay007j@gmail.com>

---------

Signed-off-by: Abhijay jain <Abhijay007j@gmail.com>
This commit is contained in:
Abhijay Jain
2025-07-16 09:30:14 +05:30
committed by GitHub
parent 89c836e5f9
commit abcae2f64f
2 changed files with 52 additions and 51 deletions

View File

@@ -1328,6 +1328,58 @@ namespace BTCPayServer.Tests
}
}
}
[Fact]
public async Task CanSetupStoreViaGuide()
{
await using var s = CreatePlaywrightTester();
await s.StartAsync();
await s.RegisterNewUser();
await s.GoToUrl("/");
// verify redirected to create store page
Assert.EndsWith("/stores/create", s.Page.Url);
Assert.Contains("Create your first store", await s.Page.ContentAsync());
Assert.Contains("Create a store to begin accepting payments", await s.Page.ContentAsync());
Assert.Equal(0, await s.Page.Locator("#StoreSelectorDropdown").CountAsync());
(_, string storeId) = await s.CreateNewStore();
// should redirect to first store
await s.GoToUrl("/");
Assert.Contains($"/stores/{storeId}", s.Page.Url);
Assert.Equal(1, await s.Page.Locator("#StoreSelectorDropdown").CountAsync());
Assert.Equal(1, await s.Page.Locator("#SetupGuide").CountAsync());
await s.GoToUrl("/stores/create");
Assert.Contains("Create a new store", await s.Page.ContentAsync());
Assert.DoesNotContain("Create your first store", await s.Page.ContentAsync());
Assert.DoesNotContain("To start accepting payments, set up a store.", await s.Page.ContentAsync());
}
[Fact]
public async Task CanImportWallet()
{
await using var s = CreatePlaywrightTester();
await s.StartAsync();
await s.RegisterNewUser(true);
await s.CreateNewStore();
const string cryptoCode = "BTC";
var mnemonic = await s.GenerateWallet(cryptoCode, "click chunk owner kingdom faint steak safe evidence bicycle repeat bulb wheel");
// Make sure wallet info is correct
await s.GoToWalletSettings(cryptoCode);
Assert.Contains(mnemonic.DeriveExtKey().GetPublicKey().GetHDFingerPrint().ToString(),
await s.Page.GetAttributeAsync("#AccountKeys_0__MasterFingerprint", "value"));
Assert.Contains("m/84'/1'/0'",
await s.Page.GetAttributeAsync("#AccountKeys_0__AccountKeyPath", "value"));
// Transactions list is empty
await s.Page.ClickAsync($"#StoreNav-Wallet{cryptoCode}");
await s.Page.WaitForSelectorAsync("#WalletTransactions[data-loaded='true']");
Assert.Contains("There are no transactions yet", await s.Page.Locator("#WalletTransactions").TextContentAsync());
}
}
}

View File

@@ -165,34 +165,6 @@ namespace BTCPayServer.Tests
});
}
[Fact(Timeout = TestTimeout)]
public async Task CanSetupStoreViaGuide()
{
using var s = CreateSeleniumTester();
await s.StartAsync();
s.RegisterNewUser();
s.GoToUrl("/");
// verify redirected to create store page
Assert.EndsWith("/stores/create", s.Driver.Url);
Assert.Contains("Create your first store", s.Driver.PageSource);
Assert.Contains("Create a store to begin accepting payments", s.Driver.PageSource);
Assert.False(s.Driver.PageSource.Contains("id=\"StoreSelectorDropdown\""), "Store selector dropdown should not be present");
(_, string storeId) = s.CreateNewStore();
// should redirect to first store
s.GoToUrl("/");
Assert.Contains($"/stores/{storeId}", s.Driver.Url);
Assert.True(s.Driver.PageSource.Contains("id=\"StoreSelectorDropdown\""), "Store selector dropdown should be present");
Assert.True(s.Driver.PageSource.Contains("id=\"SetupGuide\""), "Store setup guide should be present");
s.GoToUrl("/stores/create");
Assert.Contains("Create a new store", s.Driver.PageSource);
Assert.DoesNotContain("Create your first store", s.Driver.PageSource);
Assert.DoesNotContain("To start accepting payments, set up a store.", s.Driver.PageSource);
}
[Fact(Timeout = TestTimeout)]
[Trait("Lightning", "Lightning")]
public async Task CanCreateStores()
@@ -1220,29 +1192,6 @@ namespace BTCPayServer.Tests
s.Driver.AssertElementNotFound(By.Id("LightningNodeUrlClearnet"));
}
[Fact(Timeout = TestTimeout)]
public async Task CanImportWallet()
{
using var s = CreateSeleniumTester();
await s.StartAsync();
s.RegisterNewUser(true);
s.CreateNewStore();
const string cryptoCode = "BTC";
var mnemonic = s.GenerateWallet(cryptoCode, "click chunk owner kingdom faint steak safe evidence bicycle repeat bulb wheel");
// Make sure wallet info is correct
s.GoToWalletSettings(cryptoCode);
Assert.Contains(mnemonic.DeriveExtKey().GetPublicKey().GetHDFingerPrint().ToString(),
s.Driver.FindElement(By.Id("AccountKeys_0__MasterFingerprint")).GetAttribute("value"));
Assert.Contains("m/84'/1'/0'",
s.Driver.FindElement(By.Id("AccountKeys_0__AccountKeyPath")).GetAttribute("value"));
// Transactions list is empty
s.Driver.FindElement(By.Id($"StoreNav-Wallet{cryptoCode}")).Click();
s.Driver.WaitWalletTransactionsLoaded();
Assert.Contains("There are no transactions yet", s.Driver.FindElement(By.Id("WalletTransactions")).Text);
}
[Fact]
[Trait("Selenium", "Selenium")]
[Trait("Lightning", "Lightning")]