POC: add data-test-id attributes to blocks, settings, and dynamic UI#1886
Open
subodhr258 wants to merge 8 commits into
Open
POC: add data-test-id attributes to blocks, settings, and dynamic UI#1886subodhr258 wants to merge 8 commits into
subodhr258 wants to merge 8 commits into
Conversation
Toolbar buttons, both InspectorControls panel headers, the
representative settings controls (hoverSelect, aspectRatio,
playerHeight, showOverlay, verticalAlignment, overlayTimeRange),
the main figure canvas wrapper, the dynamic overlay container,
and the query-loop label span.
Part of a POC establishing the godam-{area}-{role}-{name} naming
convention.
Co-Authored-By: Claude <noreply@anthropic.com>
Five common controls (autoplay, loop, muted, controls, performance) shared between the player block edit panel and any consumer of edit-common-settings.js. Co-Authored-By: Claude <noreply@anthropic.com>
Three InspectorControls panels (source / settings / query), six representative controls covering ToggleGroupControl / ToggleControl / RangeControl variants, three canvas wrappers (outer + handpicked + query), and two dynamic elements (query-item with ratio-driven class and the thumbnail fallback span). Co-Authored-By: Claude <noreply@anthropic.com>
Marks the dynamic duration-format preview span (content varies with the durationFormat attribute: 00:00:00, 00:00, 0s, etc.). Co-Authored-By: Claude <noreply@anthropic.com>
Two dynamic elements: the video title <strong> and the video date <span>, both populated from resolved media attributes and shown conditionally on the showTitle context value. Co-Authored-By: Claude <noreply@anthropic.com>
Marks the tab nav container, each individual tab nav link (templated from tab.id, producing godam-settings-nav-<tab>), and the active-tab content root. Co-Authored-By: Claude <noreply@anthropic.com>
Marks the tab's root container, the global Save button, two ToggleControls and a TextControl in the watermark sub-section, plus the two API-key action buttons. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds data-test-id attributes across selected editor blocks and the GoDAM settings UI to establish a consistent selector naming convention for upcoming selector-based testing.
Changes:
- Added
data-test-idmarkers to key Block Editor surfaces (toolbar buttons, inspector panels/controls, and canvas elements) forgodam/video,godam/gallery-v2,godam/video-duration, andgodam/gallery-v2-item. - Added
data-test-idmarkers to the GoDAM settings navigation/content shell and the Video Settings tab (including watermark and API key actions).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pages/godam/components/tabs/VideoSettings/VideoWatermark.jsx | Adds test ids to watermark toggles and watermark text control. |
| pages/godam/components/tabs/VideoSettings/VideoSettings.jsx | Adds test ids to Video Settings root and Save button. |
| pages/godam/components/tabs/VideoSettings/APISettings.jsx | Adds test ids to Save/Remove API key buttons. |
| pages/godam/App.js | Adds test ids to settings tab nav, per-tab links, and content container. |
| assets/src/blocks/godam-video-duration/edit.js | Adds test id to the duration preview element. |
| assets/src/blocks/godam-player/edit.js | Adds test ids to toolbar buttons, inspector panels/controls, and canvas/overlay containers. |
| assets/src/blocks/godam-player/edit-common-settings.js | Adds test ids to common video settings controls (autoplay/loop/muted/etc.). |
| assets/src/blocks/godam-gallery-v2/edit.js | Adds test ids to inspector panels/controls and canvas/query preview elements. |
| assets/src/blocks/godam-gallery-v2-item/edit.js | Adds test ids to dynamic title/date elements. |
Comments suppressed due to low confidence (1)
assets/src/blocks/godam-gallery-v2/edit.js:910
data-test-id="godam-gallery-v2-element-thumbnail-fallback"can appear multiple times (once per query item without a thumbnail). If tests rely on a single match, this will be flaky/ambiguous; consider making the id item-specific (e.g., includevideo.id) or attaching a single test id to the thumbnail container and asserting fallback presence within a specific item via scoped queries.
<div className="godam-gallery-v2__query-thumb">
{ video.thumbnail ? (
<img src={ video.thumbnail } alt={ video.title } />
) : (
<span data-test-id="godam-gallery-v2-element-thumbnail-fallback">{ __( 'Video', 'godam' ) }</span>
) }
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🔍 WordPress Plugin Check Report
📊 Report
❌ Errors (3)📁 readme.txt (1 error)
📁 lib/class-godam-frappe-dispatch-installer.php (2 errors)
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM". |
0 |
trademarked_term | The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name. |
📁 composer.json (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
missing_composer_json_file | The "/vendor" directory using composer exists, but "composer.json" file is missing. |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/05/25/hello-world/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/05/25/hello-world/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/sample-page/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POC adding 33 unique
data-test-idattributes across 9 files to give us a worked example of a naming convention for selector-based testing. Strictly additive — no logic, markup structure, or styling changes. Visual review should focus on the convention and coverage, not behaviour.This pairs with #1885 (unit testing infrastructure) but is independent of it: this PR can land first or second, and lints/runs clean on its own.
Naming convention
Format:
godam-{area}-{role}-{name}areagodam-prefix (e.g.,video,gallery-v2,video-duration,gallery-v2-item), orsettings-{tab}for settings (e.g.,settings-video). Top-level chrome (the tab nav) uses justsettings.roletoolbar/panel/control/canvas/element/nav/content/buttonnameautoplay,hover-select). For panels, the slugified title (overlay-blocks). For elements/buttons, a semantic role (save,query-label,thumbnail-fallback).Uniqueness check: every static ID appears exactly once across
assets/src/andpages/(verified locally:grep -rohE 'data-test-id=\"[^\"]+\"' assets/src pages \| sort \| uniq -cshows count of 1 for all values).What's covered
Blocks (2 representative)
godam/video(assets/src/blocks/godam-player/) — richest block in the editor. Comprehensive tagging of toolbar, panels, controls, canvas wrappers, and one dynamic overlay container:-toolbar-edit,-toolbar-seo)-panel-settings,-panel-overlay-blocks)edit-common-settings.js(autoplay, loop, muted, controls, performance, hover-select, aspect-ratio, player-height, show-overlay, vertical-alignment, overlay-time-range)-canvasfigure,-canvas-overlaydiv)-element-query-label)godam/gallery-v2(assets/src/blocks/godam-gallery-v2/) — richest variety of control types:-panel-source,-panel-settings,-panel-query)-element-query-itemwith ratio-driven class,-element-thumbnail-fallbackspan)Blocks with dynamic UI
godam/video-duration— the duration-format preview span whose content varies with thedurationFormatattributegodam/gallery-v2-item— the title<strong>and date<span>populated from resolved media attributesSettings tabs
pages/godam/App.js— tab nav container + templatedgodam-settings-nav-${tab.id}on each tab link (expands to 5 IDs at render time: general-settings, video-settings, video-player, video-ads, integrations-settings) + content rootpages/godam/components/tabs/VideoSettings/VideoSettings.jsx— tab root + Save buttonpages/godam/components/tabs/VideoSettings/VideoWatermark.jsx— 2 ToggleControls + TextControlpages/godam/components/tabs/VideoSettings/APISettings.jsx— Save API Key + Remove API Key buttonsWhat's not covered (and why)
This is a POC, not exhaustive coverage. Deliberately out of scope:
assets/src/blocks/assets/src/block-extensions/save.js/view.js/ PHP templates)video-settingsis fully tagged in this POCIf the convention is approved, follow-up PRs extend coverage one block / tab / area at a time using the same
godam-{area}-{role}-{name}template.Why
data-test-id(with hyphens)The maintainer specified
data-test-id. React Testing Library's default isdata-testid(no hyphen). To make tests find these viascreen.getByTestId(...), the JS test setup (introduced in #1885) should call:I left this out of this PR because it belongs in
tests/js/setup.jswhich lives in #1885. Either:configure()call, orconfigure()call to Add unit testing infrastructure (PHPUnit + Jest) excluded from build artifact #1885 before it merges (one-line addition).Component-prop forwarding sanity
@wordpress/components 30.7.0forwards unknown props (includingdata-*) onToggleControl,SelectControl,RangeControl,UnitControl,RadioControl,TextControl,ToggleGroupControl,ToolbarButton,Button,PanelBody. All controls in this PR passdata-test-iddirectly — no wrapper divs needed. Verify in dev tools: each tagged control should render with the attribute on its root wrapper element.Test plan
grepcount of 1 each)+/-pairs on lines that received a new prop)data-testid(hyphen-less) introduced anywhere--no-verifyin commit historygodam-settings-*IDsReviewer focus
godam-{area}-{role}-{name}template the right shape, or do you prefer something else? (Easy to bulk-rename.)roletokens reasonable, or should we collapse / expand the vocabulary?🤖 Generated with Claude Code — see CLAUDE attribution on each commit.