BreadcrumbTypeTests.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Microsoft.Playwright;
  2. using Tests.E2e.Infra;
  3. using Tests.E2e.PageObjectModels;
  4. using Xunit.Abstractions;
  5. namespace Tests.E2e;
  6. /// <summary>
  7. /// The breadcrumb used to label every System with its storage kind, so a guest on a
  8. /// hypervisor on a server read "host (server) / host-pve (system) / guest (system)" —
  9. /// the chain existed to show the nesting and then hid what each layer actually was.
  10. /// A System now reports its own type instead.
  11. /// </summary>
  12. public class BreadcrumbTypeTests(
  13. PlaywrightFixture fixture,
  14. ITestOutputHelper output) : E2ETestBase(fixture, output) {
  15. private readonly PlaywrightFixture _fixture = fixture;
  16. private readonly ITestOutputHelper _output = output;
  17. private static string HypervisorStack(string server, string hypervisor, string guest) =>
  18. $"""
  19. version: 4
  20. resources:
  21. - kind: Server
  22. name: {server}
  23. - kind: System
  24. name: {hypervisor}
  25. type: hypervisor
  26. runsOn:
  27. - {server}
  28. - kind: System
  29. name: {guest}
  30. type: vm
  31. runsOn:
  32. - {hypervisor}
  33. connections: []
  34. """;
  35. [Fact]
  36. public async Task A_breadcrumb_names_each_layers_type_not_its_storage_kind() {
  37. (IBrowserContext context, IPage page) = await CreatePageAsync();
  38. var server = $"e2e-bcs-{Guid.NewGuid():N}"[..14];
  39. var hypervisor = $"e2e-bch-{Guid.NewGuid():N}"[..14];
  40. var guest = $"e2e-bcg-{Guid.NewGuid():N}"[..14];
  41. try {
  42. var import = new YamlImportPom(page);
  43. await import.GotoAsync(_fixture.BaseUrl);
  44. await import.PasteAsync(HypervisorStack(server, hypervisor, guest));
  45. await import.AssertNoErrorAsync();
  46. await import.ApplyAsync();
  47. await page.GotoAsync(
  48. $"{_fixture.BaseUrl}/resources/systems/{Uri.EscapeDataString(guest)}");
  49. await Assertions.Expect(page.GetByTestId("circuit-probe"))
  50. .ToHaveAttributeAsync("data-circuit-ready", "true");
  51. var body = await page.InnerTextAsync("body");
  52. Assert.Contains("(Server)", body);
  53. Assert.Contains("(Hypervisor)", body);
  54. Assert.Contains("(VM)", body);
  55. // The kind must no longer stand in for the two systems' types.
  56. Assert.DoesNotContain("(system)", body, StringComparison.OrdinalIgnoreCase);
  57. }
  58. catch (Exception) {
  59. _output.WriteLine($"TEST FAILED — URL: {page.Url}");
  60. _output.WriteLine(await page.ContentAsync());
  61. throw;
  62. }
  63. finally {
  64. await context.CloseAsync();
  65. }
  66. }
  67. }