@@ -198,7 +198,7 @@ public function test_page_export_link_attachments()
198
198
199
199
public function test_book_export ()
200
200
{
201
- $ book = $ this ->entities ->book ();
201
+ $ book = $ this ->entities ->bookHasChaptersAndPages ();
202
202
$ book ->tags ()->saveMany (Tag::factory ()->count (2 )->make ());
203
203
204
204
$ zipResp = $ this ->asEditor ()->get ($ book ->getUrl ("/export/zip " ));
@@ -251,6 +251,35 @@ public function test_chapter_export()
251
251
$ this ->assertCount ($ chapter ->pages ()->count (), $ chapterData ['pages ' ]);
252
252
}
253
253
254
+ public function test_draft_pages_are_not_included ()
255
+ {
256
+ $ editor = $ this ->users ->editor ();
257
+ $ entities = $ this ->entities ->createChainBelongingToUser ($ editor );
258
+ $ book = $ entities ['book ' ];
259
+ $ page = $ entities ['page ' ];
260
+ $ chapter = $ entities ['chapter ' ];
261
+ $ book ->tags ()->saveMany (Tag::factory ()->count (2 )->make ());
262
+
263
+ $ page ->created_by = $ editor ->id ;
264
+ $ page ->draft = true ;
265
+ $ page ->save ();
266
+
267
+ $ zipResp = $ this ->actingAs ($ editor )->get ($ book ->getUrl ("/export/zip " ));
268
+ $ zip = $ this ->extractZipResponse ($ zipResp );
269
+ $ this ->assertCount (0 , $ zip ->data ['book ' ]['chapters ' ][0 ]['pages ' ] ?? ['cat ' ]);
270
+
271
+ $ zipResp = $ this ->actingAs ($ editor )->get ($ chapter ->getUrl ("/export/zip " ));
272
+ $ zip = $ this ->extractZipResponse ($ zipResp );
273
+ $ this ->assertCount (0 , $ zip ->data ['chapter ' ]['pages ' ] ?? ['cat ' ]);
274
+
275
+ $ page ->chapter_id = 0 ;
276
+ $ page ->save ();
277
+
278
+ $ zipResp = $ this ->actingAs ($ editor )->get ($ book ->getUrl ("/export/zip " ));
279
+ $ zip = $ this ->extractZipResponse ($ zipResp );
280
+ $ this ->assertCount (0 , $ zip ->data ['book ' ]['pages ' ] ?? ['cat ' ]);
281
+ }
282
+
254
283
255
284
public function test_cross_reference_links_are_converted ()
256
285
{
0 commit comments