Make WordPress Core

Changeset 65331


Ignore:
Timestamp:
11/07/2026 05:41:05 PM (23 hours ago)
Author:
lancewillett
Message:

Tests: Cover searching installed themes.

Search the Themes screen for the uploaded test theme and check that it is the only result. Search for a missing theme and check for the empty state. The test theme stays installed, so both tests fail if search is ignored.

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

Props shailu25.
See #52895.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/e2e/specs/themes.test.js

    r65275 r65331  
     1/**
     2 * External dependencies
     3 */
     4import { randomUUID } from 'node:crypto';
     5
    16/**
    27 * WordPress dependencies
    … …  
    147152                ).toBe( previousTheme );
    148153        } );
     154
     155        test( 'searches for an installed theme', async ( { admin, page } ) => {
     156                await admin.visitAdminPage( 'themes.php' );
     157                const search = page.getByRole( 'searchbox', {
     158                        name: 'Search installed themes',
     159                        exact: true,
     160                } );
     161                await expect( search ).toBeVisible();
     162                const themeDetailsButtons = page.getByRole( 'button', {
     163                        name: /View Theme Details for /,
     164                } );
     165                // Confirm search starts from a broader results set before filtering.
     166                await expect
     167                        .poll( async () => themeDetailsButtons.count() )
     168                        .toBeGreaterThan( 1 );
     169                await search.fill( themeName );
     170
     171                // Wait for the debounced filter, then require a single matching result.
     172                await expect( themeDetailsButtons ).toHaveCount( 1 );
     173                await expect(
     174                        page.getByRole( 'button', {
     175                                name: `View Theme Details for ${ themeName }`,
     176                                exact: true,
     177                        } )
     178                ).toBeVisible();
     179        } );
     180
     181        test( 'shows an empty result when searching for a missing theme', async ( {
     182                admin,
     183                page,
     184        } ) => {
     185                // Fixture theme from beforeEach keeps the library non-empty so ignoring
     186                // search cannot vacuously pass.
     187                const missing = `e2e-missing-theme-${ randomUUID().slice( 0, 8 ) }`;
     188                await admin.visitAdminPage( 'themes.php' );
     189                const search = page.getByRole( 'searchbox', {
     190                        name: 'Search installed themes',
     191                        exact: true,
     192                } );
     193                await expect( search ).toBeVisible();
     194                await search.fill( missing );
     195
     196                // Scope to the empty-state paragraph; the same copy is also spoken via
     197                // wp.a11y.speak() into a live region.
     198                const emptyState = page.locator( 'p.no-themes' );
     199                await expect( emptyState ).toBeVisible();
     200                await expect( emptyState ).toHaveText(
     201                        'No themes found. Try a different search.'
     202                );
     203                await expect(
     204                        page.getByRole( 'button', {
     205                                name: /View Theme Details for /,
     206                        } )
     207                ).toHaveCount( 0 );
     208        } );
    149209} );
Note: See TracChangeset for help on using the changeset viewer.