SystemTests.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using Tests.E2e.Infra;
  2. using Tests.E2e.PageObjectModels;
  3. using Xunit.Abstractions;
  4. namespace Tests.E2e;
  5. public class SystemTests(
  6. PlaywrightFixture fixture,
  7. ITestOutputHelper output) : E2ETestBase(fixture, output)
  8. {
  9. private readonly ITestOutputHelper _output = output;
  10. [Fact]
  11. public async Task User_Can_Add_And_Delete_System()
  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. await layout.GotoSystemsAsync();
  22. var systems = new SystemsListPom(page);
  23. var systemName = $"e2e-system-{Guid.NewGuid():N}"[..12];
  24. await systems.AddSystemAsync(systemName);
  25. await systems.AssertSystemExists(systemName);
  26. await systems.DeleteSystemAsync(systemName);
  27. await systems.AssertSystemDoesNotExist(systemName);
  28. await context.CloseAsync();
  29. }
  30. catch (Exception ex)
  31. {
  32. _output.WriteLine("TEST FAILED — Capturing diagnostics");
  33. _output.WriteLine($"Current URL: {page.Url}");
  34. var html = await page.ContentAsync();
  35. _output.WriteLine("==== DOM SNAPSHOT START ====");
  36. _output.WriteLine(html);
  37. _output.WriteLine("==== DOM SNAPSHOT END ====");
  38. throw;
  39. }
  40. finally
  41. {
  42. await context.CloseAsync();
  43. }
  44. }
  45. }