Skip to content

Commit 51f61d2

Browse files
committed
Avoid deleting all existing attachments.
1 parent d93ca35 commit 51f61d2

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎tests/e2e/specs/accessibility.spec.js‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function filterIgnoresAndFalsePositives( results, exclusions ) {
3838
violation.nodes = violation.nodes.filter( ( node ) => {
3939
const targetSelector = node.target[ 0 ];
4040

41-
/*
41+
/*
4242
* Normalize the received Axe-core Target Selector: remove combinators,
4343
* attributes, and collapse spaces. This allows us to match patterns
4444
* against the normalized selector using token-based matching. For example:
@@ -112,14 +112,20 @@ test.describe( 'Admin Pages Accessibility', () => {
112112
test.beforeAll( async ( { requestUtils } ) => {
113113
// Upload sample image to media library for testing.
114114
const imagePath = path.resolve( __dirname, '../assets/sample.png' )
115-
await requestUtils.uploadMedia(
115+
const response = await requestUtils.uploadMedia(
116116
imagePath
117117
);
118+
119+
// Store the sample image ID for later cleanup.
120+
mediaAttachmentId = response.id;
118121
} );
119122

120123
test.afterAll( async ( { requestUtils } ) => {
121-
// Delete all media.
122-
await requestUtils.deleteAllMedia();
124+
// Delete the uploaded sample image.
125+
if ( mediaAttachmentId ) {
126+
await requestUtils.deleteMedia( mediaAttachmentId );
127+
}
128+
123129
// Delete all posts of type 'post' and all associated comments.
124130
await requestUtils.deleteAllPosts();
125131
} );

0 commit comments

Comments
 (0)