Problem/Motivation

FunctionalJavaScript tests are the slowest and least reliable in core.

Analysis of all existing tests has shown that 18 or so test methods may not require a real browser and could be converted to use BrowserTestBase instead.

Candidates:

- \Drupal\Tests\system\FunctionalJavascript\Form\DevelopmentSettingsFormTest::testDisabledRenderedOutputCacheBins()
- \Drupal\Tests\system\FunctionalJavascript\Form\TriggeringElementTest::testNoButtonInfoInPost()
- \Drupal\Tests\system\FunctionalJavascript\Form\TriggeringElementTest::testAttemptAccessControlBypass()
- \Drupal\Tests\system\FunctionalJavascript\Form\ValidationTest::testValidateLimitErrors()
- \Drupal\Tests\system\FunctionalJavascript\Form\ValidationTest::testCustomRequiredError()
- \Drupal\Tests\media_library\FunctionalJavascript\ContentModerationTest::testAdministrationPage()
- \Drupal\Tests\media_library\FunctionalJavascript\WidgetAccessTest::testRequiredFieldNoAccess()
- \Drupal\Tests\media_library\FunctionalJavascript\WidgetWithoutTypesTest::testWidgetWithoutMediaTypes()
- \Drupal\Tests\toolbar\FunctionalJavascript\announcements_feed\AccessAnnouncementTest::testAnnounceFirstLogin()
- \Drupal\Tests\toolbar\FunctionalJavascript\announcements_feed\AccessAnnouncementTest::testAnnounceWithoutPermission()
- \Drupal\Tests\toolbar\FunctionalJavascript\workspaces\WorkspaceTest::testSpecialCharacters()
- \Drupal\Tests\toolbar\FunctionalJavascript\workspaces\WorkspaceTest::testWorkspaceToolbar()
- \Drupal\Tests\toolbar\FunctionalJavascript\workspaces\WorkspaceTest::testToolbarSwitcherDynamicPageCache()
- \Drupal\Tests\announcements_feed\FunctionalJavascript\AnnounceBlockTest::testAnnounceWithoutPermission()
- \Drupal\Tests\big_pipe\FunctionalJavascript\BigPipeMessagesTest::testMessages()
- \Drupal\FunctionalJavascriptTests\Core\Session\SessionTest::testSessionExpiration()
- \Drupal\FunctionalJavascriptTests\Core\Field\TimestampFormatterWithTimeDiffTest::testNoRefreshInterval()
- \Drupal\FunctionalJavascriptTests\Theme\ClaroTableDragTest::testNoDuplicates()

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3618901

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

longwave’s picture

Issue summary: View changes
kieran.cott’s picture

Assigned: Unassigned » kieran.cott

Sounds like a good idea, I'll take a look. :)

kieran.cott’s picture

Assigned: kieran.cott » Unassigned

Ah, forgot about the Drupal Core assignee policy - unassigning.
https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-...

kieran.cott’s picture

I've taken a look at these tests and I think most of them (15) can be moved over without much in the way of changes. 3 of those 15 (from the WorkspaceTest class) are already based on BrowserTestBase, so can simply be moved from the FunctionalJavascript directory/namespace as-is.

The remaining 3 probably need more discussion as to what we want to do with them:

1. BigPipeMessagesTest::testMessages():

Verifies the final DOM after BigPipe’s JavaScript processes streamed placeholder commands, inserts the placeholder output and consolidates messages. I think a Functional client would only receive BigPipe script/command payloads; it would not necessarily create the asserted p.logged-message and message elements. Inspecting the raw payload would be materially different coverage.

2. TimestampFormatterWithTimeDiffTest::testNoRefreshInterval()

Even with refresh set to zero, JavaScript still runs once to replace the server-rendered fallback date with text such as “2 seconds ago”. The method asserts that transformed text, as well as the refresh: 0 setting. A Functional test could verify the data-drupal-time-diff JSON, but not the relative-time text; that would be reduced coverage. The method is also currently skipped before setup.

3. ClaroTableDragTest::testNoDuplicates()

.tabledrag-handle elements are created by core/misc/tabledrag.js. Without JavaScript the Functional DOM contains zero handles, so it cannot verify that behaviour attachment creates exactly one rather than duplicates.

I'll open an MR converting the other 15 tests to use BrowserTestBase as suggested but would be good to get some input from the community as to what to do with the above three highlighted exceptions.

longwave’s picture

Thanks for the analysis. I think we can just skip those here if it turns out they are non trivial, converting 15 methods is still a win.

kieran.cott’s picture

Status: Active » Needs review
Issue tags: +Needs issue summary update

Great, thanks - I've implemented this as MR 16838.

The 15 converted methods now live in Functional tests across:

core/modules/system/tests/src/Functional/Form/TriggeringElementTest.php:35
core/modules/system/tests/src/Functional/Form/ValidationTest.php:93
core/modules/media_library/tests/src/Functional/ContentModerationTest.php:184
core/modules/toolbar/tests/src/Functional/workspaces/WorkspaceTest.php:76
core/modules/announcements_feed/tests/src/Functional/AnnounceBlockTest.php:55
core/tests/Drupal/FunctionalTests/Core/Session/SessionTest.php:55

I've left the three test methods mentioned in comment #5 unchanged.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.