PerformanceTest.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System;
  4. using System.Linq;
  5. using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
  6. using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
  7. using Microsoft.AspNetCore.E2ETesting;
  8. using OpenQA.Selenium;
  9. using Xunit;
  10. using Xunit.Abstractions;
  11. namespace Microsoft.AspNetCore.Components.E2ETest.Tests
  12. {
  13. public class PerformanceTest
  14. : ServerTestBase<DevHostServerFixture<Wasm.Performance.TestApp.Program>>
  15. {
  16. public PerformanceTest(
  17. BrowserFixture browserFixture,
  18. DevHostServerFixture<Wasm.Performance.TestApp.Program> serverFixture,
  19. ITestOutputHelper output)
  20. : base(browserFixture, serverFixture, output)
  21. {
  22. }
  23. protected override void InitializeAsyncCore()
  24. {
  25. Navigate("/", noReload: true);
  26. }
  27. [Fact]
  28. public void HasTitle()
  29. {
  30. Assert.Equal("E2EPerformance", Browser.Title);
  31. }
  32. [Fact]
  33. public void BenchmarksRunWithoutError()
  34. {
  35. // In CI, we only verify that the benchmarks run without throwing any
  36. // errors. To get actual perf numbers, you must run the E2EPerformance
  37. // site manually.
  38. var verifyOnlyLabel = Browser.FindElement(By.XPath("//label[contains(text(), 'Verify only')]/input"));
  39. verifyOnlyLabel.Click();
  40. var runAllButton = Browser.FindElement(By.CssSelector("button.btn-success.run-button"));
  41. runAllButton.Click();
  42. // The "run" button goes away while the benchmarks execute, then it comes back
  43. Browser.False(() => runAllButton.Displayed);
  44. Browser.True(
  45. () => runAllButton.Displayed || Browser.FindElements(By.CssSelector(".benchmark-error")).Any(),
  46. TimeSpan.FromSeconds(60));
  47. Browser.DoesNotExist(By.CssSelector(".benchmark-error")); // no failures
  48. Browser.Exists(By.CssSelector(".benchmark-idle")); // everything's done
  49. }
  50. }
  51. }