4
0

SubnetBrowserPom.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Microsoft.Playwright;
  2. namespace Tests.E2e.PageObjectModels;
  3. public class SubnetBrowserPom(IPage page) {
  4. // -------------------------------------------------
  5. // Root
  6. // -------------------------------------------------
  7. public ILocator Root
  8. => page.GetByTestId("subnet-browser-root");
  9. public ILocator Title
  10. => page.GetByTestId("subnet-browser-title");
  11. public ILocator Filter
  12. => page.GetByTestId("subnet-browser-filter");
  13. // -------------------------------------------------
  14. // States
  15. // -------------------------------------------------
  16. public ILocator Loading
  17. => page.GetByTestId("subnet-browser-loading");
  18. public ILocator Empty
  19. => page.GetByTestId("subnet-browser-empty");
  20. public ILocator List
  21. => page.GetByTestId("subnet-browser-list");
  22. /// <summary>
  23. /// A subnet group, addressed by its /24 key. The page groups on the
  24. /// first three octets, so 10.42.7.21 lands in the "10.42.7.x" group.
  25. /// </summary>
  26. public ILocator Group(string subnetKey)
  27. => page.GetByTestId($"subnet-group-{subnetKey.Replace('.', '-')}");
  28. // -------------------------------------------------
  29. // High-Level Actions
  30. // -------------------------------------------------
  31. public async Task AssertLoadedAsync() {
  32. await Assertions.Expect(Root).ToBeVisibleAsync();
  33. await Assertions.Expect(Title).ToBeVisibleAsync();
  34. }
  35. /// <summary>
  36. /// The filter binds on oninput, so no explicit blur is needed here.
  37. /// </summary>
  38. public async Task FilterAsync(string value)
  39. => await Filter.FillAsync(value);
  40. public async Task AssertGroupVisibleAsync(string subnetKey)
  41. => await Assertions.Expect(Group(subnetKey)).ToBeVisibleAsync();
  42. public async Task AssertGroupContainsAsync(string subnetKey, string text)
  43. => await Assertions.Expect(Group(subnetKey)).ToContainTextAsync(text);
  44. public async Task AssertEmptyAsync()
  45. => await Assertions.Expect(Empty).ToBeVisibleAsync();
  46. }