Make WordPress Core

Changeset 65322


Ignore:
Timestamp:
11/06/2026 09:33:59 PM (less than one hour ago)
Author:
lancewillett
Message:

Tests: Cover Media Library search.

Search the list view for an uploaded image and check that its row is shown. Search for a missing title and check for the empty result, with another upload present so the test fails if search is ignored.

Follow-up to [64737].

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/15722

Props shailu25.
See #52895.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/e2e/specs/media-library.test.js

    r65275 r65322  
    160160                await expect( audioTile ).toBeHidden();
    161161        } );
     162
     163        test( 'searches for an existing image', async ( {
     164                admin,
     165                page,
     166                requestUtils,
     167        } ) => {
     168                const id = await upload( requestUtils, 'search' );
     169                const title = `${ prefix }-search`;
     170
     171                await admin.visitAdminPage(
     172                        '/upload.php',
     173                        `mode=list&s=${ encodeURIComponent( title ) }`
     174                );
     175                const row = page.locator( `#post-${ id }` );
     176                await expect( row ).toBeVisible();
     177                await expect(
     178                        row.getByRole( 'link', { name: title, exact: true } )
     179                ).toBeVisible();
     180        } );
     181
     182        test( 'shows an empty result when searching for missing media', async ( {
     183                admin,
     184                page,
     185                requestUtils,
     186        } ) => {
     187                // Ensure the library is not empty so ignoring search cannot vacuously pass.
     188                await upload( requestUtils, 'present' );
     189                const missing = `${ prefix }-missing-${ randomUUID() }`;
     190
     191                await admin.visitAdminPage(
     192                        '/upload.php',
     193                        `mode=list&s=${ encodeURIComponent( missing ) }`
     194                );
     195                await expect(
     196                        page.getByRole( 'cell', {
     197                                name: 'No media files found.',
     198                                exact: true,
     199                        } )
     200                ).toBeVisible();
     201        } );
    162202} );
Note: See TracChangeset for help on using the changeset viewer.