Skip to content

Commit e59c585

Browse files
bfintalcursoragent
andcommitted
Fix Media Library modal test: click the .check checkbox, scope Select button locator
This grid's Attachment view only toggles selection via its .check checkbox button — clicking elsewhere on the item doesn't register. Separately, the loose /Select|Insert/i search wasn't scoped to the toolbar, so it ambiguously matched the attachment's own checkbox once its accessible name toggled to "Deselect". Scoping to .media-toolbar fixes that. Also restores the full e2e test run in CI. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6f6d5f6 commit e59c585

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

‎.github/workflows/e2e-tests.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
EOF
4444
4545
- name: Run Playwright e2e tests
46-
run: npm run test -- -g "Media Library drop"
46+
run: npm run test
4747

4848
- name: Upload Playwright report
4949
if: always()

‎e2e/tests/upload-interception.spec.ts‎

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,23 @@ test.describe( 'Upload interception (JPG → WebP)', () => {
101101
await expect( webpAttachment ).toBeVisible( { timeout: 15_000 } )
102102
await expect( webpAttachment.locator( '.attachment-preview' ) ).toBeVisible( { timeout: 15_000 } )
103103

104-
// eslint-disable-next-line no-console
105-
console.log( 'DEBUG attachment html:', await webpAttachment.innerHTML() )
106-
107-
const checkTarget = webpAttachment.locator( '.check' )
108-
if ( await checkTarget.count() ) {
109-
await checkTarget.click()
104+
// This library's Attachment view only toggles selection via its
105+
// `.check` checkbox button — clicking elsewhere on the grid item
106+
// doesn't register. Fall back to a plain click if `.check` isn't
107+
// rendered (e.g. a different WP media view).
108+
const checkButton = webpAttachment.locator( '.check' )
109+
if ( await checkButton.count() ) {
110+
await checkButton.click()
110111
} else {
111112
await webpAttachment.click()
112113
}
113114

114-
const selectButton = modal.getByRole( 'button', {
115+
// Scope to the toolbar: the attachment's own `.check` button's
116+
// accessible name toggles to "Deselect", which also matches a
117+
// loose /Select|Insert/i search if not scoped away from it.
118+
const selectButton = modal.locator( '.media-toolbar' ).getByRole( 'button', {
115119
name: /Select|Insert/i,
116120
} )
117-
const disabledAfterClick = await selectButton.isDisabled()
118-
// eslint-disable-next-line no-console
119-
console.log( 'DEBUG after check-click, btnDisabled=', disabledAfterClick )
120-
121-
if ( disabledAfterClick ) {
122-
await webpAttachment.focus()
123-
await page.keyboard.press( 'Enter' )
124-
// eslint-disable-next-line no-console
125-
console.log( 'DEBUG after Enter keypress, btnDisabled=', await selectButton.isDisabled() )
126-
}
127-
128121
await expect( selectButton ).toBeEnabled( { timeout: 10_000 } )
129122
await selectButton.click()
130123
}

0 commit comments

Comments
 (0)