Skip to content

Conversation

@mxschmitt
Copy link
Contributor

This only affects our internal tests.

Fixes #3118

@mxschmitt mxschmitt force-pushed the chore--migrate-from-TimeoutAttribute-to-CancelAfterAttribute branch 2 times, most recently from 5ed9631 to dbbc139 Compare March 5, 2025 10:58

using System.Runtime.InteropServices;

[assembly: NUnit.Framework.Timeout(Microsoft.Playwright.Tests.TestConstants.DefaultTestTimeout)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First line removed, second line moved to the PlaywrightTestAttribute.cs.



[PlaywrightTest("screencast.spec.ts", "video.path()/saveAs() does not hang immediately after launchPersistentContext and context.close()")]
[CancelAfter(30_000)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

30 is the default, hence removed.

@mxschmitt mxschmitt force-pushed the chore--migrate-from-TimeoutAttribute-to-CancelAfterAttribute branch from dbbc139 to 3cf89e5 Compare March 5, 2025 11:05
/// <param name="fileName"><see cref="FileName"/></param>
/// <param name="describe"><see cref="Describe"/></param>
/// <param name="nameOfTest"><see cref="TestName"/></param>
public PlaywrightTestAttribute(string fileName, string describe, string nameOfTest) : this(fileName, nameOfTest)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method with this kind of signature we haven't used much, hence removed + modified the tests which used it.

@mxschmitt mxschmitt requested a review from Copilot March 5, 2025 11:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR migrates internal tests from using the TimeoutAttribute to the new CancelAfterAttribute, addressing test timeout handling and removing obsolete attributes. Key changes include:

  • Adding CancelAfterAttribute usage and corresponding interface implementations in PlaywrightTestAttribute.
  • Updating tests to use CancelAfter with appropriate timeout constants.
  • Removing legacy timeout and parallelization assembly attributes.

Reviewed Changes

File Description
src/Playwright.Tests/Attributes/PlaywrightTestAttribute.cs Extended attribute to implement additional contexts and to apply CancelAfter for timing out tests.
src/Playwright.Tests/PageDispatchEventTests.cs Updated PlaywrightTest attribute usage by removing redundant parameters.
src/Playwright.Tests/PageWaitForNavigationTests.cs Replaced direct timeout values with TestConstants and removed one CancelAfter attribute.
src/Playwright.Tests/ElementHandleConvenienceTests.cs Updated PlaywrightTest attribute usage by removing an extra parameter.
src/Playwright.Tests/TestConstants.cs Removed assembly-level attributes to align with the new timeout handling approach.
src/Playwright.Tests/PageEvaluateTests.cs Removed inline description from PlaywrightTest in favor of a code comment.
src/Playwright.Tests/ScreencastTests.cs Removed the CancelAfter attribute to streamline test timeout configuration.
src/Playwright.Tests/BrowserContextBasicTests.cs Updated PlaywrightTest attributes to omit redundant descriptions.
src/Playwright.Tests/PageNetworkRequestTest.cs Updated the PlaywrightTest attribute usage for clarity and consistency.

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/Playwright.Tests/PageWaitForNavigationTests.cs:317

  • The removal of the CancelAfter attribute on this test might lead to unintended behavior if a test-specific timeout is expected. Please confirm that the omission of a CancelAfter configuration is intentional to avoid potential flakiness.
public async Task ShouldTakeTimeoutIntoAccount()

@mxschmitt mxschmitt merged commit 701e728 into main Mar 6, 2025
13 of 15 checks passed
@mxschmitt mxschmitt deleted the chore--migrate-from-TimeoutAttribute-to-CancelAfterAttribute branch March 6, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[internal] Fix 'TimeoutAttribute' is obsolete inside our tests

3 participants