Skip to content

Commit 7b4073c

Browse files
committed
Commit message:
Tests: Cover editing attachment details. Edit an attachment's title, alternative text and description on its edit screen and save. Check the values on the reloaded screen and through the REST API. Developed in: #15689 Props shailu25. See #52895. git-svn-id: https://develop.svn.wordpress.org/trunk@65327 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a640b11 commit 7b4073c

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎tests/e2e/specs/media-library.test.js‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,43 @@ test.describe( 'Media library', () => {
199199
} )
200200
).toBeVisible();
201201
} );
202+
203+
test( 'edits attachment title, alternative text, and description', async ( {
204+
admin,
205+
page,
206+
requestUtils,
207+
} ) => {
208+
const id = await upload( requestUtils, 'details' );
209+
const title = `${ prefix }-updated-title`;
210+
const altText = `${ prefix }-alt`;
211+
const description = `${ prefix }-description`;
212+
213+
await admin.visitAdminPage( '/post.php', `post=${ id }&action=edit` );
214+
215+
await page.getByLabel( 'Add title' ).fill( title );
216+
await page.getByLabel( 'Alternative Text' ).fill( altText );
217+
await page.getByLabel( 'Description' ).fill( description );
218+
await page
219+
.getByRole( 'button', { name: 'Update', exact: true } )
220+
.click();
221+
222+
await expect( page.locator( '#message' ) ).toContainText(
223+
'Media file updated.'
224+
);
225+
await expect( page.getByLabel( 'Add title' ) ).toHaveValue( title );
226+
await expect( page.getByLabel( 'Alternative Text' ) ).toHaveValue(
227+
altText
228+
);
229+
await expect( page.getByLabel( 'Description' ) ).toHaveValue(
230+
description
231+
);
232+
233+
const updated = await requestUtils.rest( {
234+
path: `/wp/v2/media/${ id }`,
235+
params: { context: 'edit' },
236+
} );
237+
expect( updated.title.raw ).toBe( title );
238+
expect( updated.alt_text ).toBe( altText );
239+
expect( updated.description.raw ).toBe( description );
240+
} );
202241
} );

0 commit comments

Comments
 (0)