using System.Text.RegularExpressions; using Microsoft.Playwright; using Microsoft.Playwright.NUnit; using PlaywrightTests.Utilities; namespace PlaywrightTests; [Parallelizable(ParallelScope.Self)] [TestFixture] [Category("version2")] public class WebaccountTests : PageTest { private static LocatorClickOptions TenSLocatorTimout => new() {Timeout = 10_000}; private static LocatorAssertionsToBeVisibleOptions TenSLocatorAssertTimout => new() {Timeout = 10_000}; [SetUp] public async Task Setup() { await Context.Tracing.StartAsync(new() { Title = $"{TestContext.CurrentContext.Test.ClassName}.{TestContext.CurrentContext.Test.Name}", Screenshots = true, Snapshots = true, Sources = true }); } [TearDown] public async Task TearDown() { await Context.Tracing.StopAsync(new() { Path = Path.Combine( TestContext.CurrentContext.WorkDirectory, "playwright-traces", $"{TestContext.CurrentContext.Test.ClassName}.{TestContext.CurrentContext.Test.Name}.zip" ) }); } [Test] public async Task Login() { await Auth.LoginWebAccount(Page); } [Test] public async Task CheckWebAccount() { await Auth.LoginWebAccount(Page); await Page.Locator("a").Filter(new() { HasText = "Shop" }).ClickAsync(); await Expect(Page.GetByText("Wartung Printer laut Vertrag")).ToBeVisibleAsync(TenSLocatorAssertTimout); await Page.GetByRole(AriaRole.Button, new() { Name = "Add to cart" }).ClickAsync(); await Expect(Page.GetByText("The article has been added to")).ToBeVisibleAsync(); await Page.Locator("li").Filter(new() { HasText = "Cart" }).ClickAsync(); await Page.GetByRole(AriaRole.Button, new() { Name = "Request approval" }).ClickAsync(); await Expect(Page.Locator("b")).ToContainTextAsync("Waiting for approval"); await Page.GetByRole(AriaRole.Button, new() { Name = "Approve", Exact = true }).ClickAsync(); await Expect(Page.GetByText("The cart was approved and is")).ToBeVisibleAsync(); await Expect(Page.Locator("b")).ToContainTextAsync("Ready for order"); } [Test] public async Task CheckWebAccountTickets() { await Auth.LoginWebAccount(Page); await Page.GetByRole(AriaRole.Link, new() { Name = " Tickets" }).ClickAsync(); await Expect(Page.GetByText("Ticketname")).ToBeVisibleAsync(); await Expect(Page.GetByText("Status")).ToBeVisibleAsync(); await Expect(Page.GetByText("Nummer")).ToBeVisibleAsync(); await Expect(Page.GetByText("Erstellt am")).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "12001" })).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "12002" })).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "12003" })).ToBeVisibleAsync(); } [Test] public async Task CheckWebAccountTicketViews() { await Auth.LoginWebAccount(Page); await Page.GetByRole(AriaRole.Link, new() { Name = " Tickets" }).ClickAsync(); await Expect(Page.Locator("div").Filter(new() { HasTextRegex = new Regex("^Offen$") })).ToBeVisibleAsync(); await Expect(Page.GetByText("Abgeschlossene")).ToBeVisibleAsync(); await Expect(Page.GetByText("Ausstehende")).ToBeVisibleAsync(); await Expect(Page.GetByText("Abgelehnte")).ToBeVisibleAsync(); } [Test] public async Task CheckWebAccountReceipts() { await Auth.LoginWebAccount(Page); await Page.Locator("a").Filter(new() { HasText = "Receipts" }).ClickAsync(); await Expect(Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "All" })).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Offers" })).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Orders" })).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Delivery notes" })).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Invoices" })).ToBeVisibleAsync(); await Expect(Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Credit notes" })).ToBeVisibleAsync(); await Expect(Page.Locator(".grid")).ToBeVisibleAsync(); await Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "All" }).ClickAsync(); await Expect(Page.Locator(".grid")).ToBeVisibleAsync(); await Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Offers" }).ClickAsync(); await Expect(Page.Locator(".grid")).ToBeVisibleAsync(); await Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Orders" }).ClickAsync(); await Expect(Page.Locator(".grid")).ToBeVisibleAsync(); await Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Orders" }).ClickAsync(); await Expect(Page.Locator(".grid")).ToBeVisibleAsync(); await Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Invoices" }).ClickAsync(); await Expect(Page.Locator(".grid")).ToBeVisibleAsync(); await Page.GetByRole(AriaRole.Listitem).Filter(new() { HasText = "Credit notes" }).ClickAsync(); await Expect(Page.Locator(".grid")).ToBeVisibleAsync(); } [Test] public async Task CheckWebAccountTicketsCanSeeDisabled() { await Auth.LoginWebAccount(Page, AvailableWebAccountForTests.Alpha); await Page.GetByRole(AriaRole.Link, new() { Name = " Tickets" }).ClickAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "No data to display" })).ToBeVisibleAsync(TenSLocatorAssertTimout); await Page.Locator("div").Filter(new() { HasTextRegex = new Regex("^Abgeschlossene$") }).ClickAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "No data to display" })).ToBeVisibleAsync(); } [Test] public async Task CheckWebAccountTicketsCanSeeEnabled() { await Auth.LoginWebAccount(Page, AvailableWebAccountForTests.Beta); await Page.GetByRole(AriaRole.Link, new() { Name = " Tickets" }).ClickAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Open Beta Ticket" })).ToBeVisibleAsync(TenSLocatorAssertTimout); await Page.Locator("div").Filter(new() { HasTextRegex = new Regex("^Abgeschlossene$") }).ClickAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Closed Beta Ticket" })).ToBeVisibleAsync(); } [Test] public async Task CheckWebAccountTicketsAfter240101() { await Auth.LoginWebAccount(Page, AvailableWebAccountForTests.Gamma); await Page.GetByRole(AriaRole.Link, new() { Name = " Tickets" }).ClickAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Open Gamma Ticket - after" })).ToBeVisibleAsync(TenSLocatorAssertTimout); await Page.Locator("div").Filter(new() { HasTextRegex = new Regex("^Abgeschlossene$") }).ClickAsync(); await Expect(Page.GetByRole(AriaRole.Cell, new() { Name = "Closed Gamma Ticket - after" })).ToBeVisibleAsync(); } }