Skip to content

Commit b6091aa

Browse files
committed
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: #15782 Props shailu25. See #52895. git-svn-id: https://develop.svn.wordpress.org/trunk@65331 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 02671ac commit b6091aa

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

‎tests/e2e/specs/themes.test.js‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* External dependencies
3+
*/
4+
import { randomUUID } from 'node:crypto';
5+
16
/**
27
* WordPress dependencies
38
*/
@@ -146,4 +151,59 @@ test.describe( 'Theme management', () => {
146151
themes.find( ( theme ) => theme.status === 'active' ).stylesheet
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
} );

0 commit comments

Comments
 (0)