AnsibleInventoryTests.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Tests.E2e.Infra;
  2. using Tests.E2e.PageObjectModels;
  3. using Xunit.Abstractions;
  4. namespace Tests.E2e;
  5. public class AnsibleInventoryTests(
  6. PlaywrightFixture fixture,
  7. ITestOutputHelper output) : E2ETestBase(fixture, output)
  8. {
  9. private readonly ITestOutputHelper _output = output;
  10. [Fact]
  11. public async Task User_Can_Generate_Ansible_Inventory()
  12. {
  13. var (context, page) = await CreatePageAsync();
  14. try
  15. {
  16. // Go home
  17. await page.GotoAsync(fixture.BaseUrl);
  18. _output.WriteLine($"URL after Goto: {page.Url}");
  19. var layout = new MainLayoutPom(page);
  20. await layout.AssertLoadedAsync();
  21. // Navigate directly to inventory page
  22. await page.GotoAsync($"{fixture.BaseUrl}/ansible/inventory");
  23. var inventoryPage = new AnsibleInventoryPagePom(page);
  24. await inventoryPage.AssertVisibleAsync();
  25. // Configure options
  26. await inventoryPage.SetGroupByTagsAsync("prod,staging");
  27. await inventoryPage.SetGroupByLabelsAsync("env");
  28. await inventoryPage.SetGlobalVarsAsync("""
  29. ansible_user=ansible
  30. ansible_python_interpreter=/usr/bin/python3
  31. """);
  32. // Generate inventory
  33. await inventoryPage.GenerateAsync();
  34. // Assert output contains expected sections
  35. await inventoryPage.AssertInventoryContainsAsync("[all:vars]");
  36. await inventoryPage.AssertInventoryContainsAsync("ansible_user=ansible");
  37. // Ensure no warnings shown
  38. await inventoryPage.AssertNoWarningsAsync();
  39. await context.CloseAsync();
  40. }
  41. catch (Exception)
  42. {
  43. _output.WriteLine("TEST FAILED — Capturing diagnostics");
  44. _output.WriteLine($"Current URL: {page.Url}");
  45. var html = await page.ContentAsync();
  46. _output.WriteLine("==== DOM SNAPSHOT START ====");
  47. _output.WriteLine(html);
  48. _output.WriteLine("==== DOM SNAPSHOT END ====");
  49. throw;
  50. }
  51. finally
  52. {
  53. await context.CloseAsync();
  54. }
  55. }
  56. }