Skip to content

Commit

Permalink
Merge pull request #265 from Lombiq/issue/LMBQ-137
Browse files Browse the repository at this point in the history
LMBQ-137: Investigate and fix flaky visual verification UI tests
  • Loading branch information
sarahelsaig authored Mar 22, 2023
2 parents b9895a8 + b16fadb commit 5bbed7c
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace Lombiq.Tests.UI.Extensions;

Expand All @@ -33,19 +32,22 @@ public static class VisualVerificationUITestContextExtensions
/// Compares the baseline image and screenshot of the selected element on multiple different resolutions.
/// </summary>
/// <param name="sizes">The comparison is performed on each of these resolutions.</param>
/// <param name="beforeAssertAsync">
/// Task to be performed after the viewport has been resized but before the screenshot is taken. This can be used
/// for example if the page must be loaded in the given size.
/// </param>
/// <param name="getSelector">
/// Returns the selector for the given screen size. This may return the same selector all the time, or a different
/// selector, e.g. if mobile and desktop views have different DOMs.
/// </param>
/// <remarks>
/// <para>
/// The parameter <c>beforeAssertAsync</c> was removed, because it sometimes polluted the stack trace, which was
/// used in visual verification tests, so it caused tests to fail. The point of <c>beforeAssertAsync</c> was, that
/// sometimes the page can change on the resize window event. So the navigation happening after the window resize
/// ensures that the currently loaded page only existed with the desired screen size.
/// </para>
/// </remarks>
[VisualVerificationApprovedMethod]
public static async Task AssertVisualVerificationOnAllResolutionsAsync(
public static void AssertVisualVerificationOnAllResolutions(
this UITestContext context,
IEnumerable<Size> sizes,
Func<Task> beforeAssertAsync,
Func<Size, By> getSelector)
{
context.HideScrollbar();
Expand All @@ -54,7 +56,6 @@ public static async Task AssertVisualVerificationOnAllResolutionsAsync(
foreach (var size in sizes)
{
context.SetViewportSize(size);
await beforeAssertAsync();

try
{
Expand Down

0 comments on commit 5bbed7c

Please sign in to comment.