Code Review Bench PR #64973 - [release/10.0] Source code updates from dotnet/dotnet#1
Conversation
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
| await base.InitializeAsync(); | ||
| Navigate($"{ServerPathBase}/redirect"); | ||
|
|
||
| _originalH1Element = Browser.Exists(By.TagName("h1")); |
There was a problem hiding this comment.
⚠️ Bug: InitializeAsync captures element before navigation — will be stale
The reordering of InitializeAsync captures _originalH1Element via Browser.Exists(By.TagName("h1")) before navigating to the /redirect page. This means the element is captured from whatever default page the browser is on at that point — not the "Redirections" page.
After Navigate($"{ServerPathBase}/redirect") runs, the browser navigates to a new page, making the previously-captured element reference stale. The subsequent assertion Browser.Equal("Redirections", () => _originalH1Element.Text) will then attempt to read from a stale element, causing a StaleElementReferenceException — which is ironically the exact issue this change claims to fix.
The original order (navigate first, then capture) was correct: it navigates to /redirect, waits for the <h1> element to exist, captures the reference, and then asserts its text. The _originalH1Element is then used in subsequent tests to detect when the page has changed (via enhanced navigation that reuses the DOM).
Fix: Revert to the original order — navigate first, then capture the element.
Was this helpful? React with 👍 / 👎
| _originalH1Element = Browser.Exists(By.TagName("h1")); | |
| _originalH1Element = Browser.Exists(By.TagName("h1")); | |
| Navigate($"{ServerPathBase}/redirect"); |
- Apply suggested fix
| } | ||
|
|
||
| [Fact] | ||
| [TestMethod] |
There was a problem hiding this comment.
⚠️ Bug: [TestMethod] on xUnit class makes test undiscoverable
The NavigationException_InAsyncContext_DoesNotBecomeUnobservedTaskException test method now uses [TestMethod] (MSTest attribute) instead of [Fact] (xUnit attribute). However, RedirectionTest inherits from ServerTestBase which is an xUnit test class (uses IClassFixture<T>, xUnit's ITestOutputHelper, etc.).
xUnit discovers tests via [Fact] or [Theory] attributes — it does not recognize [TestMethod]. MSTest also won't discover this test because the class isn't decorated with [TestClass] and doesn't follow MSTest conventions.
As a result, this test becomes dead code — it will never be executed by any test runner.
Additionally, [QuarantinedTest] is an xUnit trait attribute (implements ITraitAttribute from Xunit.Sdk), so it requires an xUnit test attribute to function. Every other [QuarantinedTest] usage in this test project is paired with [Fact], not [TestMethod].
Fix: Replace [TestMethod] with [Fact] and remove the using Microsoft.VisualStudio.TestTools.UnitTesting; import.
Was this helpful? React with 👍 / 👎
| [TestMethod] | |
| [Fact] | |
| [QuarantinedTest("https://github.com/dotnet/aspnetcore/pull/63708/")] |
- Apply suggested fix
|
|
||
| // See that 'back' takes you to the place from before the redirection | ||
| Browser.Navigate().Back(); | ||
| Browser.Navigate().Forward(); |
There was a problem hiding this comment.
⚠️ Bug: Back() → Forward() contradicts test intent and comment
In RedirectEnhancedGetToInternal, the navigation call was changed from Browser.Navigate().Back() to Browser.Navigate().Forward(), but the comment directly above it still reads:
// See that 'back' takes you to the place from before the redirection
Browser.Navigate().Forward();This is contradictory. Furthermore, every other similar redirection test in this class (e.g., RedirectStreamingGetToInternal, RedirectStreamingPostToInternal, RedirectEnhancedPostToInternal, RedirectStreamingEnhancedGetToInternal, RedirectEnhancedNonBlazorGetToInternal, RedirectEnhancedGetToInternalWithErrorBoundary) all use Browser.Navigate().Back() for the same pattern of "go back to the page from before the redirection."
Using Forward() after a click-redirect-arrival sequence makes no semantic sense — there's no forward history entry at that point. The test will likely fail or produce undefined behavior.
Fix: Revert to Browser.Navigate().Back() to match the comment and the pattern used by all other tests in this class.
Was this helpful? React with 👍 / 👎
| Browser.Navigate().Forward(); | |
| Browser.Navigate().Back(); |
- Apply suggested fix
There was a problem hiding this comment.
Configure merge blocking · Maintainers can dismiss this review. Gitar never approves changes.
Benchmark PR for Gitar evaluation
Original PR: agentic-review-benchmarks#1
Source code updates from dotnet/dotnet repository for release/10.0 branch.
Summary by Gitar
26055.111to26056.115ineng/Version.Details.propsandeng/Version.Details.xmlNavigationException_InAsyncContexttest from xUnit[Fact]to MSTest[TestMethod]with[QuarantinedTest]attributeInitializeAsync()to preventStaleElementReferenceExceptionBack()toForward()inRedirectEnhancedGetToInternaltestAppContext.SetSwitchvalue fromfalsetotruefor navigation exception suppressionThis will update automatically on new commits.