@@ -667,7 +667,7 @@ public void testAutoSavePublishedPost() throws InterruptedException {
667667 PostModel post = createNewPost ();
668668 post .setStatus (PostStatus .PUBLISHED .toString ());
669669
670- testAutoSavePostOrPage (post , false );
670+ testAutoSavePostOrPage (post , false , false );
671671 }
672672
673673 @ Test
@@ -677,7 +677,7 @@ public void testAutoSaveScheduledPost() throws InterruptedException {
677677 post .setStatus (PostStatus .SCHEDULED .toString ());
678678 post .setDateCreated ("2075-10-14T10:51:11+00:00" );
679679
680- testAutoSavePostOrPage (post , false );
680+ testAutoSavePostOrPage (post , false , true );
681681 }
682682
683683 @ Test
@@ -686,10 +686,10 @@ public void testAutoSavePublishedPage() throws InterruptedException {
686686 PostModel post = createNewPost ();
687687 post .setStatus (PostStatus .PUBLISHED .toString ());
688688
689- testAutoSavePostOrPage (post , true );
689+ testAutoSavePostOrPage (post , true , false );
690690 }
691691
692- private void testAutoSavePostOrPage (PostModel post , boolean isPage ) throws InterruptedException {
692+ private void testAutoSavePostOrPage (PostModel post , boolean isPage , boolean cleanUp ) throws InterruptedException {
693693 // Arrange
694694 setupPostAttributes (post );
695695
@@ -707,6 +707,13 @@ private void testAutoSavePostOrPage(PostModel post, boolean isPage) throws Inter
707707 assertNotNull (postAfterAutoSave .getAutoSaveModified ());
708708 assertNotNull (postAfterAutoSave .getAutoSavePreviewUrl ());
709709 assertNotEquals (0 , postAfterAutoSave .getAutoSaveRevisionId ());
710+
711+ // We don't want to perform the clean up unless necessary to keep the tests as quick as
712+ // possible. However, creating for example scheduled posts during a test may affect other
713+ // tests and hence they need to be trashed.
714+ if (cleanUp ) {
715+ deletePost (uploadedPost );
716+ }
710717 }
711718
712719 @ Test
0 commit comments