Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DemeSzabolcs committed Jan 31, 2025
2 parents fb188b2 + dfb420d commit 806f368
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,18 @@ public class OrchardCoreUITestExecutorConfiguration
public Func<IWebApplicationInstance, Task> AssertAppLogsAsync { get; set; } = AssertAppLogsCanContainCacheFolderErrorsAsync;

/// <summary>
/// Selects which response data get saved to <see cref="UITestContext.CumulativeBrowserLog"/>.
/// Gets or sets a delegate that selects which response data get saved to <see
/// cref="UITestContext.CumulativeBrowserLog"/>.
/// </summary>
public Func<Entry, bool> BrowserLogFilter = IsNonSuccessBrowserLogEntry;
public Func<Entry, bool> BrowserLogFilter { get; set; } = IsNonSuccessBrowserLogEntry;

public Action<IEnumerable<Entry>> AssertBrowserLog { get; set; } = AssertBrowserLogIsEmpty;

/// <summary>
/// Selects which response data get saved to <see cref="UITestContext.CumulativeResponseLog"/>.
/// Gets or sets a delegate that selects which response data get saved to <see
/// cref="UITestContext.CumulativeResponseLog"/>.
/// </summary>
public Func<ResponseCompletedEventArgs, bool> ResponseLogFilter = IsNonSuccessResponse;
public Func<ResponseCompletedEventArgs, bool> ResponseLogFilter { get; set; } = IsNonSuccessResponse;

public Action<IEnumerable<ResponseData>> AssertResponseLog { get; set; } = AssertResponseLogIsEmpty;

Expand Down
4 changes: 4 additions & 0 deletions Lombiq.Tests.UI/Services/UITestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ public static async Task<UITestContext> CreateAsync(
{
var biDi = await scope.Driver.AsBiDiAsync();

// We intentionally don't pass the UITestContext to these callbacks: The callbacks are called asynchronously
// by the browser (and Selenium), and e.g. the current URL can change between when a JS exception was thrown
// and the callback is called. Thus, BrowserLogFilter could e.g. ignore log entries for a URL that actually
// originated from a different URL and shouldn't be ignored.
await biDi.Log.OnEntryAddedAsync(entry =>
{
if (configuration.BrowserLogFilter(entry)) context._cumulativeBrowserLog.Enqueue(entry);
Expand Down

0 comments on commit 806f368

Please sign in to comment.