@@ -223,7 +223,7 @@ public function testAddNewMemberContentDownloadsByProduct(EndToEndTester $I)
223223 $ I ,
224224 $ url ,
225225 [
226- 'member_content ' => 'The downloadable content (that is available when the visitor has paid for the Kit product) goes here. ' ,
226+ 'member_content ' => 'The downloadable member-only content goes here. ' ,
227227 ]
228228 );
229229 }
@@ -292,7 +292,7 @@ public function testAddNewMemberContentCourseByProduct(EndToEndTester $I)
292292 $ url ,
293293 [
294294 'visible_content ' => 'Some introductory text about lesson 1 ' ,
295- 'member_content ' => 'Lesson 1 content (that is available when the visitor has paid for the Kit product) goes here. ' ,
295+ 'member_content ' => 'Lesson 1 member-only content goes here. ' ,
296296 ]
297297 );
298298
@@ -301,25 +301,25 @@ public function testAddNewMemberContentCourseByProduct(EndToEndTester $I)
301301 $ I ->waitForElementVisible ('body.page-template-default ' );
302302 $ I ->see ('Kit: Member Content: Course: 2/3 ' );
303303 $ I ->see ('Some introductory text about lesson 2 ' );
304- $ I ->see ('Lesson 2 content (that is available when the visitor has paid for the Kit product) goes here ' );
304+ $ I ->see ('Lesson 2 member-only content goes here. ' );
305305
306306 $ I ->click ('Next Lesson ' );
307307 $ I ->waitForElementVisible ('body.page-template-default ' );
308308 $ I ->see ('Kit: Member Content: Course: 3/3 ' );
309309 $ I ->see ('Some introductory text about lesson 3 ' );
310- $ I ->see ('Lesson 3 content (that is available when the visitor has paid for the Kit product) goes here ' );
310+ $ I ->see ('Lesson 3 member-only content goes here. ' );
311311
312312 $ I ->click ('Previous Lesson ' );
313313 $ I ->waitForElementVisible ('body.page-template-default ' );
314314 $ I ->see ('Kit: Member Content: Course: 2/3 ' );
315315 $ I ->see ('Some introductory text about lesson 2 ' );
316- $ I ->see ('Lesson 2 content (that is available when the visitor has paid for the Kit product) goes here ' );
316+ $ I ->see ('Lesson 2 member-only content goes here. ' );
317317
318318 $ I ->click ('Previous Lesson ' );
319319 $ I ->waitForElementVisible ('body.page-template-default ' );
320320 $ I ->see ('Kit: Member Content: Course: 1/3 ' );
321321 $ I ->see ('Some introductory text about lesson 1 ' );
322- $ I ->see ('Lesson 1 content (that is available when the visitor has paid for the Kit product) goes here ' );
322+ $ I ->see ('Lesson 1 member-only content goes here. ' );
323323 }
324324
325325 /**
@@ -373,7 +373,7 @@ public function testAddNewMemberContentDownloadsByTag(EndToEndTester $I)
373373 urlOrPageID: $ url ,
374374 emailAddress: $ I ->generateEmailAddress (),
375375 options: [
376- 'member_content ' => 'The downloadable content (that is available when the visitor has paid for the Kit product) goes here. ' ,
376+ 'member_content ' => 'The downloadable member-only content goes here. ' ,
377377 ]
378378 );
379379 }
@@ -443,7 +443,7 @@ public function testAddNewMemberContentCourseByTag(EndToEndTester $I)
443443 emailAddress: $ I ->generateEmailAddress (),
444444 options: [
445445 'visible_content ' => 'Some introductory text about lesson 1 ' ,
446- 'member_content ' => 'Lesson 1 content (that is available when the visitor has paid for the Kit product) goes here. ' ,
446+ 'member_content ' => 'Lesson 1 member-only content goes here. ' ,
447447 ]
448448 );
449449
@@ -452,25 +452,176 @@ public function testAddNewMemberContentCourseByTag(EndToEndTester $I)
452452 $ I ->waitForElementVisible ('body.page-template-default ' );
453453 $ I ->see ('Kit: Member Content: Course: Tag: 2/3 ' );
454454 $ I ->see ('Some introductory text about lesson 2 ' );
455- $ I ->see ('Lesson 2 content (that is available when the visitor has paid for the Kit product) goes here ' );
455+ $ I ->see ('Lesson 2 member-only content goes here. ' );
456456
457457 $ I ->click ('Next Lesson ' );
458458 $ I ->waitForElementVisible ('body.page-template-default ' );
459459 $ I ->see ('Kit: Member Content: Course: Tag: 3/3 ' );
460460 $ I ->see ('Some introductory text about lesson 3 ' );
461- $ I ->see ('Lesson 3 content (that is available when the visitor has paid for the Kit product) goes here ' );
461+ $ I ->see ('Lesson 3 member-only content goes here. ' );
462462
463463 $ I ->click ('Previous Lesson ' );
464464 $ I ->waitForElementVisible ('body.page-template-default ' );
465465 $ I ->see ('Kit: Member Content: Course: Tag: 2/3 ' );
466466 $ I ->see ('Some introductory text about lesson 2 ' );
467- $ I ->see ('Lesson 2 content (that is available when the visitor has paid for the Kit product) goes here ' );
467+ $ I ->see ('Lesson 2 member-only content goes here. ' );
468468
469469 $ I ->click ('Previous Lesson ' );
470470 $ I ->waitForElementVisible ('body.page-template-default ' );
471471 $ I ->see ('Kit: Member Content: Course: Tag: 1/3 ' );
472472 $ I ->see ('Some introductory text about lesson 1 ' );
473- $ I ->see ('Lesson 1 content (that is available when the visitor has paid for the Kit product) goes here ' );
473+ $ I ->see ('Lesson 1 member-only content goes here. ' );
474+ }
475+
476+ /**
477+ * Test that the Add New Member Content > Downloads generates the expected Page
478+ * and restricts content by the selected Form.
479+ *
480+ * @since 2.8.3
481+ *
482+ * @param EndToEndTester $I Tester.
483+ */
484+ public function testAddNewMemberContentDownloadsByForm (EndToEndTester $ I )
485+ {
486+ // Setup Plugin and navigate to Add New Member Content screen.
487+ $ this ->_setupAndLoadAddNewMemberContentScreen ($ I );
488+
489+ // Click Downloads button.
490+ $ I ->click ('Download ' );
491+
492+ // Confirm the Configure Download screen is displayed.
493+ $ I ->see ('Configure Download ' );
494+
495+ // Enter a title and description.
496+ $ I ->fillField ('title ' , 'Kit: Member Content: Download: Form ' );
497+ $ I ->fillField ('description ' , 'Visible content. ' );
498+
499+ // Confirm that the limit option is not visible, as this is only for courses.
500+ $ I ->dontSee ('How many lessons does this course consist of? ' );
501+
502+ // Restrict by Form.
503+ $ I ->fillSelect2Field ($ I , '#select2-wp-convertkit-restrict_content-container ' , $ _ENV ['CONVERTKIT_API_FORM_NAME ' ]);
504+
505+ // Click submit button.
506+ $ I ->click ('Submit ' );
507+
508+ // Wait for the WP_List_Table of Pages to load.
509+ $ I ->waitForElementVisible ('tbody#the-list ' );
510+
511+ // Confirm that one Page is listed in the WP_List_Table.
512+ $ I ->see ('Kit: Member Content: Download: Form ' );
513+ $ I ->seeInSource ('<span class="post-state">Kit Member Content</span> ' );
514+
515+ // Hover mouse over Post's table row.
516+ $ I ->moveMouseOver ('tr.iedit ' );
517+
518+ // Get link to Page.
519+ $ url = $ I ->grabAttributeFrom ('tr.iedit span.view a ' , 'href ' );
520+
521+ // Test Restrict Content functionality.
522+ $ I ->testRestrictedContentByFormOnFrontend (
523+ $ I ,
524+ urlOrPageID: $ url ,
525+ formID: $ _ENV ['CONVERTKIT_API_FORM_ID ' ],
526+ options: [
527+ 'member_content ' => 'The downloadable member-only content goes here. ' ,
528+ ]
529+ );
530+ }
531+
532+ /**
533+ * Test that the Add New Member Content > Course generates the expected Pages
534+ * and restricts content by the selected Form.
535+ *
536+ * @since 2.8.3
537+ *
538+ * @param EndToEndTester $I Tester.
539+ */
540+ public function testAddNewMemberContentCourseByForm (EndToEndTester $ I )
541+ {
542+ // Setup Plugin and navigate to Add New Member Content screen.
543+ $ this ->_setupAndLoadAddNewMemberContentScreen ($ I );
544+
545+ // Click Course button.
546+ $ I ->click ('Course ' );
547+
548+ // Confirm the Configure Course screen is displayed.
549+ $ I ->see ('Configure Course ' );
550+
551+ // Enter a title, description and lesson count.
552+ $ I ->fillField ('title ' , 'Kit: Member Content: Course: Form ' );
553+ $ I ->fillField ('description ' , 'Visible content. ' );
554+ $ I ->fillField ('number_of_pages ' , '3 ' );
555+
556+ // Restrict by Product.
557+ $ I ->fillSelect2Field ($ I , '#select2-wp-convertkit-restrict_content-container ' , $ _ENV ['CONVERTKIT_API_FORM_NAME ' ]);
558+
559+ // Click submit button.
560+ $ I ->click ('Submit ' );
561+
562+ // Wait for the WP_List_Table of Pages to load.
563+ $ I ->waitForElementVisible ('tbody#the-list ' );
564+
565+ // Confirm that four Pages are listed in the WP_List_Table.
566+ $ I ->see ('Kit: Member Content: Course: Form ' );
567+ $ I ->see ('— Kit: Member Content: Course: Form: 1/3 ' );
568+ $ I ->see ('— Kit: Member Content: Course: Form: 2/3 ' );
569+ $ I ->see ('— Kit: Member Content: Course: Form: 3/3 ' );
570+ $ I ->see ('Kit Member Content | Parent Page: Kit: Member Content: Course: Form ' );
571+
572+ // Hover mouse over Post's table row.
573+ $ I ->moveMouseOver ('tr.iedit:first-child ' );
574+
575+ // Wait for View link to be visible.
576+ $ I ->waitForElementVisible ('tr.iedit:first-child span.view a ' );
577+
578+ // Click View link.
579+ $ I ->click ('tr.iedit:first-child span.view a ' );
580+
581+ // Wait for frontend web site to load.
582+ $ I ->waitForElementVisible ('body.page-template-default ' );
583+
584+ // Confirm the Start Course button exists.
585+ $ I ->see ('Start Course ' );
586+
587+ // Get URL to first restricted content page.
588+ $ url = $ I ->grabAttributeFrom ('.wp-block-button a ' , 'href ' );
589+
590+ // Test Restrict Content functionality.
591+ $ I ->testRestrictedContentByFormOnFrontend (
592+ $ I ,
593+ urlOrPageID: $ url ,
594+ formID: $ _ENV ['CONVERTKIT_API_FORM_ID ' ],
595+ options: [
596+ 'visible_content ' => 'Some introductory text about lesson 1 ' ,
597+ 'member_content ' => 'Lesson 1 member-only content goes here. ' ,
598+ ]
599+ );
600+
601+ // Test Next / Previous links.
602+ $ I ->click ('Next Lesson ' );
603+ $ I ->waitForElementVisible ('body.page-template-default ' );
604+ $ I ->see ('Kit: Member Content: Course: Form: 2/3 ' );
605+ $ I ->see ('Some introductory text about lesson 2 ' );
606+ $ I ->see ('Lesson 2 member-only content goes here. ' );
607+
608+ $ I ->click ('Next Lesson ' );
609+ $ I ->waitForElementVisible ('body.page-template-default ' );
610+ $ I ->see ('Kit: Member Content: Course: Form: 3/3 ' );
611+ $ I ->see ('Some introductory text about lesson 3 ' );
612+ $ I ->see ('Lesson 3 member-only content goes here. ' );
613+
614+ $ I ->click ('Previous Lesson ' );
615+ $ I ->waitForElementVisible ('body.page-template-default ' );
616+ $ I ->see ('Kit: Member Content: Course: Form: 2/3 ' );
617+ $ I ->see ('Some introductory text about lesson 2 ' );
618+ $ I ->see ('Lesson 2 member-only content goes here. ' );
619+
620+ $ I ->click ('Previous Lesson ' );
621+ $ I ->waitForElementVisible ('body.page-template-default ' );
622+ $ I ->see ('Kit: Member Content: Course: Form: 1/3 ' );
623+ $ I ->see ('Some introductory text about lesson 1 ' );
624+ $ I ->see ('Lesson 1 member-only content goes here. ' );
474625 }
475626
476627 /**
0 commit comments