File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed
wp_api_integration_tests/tests Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ use wp_api:: {
2
+ posts:: { PostCreateParams , PostId } ,
3
+ request:: endpoint:: posts_endpoint:: PostEndpointType ,
4
+ } ;
5
+ use wp_api_integration_tests:: prelude:: * ;
6
+
7
+ #[ tokio:: test]
8
+ async fn create_autosave ( ) {
9
+ let title = "Test Autosave Navigation Title" . to_string ( ) ;
10
+ let content =
11
+ "<!-- wp:navigation -->Test autosave navigation content<!-- /wp:navigation -->" . to_string ( ) ;
12
+ let params = PostCreateParams {
13
+ title : Some ( title. clone ( ) ) ,
14
+ content : Some ( content. clone ( ) ) ,
15
+ ..Default :: default ( )
16
+ } ;
17
+
18
+ let autosave = api_client ( )
19
+ . autosaves ( )
20
+ . create (
21
+ & PostEndpointType :: Navigation ,
22
+ & autosaved_navigation_id ( ) ,
23
+ & params,
24
+ )
25
+ . await
26
+ . assert_response ( )
27
+ . data ;
28
+
29
+ // Verify the autosave was created successfully
30
+ assert_eq ! ( autosave. title. raw, Some ( title) ) ;
31
+ assert_eq ! ( autosave. content. raw, Some ( content) ) ;
32
+ }
33
+
34
+ fn autosaved_navigation_id ( ) -> PostId {
35
+ PostId ( TestCredentials :: instance ( ) . autosaved_navigation_id )
36
+ }
Original file line number Diff line number Diff line change
1
+ use wp_api:: {
2
+ post_revisions:: PostRevisionId , posts:: PostId ,
3
+ request:: endpoint:: posts_endpoint:: PostEndpointType ,
4
+ } ;
5
+ use wp_api_integration_tests:: prelude:: * ;
6
+
7
+ #[ tokio:: test]
8
+ #[ serial]
9
+ async fn delete_navigation_revision ( ) {
10
+ let revision_id = revision_id_for_navigation_id ( ) ;
11
+ let revision_delete_response = api_client ( )
12
+ . post_revisions ( )
13
+ . delete (
14
+ & PostEndpointType :: Navigation ,
15
+ & navigation_id ( ) ,
16
+ & revision_id,
17
+ )
18
+ . await ;
19
+
20
+ assert ! (
21
+ revision_delete_response. is_ok( ) ,
22
+ "{revision_delete_response:#?}"
23
+ ) ;
24
+
25
+ let delete_response = revision_delete_response. unwrap ( ) . data ;
26
+ assert ! ( delete_response. deleted) ;
27
+ assert_eq ! ( delete_response. previous. id, revision_id) ;
28
+
29
+ RestoreServer :: db ( ) . await ;
30
+ }
31
+
32
+ fn navigation_id ( ) -> PostId {
33
+ PostId ( TestCredentials :: instance ( ) . navigation_id )
34
+ }
35
+
36
+ fn revision_id_for_navigation_id ( ) -> PostRevisionId {
37
+ PostRevisionId ( TestCredentials :: instance ( ) . revision_id_for_navigation_id )
38
+ }
You can’t perform that action at this time.
0 commit comments