Skip to content

ToolsPanel: improve unit tests #35057

@ciampo

Description

@ciampo

What

Improve unit tests by partially rewriting them. They should not be checking implementation details (like classnames, the presence of certain react components...), but instead, they should test the ToolsPanel component replicating the way end-users interact with it.

Why

Here's a great explainer

A/C

  • There should be no usages of querySelector, querySelectorAll or any similar way of getting an element from the DOM.
  • Similarly, we should not test the exact DOM structure (e.g. getting parent elements, or checking for the existence of a specific React component). We should instead, for example, find components by role, or accessible text
  • Add coverage for behaviour related to unique panelIds to cover the user behaviour of switching between similar blocks that share common ToolsPanels. A concrete example is to cover the bug fix in ToolsPanelItem: Add panelId check before calling toggle methods #35375

Metadata

Metadata

Labels

[Feature] Component SystemWordPress component system[Feature] UI ComponentsImpacts or related to the UI component system[Status] In ProgressTracking issues with work in progress[Type] Automated TestingTesting infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.[Type] Code QualityIssues or PRs that relate to code quality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions