Here is an expired notice it should never display anywhere even though it has location `all` Dismiss this notice. <\/p><\/div>"
65 | }
66 | ]
--------------------------------------------------------------------------------
/tests/cypress/fixtures/webinars-inactive.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "title": "Maximize Productivity with Time Management",
5 | "description" : "Phasellus sagittis gravida molestie. Vivamus dictum, massa luctus tempus imperdiet, ligula leo ultrices purus, sit amet consectetur ligula turpis non nisi.",
6 | "date": "November 15, 2022",
7 | "time": "2pm - 3pm EST",
8 | "ctaText": "Sign Up Today",
9 | "link": "https://www.bluehost.com/blog/events/how-to-start-with-seo-yoast/"
10 | },
11 | {
12 | "title": "Build your brand with WordPress",
13 | "description": "Join us for a free webinar on how to build your brand with WordPress.",
14 | "topics": [
15 | "Explore SEO and WordPress",
16 | "Gain valuable tips for building your brand",
17 | "Content marketing",
18 | "eCommerce integration"
19 | ],
20 | "date": "August 31, 2040",
21 | "time": "1pm - 2pm EST",
22 | "ctaText": "Register Now",
23 | "link": "https://www.bluehost.com/blog/events/next-event-post"
24 | },
25 | {
26 | "title": "Mastering the Art of Public Speaking",
27 | "topics": [
28 | "Overcoming stage fright and nervousness",
29 | "Crafting compelling speeches and presentations",
30 | "Engaging your audience effectively",
31 | "Tips for confident and impactful public speaking"
32 | ],
33 | "date": "December 10, 2050",
34 | "time": "3pm - 4pm EST",
35 | "ctaText": "Enroll Now",
36 | "link": "https://www.bluehost.com/blog/events/yoast-seo-news-october-edition/"
37 | }
38 | ],
39 | "isActive": false
40 | }
--------------------------------------------------------------------------------
/tests/cypress/fixtures/webinars-past.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "title": "Maximize Productivity with Time Management",
5 | "description" : "Phasellus sagittis gravida molestie. Vivamus dictum, massa luctus tempus imperdiet, ligula leo ultrices purus, sit amet consectetur ligula turpis non nisi.",
6 | "date": "November 15, 2022",
7 | "time": "2pm - 3pm EST",
8 | "ctaText": "Sign Up Today",
9 | "link": "https://www.bluehost.com/blog/events/how-to-start-with-seo-yoast/"
10 | },
11 | {
12 | "title": "Build your brand with WordPress",
13 | "description": "Join us for a free webinar on how to build your brand with WordPress.",
14 | "topics": [
15 | "Explore SEO and WordPress",
16 | "Gain valuable tips for building your brand",
17 | "Content marketing",
18 | "eCommerce integration"
19 | ],
20 | "date": "August 31, 2022",
21 | "time": "1pm - 2pm EST",
22 | "ctaText": "Register Now",
23 | "link": "https://www.bluehost.com/blog/events/next-event-post"
24 | },
25 | {
26 | "title": "Mastering the Art of Public Speaking",
27 | "topics": [
28 | "Overcoming stage fright and nervousness",
29 | "Crafting compelling speeches and presentations",
30 | "Engaging your audience effectively",
31 | "Tips for confident and impactful public speaking"
32 | ],
33 | "date": "December 10, 2022",
34 | "time": "3pm - 4pm EST",
35 | "ctaText": "Enroll Now",
36 | "link": "https://www.bluehost.com/blog/events/yoast-seo-news-october-edition/"
37 | }
38 | ],
39 | "isActive": true
40 | }
--------------------------------------------------------------------------------
/tests/cypress/fixtures/webinars.json:
--------------------------------------------------------------------------------
1 | {
2 | "items": [
3 | {
4 | "title": "Maximize Productivity with Time Management",
5 | "description" : "Phasellus sagittis gravida molestie. Vivamus dictum, massa luctus tempus imperdiet, ligula leo ultrices purus, sit amet consectetur ligula turpis non nisi.",
6 | "date": "November 15, 2022",
7 | "time": "2pm - 3pm EST",
8 | "ctaText": "Sign Up Today",
9 | "link": "https://www.bluehost.com/blog/events/how-to-start-with-seo-yoast/"
10 | },
11 | {
12 | "title": "Build your brand with WordPress",
13 | "description": "Join us for a free webinar on how to build your brand with WordPress.",
14 | "topics": [
15 | "Explore SEO and WordPress",
16 | "Gain valuable tips for building your brand",
17 | "Content marketing",
18 | "eCommerce integration"
19 | ],
20 | "date": "August 31, 2040",
21 | "time": "1pm - 2pm EST",
22 | "ctaText": "Register Now",
23 | "link": "https://www.bluehost.com/blog/events/next-event-post"
24 | },
25 | {
26 | "title": "Mastering the Art of Public Speaking",
27 | "topics": [
28 | "Overcoming stage fright and nervousness",
29 | "Crafting compelling speeches and presentations",
30 | "Engaging your audience effectively",
31 | "Tips for confident and impactful public speaking"
32 | ],
33 | "date": "December 10, 2050",
34 | "time": "3pm - 4pm EST",
35 | "ctaText": "Enroll Now",
36 | "link": "https://www.bluehost.com/blog/events/yoast-seo-news-october-edition/"
37 | }
38 | ],
39 | "isActive": true
40 | }
--------------------------------------------------------------------------------
/tests/cypress/integration/help.cy.js:
--------------------------------------------------------------------------------
1 | //
2 | const pluginNotificationsFixture = require( '../fixtures/plugin-notifications.json' );
3 | const pluginProductsFixture = require( '../fixtures/plugin-products.json' );
4 |
5 | describe( 'Help Page', { testIsolation: true }, function () {
6 | beforeEach( () => {
7 | cy.wpLogin();
8 | cy.intercept(
9 | {
10 | method: 'GET',
11 | url: /newfold-marketplace(\/|%2F)v1(\/|%2F)marketplace/,
12 | },
13 | pluginProductsFixture
14 | ).as( 'pluginProductsFixture' );
15 | cy.intercept(
16 | {
17 | method: 'GET',
18 | url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/,
19 | },
20 | pluginNotificationsFixture
21 | ).as( 'pluginNotificationsFixture' );
22 | cy.visit(
23 | '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/help',
24 | { timeout: 30000 }
25 | );
26 | } );
27 |
28 | it( 'Is Accessible', () => {
29 | cy.injectAxe();
30 | cy.wait( 500 );
31 | cy.checkA11y( '.wppbh-app-body' );
32 | } );
33 |
34 | it( 'Cards Each Exist', () => {
35 | cy.get( '.card-help-phone' )
36 | .contains( 'h3', 'Phone' )
37 | .scrollIntoView()
38 | .should( 'be.visible' );
39 |
40 | cy.get( '.card-help-chat' )
41 | .contains( 'h3', 'Chat' )
42 | .scrollIntoView()
43 | .should( 'be.visible' );
44 |
45 | cy.get( '.card-help-twitter' )
46 | .contains( 'h3', 'Tweet' )
47 | .scrollIntoView()
48 | .should( 'be.visible' );
49 |
50 | cy.get( '.card-help-youtube' )
51 | .contains( 'h3', 'YouTube' )
52 | .scrollIntoView()
53 | .should( 'be.visible' );
54 |
55 | cy.get( '.card-help-kb' )
56 | .contains( 'h3', 'Knowledge Base' )
57 | .scrollIntoView()
58 | .should( 'be.visible' );
59 |
60 | cy.get( '.card-help-resources' )
61 | .contains( 'h3', 'Resources' )
62 | .scrollIntoView()
63 | .should( 'be.visible' );
64 |
65 | cy.get( '.card-help-events' )
66 | .contains( 'h3', 'Events and Webinars' )
67 | .scrollIntoView()
68 | .should( 'be.visible' );
69 |
70 | cy.get( '.card-help-website' )
71 | .contains( 'h3', 'Bluehost Website' )
72 | .scrollIntoView()
73 | .should( 'be.visible' );
74 | } );
75 | } );
76 |
--------------------------------------------------------------------------------
/tests/cypress/integration/home.cy.js:
--------------------------------------------------------------------------------
1 | //
2 | const webinarsFixture = require( '../fixtures/webinars.json' );
3 | const webinarsPastFixture = require( '../fixtures/webinars-past.json' );
4 | const webinarsInactiveFixture = require( '../fixtures/webinars-inactive.json' );
5 |
6 | describe( 'Home Page', { testIsolation: true }, function () {
7 | let NewfoldRuntime;
8 |
9 | beforeEach( () => {
10 | cy.wpLogin();
11 | cy.visit(
12 | '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home'
13 | );
14 | cy.window()
15 | .its( 'NewfoldRuntime' )
16 | .then( ( data ) => {
17 | NewfoldRuntime = data;
18 | } );
19 | } );
20 |
21 | it( 'Site Info Exists', () => {
22 | cy.get( '.wppbh-app-site-info' )
23 | .contains( 'h3', NewfoldRuntime.siteTitle )
24 | .scrollIntoView()
25 | .should( 'be.visible' );
26 | } );
27 |
28 | it( 'Is Accessible', () => {
29 | cy.injectAxe();
30 | cy.wait( 500 );
31 | cy.checkA11y( '.wppbh-app-body' );
32 | } );
33 |
34 | it( 'Welcome Section Exists', () => {
35 | cy.get( '.nfd-app-section-container' )
36 | .contains( 'h2', 'Home' )
37 | .scrollIntoView()
38 | .should( 'be.visible' );
39 | } );
40 |
41 | it.skip( 'Additional Features Section Exists', () => {
42 | cy.get( '.nfd-app-section-container' )
43 | .contains( 'h2', 'Additional Features' )
44 | .scrollIntoView()
45 | .should( 'be.visible' );
46 | } );
47 |
48 | it( 'Account Section Exists', () => {
49 | cy.get( '.wppbh-account-help-section' )
50 | .contains( 'h1', 'Bluehost Account' )
51 | .scrollIntoView()
52 | .should( 'be.visible' );
53 | } );
54 |
55 | it( 'Help Section Exists', () => {
56 | cy.get( '.wppbh-account-help-section' )
57 | .contains( 'h1', 'Need some help?' )
58 | .scrollIntoView()
59 | .should( 'be.visible' );
60 | } );
61 |
62 | it( 'Webinars Section Exists and Renders Properly', () => {
63 | cy.intercept(
64 | {
65 | method: 'GET',
66 | url: 'https://cdn.hiive.space/resources/bluehost-webinars.json',
67 | },
68 | webinarsFixture
69 | ).as( 'webinarsFixture' );
70 | cy.reload();
71 | cy.wait( '@webinarsFixture' );
72 | cy.get( '.wppbh-webinars-banner-section' )
73 | .contains( 'h2', 'Build your brand with WordPress' )
74 | .scrollIntoView()
75 | .should( 'be.visible' );
76 |
77 | // Title
78 | cy.get( '.wppbh-webinars-banner-section' )
79 | .contains( 'h2', 'Build your brand with WordPress' )
80 | .scrollIntoView()
81 | .should( 'be.visible' );
82 |
83 | // Description
84 | cy.get( '.wppbh-webinars-banner-section p:first-of-type' )
85 | .contains(
86 | 'Join us for a free webinar on how to build your brand with WordPress.'
87 | )
88 | .scrollIntoView()
89 | .should( 'be.visible' );
90 |
91 | // Topics
92 | cy.get( '.wppbh-webinars-banner-section h3' )
93 | .contains( 'Topics:' )
94 | .scrollIntoView()
95 | .should( 'be.visible' );
96 |
97 | // Date
98 | cy.get( '.wppbh-webinars-banner-section' )
99 | .contains( 'August 31, 2040' )
100 | .scrollIntoView()
101 | .should( 'be.visible' );
102 |
103 | // Time
104 | cy.get( '.wppbh-webinars-banner-section' )
105 | .contains( '1pm - 2pm EST' )
106 | .scrollIntoView()
107 | .should( 'be.visible' );
108 |
109 | // CTA
110 | cy.get( '.wppbh-webinars-banner-section a:first-of-type' )
111 | .contains( 'Register Now' )
112 | .scrollIntoView()
113 | .should( 'be.visible' )
114 | .should( 'have.attr', 'href' )
115 | .and(
116 | 'include',
117 | 'https://www.bluehost.com/blog/events/next-event-post'
118 | );
119 | } );
120 |
121 | it( "Webinars Section Doesn't Render When Active Propety is False", () => {
122 | cy.intercept(
123 | {
124 | method: 'GET',
125 | url: 'https://cdn.hiive.space/resources/bluehost-webinars.json',
126 | },
127 | webinarsInactiveFixture
128 | ).as( 'webinarsInactiveFixture' );
129 | cy.reload();
130 | cy.wait( '@webinarsInactiveFixture' );
131 | cy.get( '.wppbh-webinars-banner-section' ).should( 'not.exist' );
132 | } );
133 |
134 | it( "Webinars Section Doesn't Render Items Are in the Past", () => {
135 | cy.intercept(
136 | {
137 | method: 'GET',
138 | url: 'https://cdn.hiive.space/resources/bluehost-webinars.json',
139 | },
140 | webinarsPastFixture
141 | ).as( 'webinarsPastFixture' );
142 | cy.reload();
143 | cy.wait( '@webinarsPastFixture' );
144 | cy.get( '.wppbh-webinars-banner-section' ).should( 'not.exist' );
145 | } );
146 | } );
147 |
--------------------------------------------------------------------------------
/tests/cypress/integration/navigation.cy.js:
--------------------------------------------------------------------------------
1 | //
2 |
3 | describe( 'Navigation', { testIsolation: true }, function () {
4 | beforeEach( () => {
5 | cy.wpLogin();
6 | cy.visit( '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) );
7 | } );
8 |
9 | it( "Admin submenu shouldn't exist inside app", () => {
10 | cy.get( '#adminmenu #toplevel_page_bluehost ul.wp-submenu' ).should(
11 | 'not.exist'
12 | );
13 | } );
14 |
15 | it( 'Logo Links to home', () => {
16 | cy.get( '.wppbh-logo-wrap' ).click();
17 | cy.wait( 500 );
18 | cy.hash().should( 'eq', '#/home' );
19 | } );
20 |
21 | // test main nav
22 | it( 'Main nav links properly navigates', () => {
23 | cy.get( '.wppbh-app-navitem-Marketplace' ).should(
24 | 'not.have.class',
25 | 'active'
26 | );
27 | cy.get( '.wppbh-app-navitem-Marketplace' ).click();
28 | cy.wait( 500 );
29 | cy.hash().should( 'eq', '#/marketplace' );
30 | cy.get( '.wppbh-app-navitem-Marketplace' ).should(
31 | 'have.class',
32 | 'active'
33 | );
34 |
35 | cy.get( '.wppbh-app-navitem-Performance' ).click();
36 | cy.wait( 500 );
37 | cy.hash().should( 'eq', '#/performance' );
38 | cy.get( '.wppbh-app-navitem-Performance' ).should(
39 | 'have.class',
40 | 'active'
41 | );
42 | cy.get( '.wppbh-app-navitem-Marketplace' ).should(
43 | 'not.have.class',
44 | 'active'
45 | );
46 |
47 | cy.get( '.wppbh-app-navitem-Settings' ).click();
48 | cy.wait( 500 );
49 | cy.hash().should( 'eq', '#/settings' );
50 | } );
51 |
52 | it( 'Subnav links properly navigates', () => {
53 | cy.get( '.wppbh-app-navitem-Marketplace' )
54 | .scrollIntoView()
55 | .should( 'not.have.class', 'active' );
56 | cy.get( '.wppbh-app-navitem-Marketplace' ).click();
57 |
58 | cy.wait( 500 );
59 | cy.hash().should( 'eq', '#/marketplace' );
60 | cy.get( '.wppbh-app-navitem-Marketplace' ).should(
61 | 'have.class',
62 | 'active'
63 | );
64 |
65 | cy.get( '.wppbh-app-subnavitem-Services' ).click();
66 | cy.wait( 500 );
67 | cy.hash().should( 'eq', '#/marketplace/services' );
68 | cy.get( '.wppbh-app-subnavitem-Services' ).should(
69 | 'have.class',
70 | 'active'
71 | );
72 | cy.get( '.wppbh-app-navitem-Marketplace' ).should(
73 | 'have.class',
74 | 'active'
75 | );
76 |
77 | cy.get( '.wppbh-app-subnavitem-SEO' ).click();
78 | cy.wait( 500 );
79 | cy.hash().should( 'eq', '#/marketplace/seo' );
80 | cy.get( '.wppbh-app-subnavitem-SEO' ).should( 'have.class', 'active' );
81 | cy.get( '.wppbh-app-subnavitem-Services' ).should(
82 | 'not.have.class',
83 | 'active'
84 | );
85 | cy.get( '.wppbh-app-navitem-Marketplace' ).should(
86 | 'have.class',
87 | 'active'
88 | );
89 |
90 | cy.get( '.wppbh-app-navitem-Performance' ).click();
91 | cy.wait( 500 );
92 | cy.get( '.wppbh-app-subnavitem-Services' ).should(
93 | 'not.have.class',
94 | 'active'
95 | );
96 | cy.get( '.wppbh-app-subnavitem-SEO' ).should(
97 | 'not.have.class',
98 | 'active'
99 | );
100 | cy.get( '.wppbh-app-navitem-Marketplace' ).should(
101 | 'not.have.class',
102 | 'active'
103 | );
104 | } );
105 |
106 | it( 'Admin submenu exist outside the app', () => {
107 | cy.visit( '/wp-admin/index.php' );
108 | cy.get( '#adminmenu #toplevel_page_bluehost ul.wp-submenu' ).should(
109 | 'exist'
110 | );
111 | cy.get(
112 | '#adminmenu #toplevel_page_bluehost ul.wp-submenu li a[href="admin.php?page=bluehost#/home"]'
113 | ).should( 'exist' );
114 | cy.get(
115 | '#adminmenu #toplevel_page_bluehost ul.wp-submenu li a[href="admin.php?page=bluehost#/marketplace"]'
116 | ).should( 'exist' );
117 | cy.get(
118 | '#adminmenu #toplevel_page_bluehost ul.wp-submenu li a[href="admin.php?page=bluehost#/settings"]'
119 | ).should( 'exist' );
120 | } );
121 |
122 | it( 'Mobile nav links dispaly and link properly on mobile', () => {
123 | cy.get( '#nfd-app-mobile-nav' ).should( 'not.exist' );
124 |
125 | cy.viewport( 'iphone-x' );
126 | cy.get( '#nfd-app-mobile-nav' ).should( 'be.visible' );
127 |
128 | cy.get( '.wppbh-app-navitem-Home' ).should( 'not.exist' );
129 |
130 | cy.get( '#nfd-app-mobile-nav' ).click();
131 | cy.wait( 500 );
132 | cy.get( '.wppbh-app-navitem-Home' ).should( 'be.visible' );
133 | cy.get( 'button.nfd-modal__close-button' ).should( 'be.visible' );
134 | cy.get( 'button.nfd-modal__close-button' ).click();
135 | cy.get( '.wppbh-app-navitem-Home' ).should( 'not.exist' );
136 | } );
137 | } );
138 |
--------------------------------------------------------------------------------
/tests/cypress/integration/pages-and-posts.cy.js:
--------------------------------------------------------------------------------
1 | describe( 'Pages & Posts', { testIsolation: true }, function () {
2 | let NewfoldRuntime;
3 |
4 | beforeEach( () => {
5 | cy.wpLogin();
6 | cy.visit(
7 | '/wp-admin/admin.php?page=' +
8 | Cypress.env( 'pluginId' ) +
9 | '#/pages-and-posts'
10 | );
11 | cy.window()
12 | .its( 'NewfoldRuntime' )
13 | .then( ( data ) => {
14 | NewfoldRuntime = data;
15 | } );
16 | cy.injectAxe();
17 | } );
18 |
19 | it( 'Pages & Posts Exists', () => {
20 | cy.get( '.wppbh-app-pagesAndPosts-page' )
21 | .contains( 'Pages & Posts' )
22 | .scrollIntoView()
23 | .should( 'be.visible' );
24 | } );
25 |
26 | it( 'site pages Exists', () => {
27 | cy.get( '.wppbh-app-site-page' )
28 | .findByText( 'Site Pages' )
29 | .should( 'exist' );
30 | cy.get( '.wppbh-app-site-page' )
31 | .find( 'a[href="edit.php?post_type=page"]' )
32 | .click();
33 | cy.url().should( 'include', 'edit.php?post_type=page' );
34 | cy.go( 'back' );
35 |
36 | cy.get( '.wppbh-app-site-page' )
37 | .find(
38 | 'a[href="post-new.php?post_type=page&wb-library=patterns&wb-category=features"] Button'
39 | )
40 | .click();
41 | cy.url().should(
42 | 'include',
43 | 'post-new.php?post_type=page&wb-library=patterns&wb-category=features'
44 | );
45 | cy.go( 'back' );
46 | } );
47 |
48 | it( 'Blog posts Exists', () => {
49 | cy.get( '.wppbh-app-blog-posts' )
50 | .findByText( 'Blog Posts' )
51 | .should( 'exist' );
52 | cy.get( '.wppbh-app-blog-posts' ).find( 'a[href="edit.php"]' ).click();
53 | cy.url().should( 'include', 'edit.php' );
54 | cy.go( 'back' );
55 |
56 | cy.get( '.wppbh-app-blog-posts' )
57 | .get(
58 | 'a[href="post-new.php?wb-library=patterns&wb-category=text"] Button'
59 | )
60 | .click();
61 | cy.url().should(
62 | 'include',
63 | 'post-new.php?wb-library=patterns&wb-category=text'
64 | );
65 | cy.go( 'back' );
66 | } );
67 |
68 | it( 'Bookings & Appointments Exists', () => {
69 | if (
70 | NewfoldRuntime.capabilities.hasYithExtended &&
71 | NewfoldRuntime.isWoocommerceActive
72 | ) {
73 | cy.get( '.wppbh-app-bookings' )
74 | .findByText( 'Bookings & Appointments' )
75 | .should( 'exist' );
76 | cy.get( '.wppbh-app-bookings' )
77 | .find(
78 | 'a[href="edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1"]'
79 | )
80 | .first()
81 | .click();
82 | cy.url().should(
83 | 'include',
84 | 'edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1'
85 | );
86 | cy.go( 'back' );
87 |
88 | cy.get( '.wppbh-app-bookings' )
89 | .find(
90 | 'a[href="edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1"] Button'
91 | )
92 | .last()
93 | .click();
94 | cy.url().should(
95 | 'include',
96 | 'edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1'
97 | );
98 | cy.go( 'back' );
99 | } else {
100 | cy.get( '.wppbh-app-transform' )
101 | .findByText( 'Transform your store!' )
102 | .should( 'exist' );
103 | cy.get( '.wppbh-app-transform' )
104 | .find(
105 | 'a[href="admin.php?page=bluehost#/marketplace/product/6049dddb-1303-4c41-b3c0-242881697860"]'
106 | )
107 | .first()
108 | .click();
109 | cy.url().should(
110 | 'include',
111 | 'admin.php?page=bluehost#/marketplace/product/6049dddb-1303-4c41-b3c0-242881697860'
112 | );
113 | cy.go( 'back' );
114 | }
115 | } );
116 |
117 | it( 'Products Exists', () => {
118 | if ( NewfoldRuntime.isWoocommerceActive ) {
119 | cy.get( '.wppbh-app-products' )
120 | .findByText( 'Products' )
121 | .should( 'exist' );
122 | cy.get( '.wppbh-app-products' )
123 | .find( 'a[href="edit.php?post_type=product"]' )
124 | .click();
125 | cy.url().should( 'include', 'edit.php?post_type=product' );
126 | cy.go( 'back' );
127 |
128 | cy.get( '.wppbh-app-products' )
129 | .find( 'a[href="post-new.php?post_type=product"] Button' )
130 | .click();
131 | cy.url().should( 'include', 'post-new.php?post_type=product' );
132 | cy.go( 'back' );
133 | } else {
134 | cy.findByText( 'Products' ).should( 'not.exist' );
135 | }
136 | } );
137 | } );
138 |
--------------------------------------------------------------------------------
/tests/cypress/integration/version-check.cy.js:
--------------------------------------------------------------------------------
1 | //
2 |
3 | describe( 'Page', { testIsolation: true }, () => {
4 | beforeEach( () => {
5 | cy.wpLogin();
6 | cy.visit( '/wp-admin/site-health.php?tab=debug' );
7 | } );
8 |
9 | it( 'Is running the correct WP version', () => {
10 | cy.get( '#health-check-accordion-block-wp-core' ).prev().click();
11 | cy.get( '#health-check-accordion-block-wp-core' )
12 | .find( 'tr' )
13 | .first()
14 | .find( 'td' )
15 | .last()
16 | .contains( new RegExp( `^${ Cypress.env( 'wpVersion' ) }` ) );
17 | } );
18 |
19 | it( 'Is running the correct PHP versions', () => {
20 | cy.get( '#health-check-accordion-block-wp-server' ).prev().click();
21 | cy.get( '#health-check-accordion-block-wp-server' )
22 | .find( 'tr' )
23 | .eq( 2 )
24 | .find( 'td' )
25 | .last()
26 | .contains( Cypress.env( 'phpVersion' ) );
27 | } );
28 | } );
29 |
--------------------------------------------------------------------------------
/tests/cypress/plugins/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = (on, config) => {
4 |
5 | if (config.env && config.env.baseUrl) {
6 | config.baseUrl = config.env.baseUrl;
7 | }
8 |
9 | return config;
10 | };
11 |
--------------------------------------------------------------------------------
/tests/cypress/support/commands.js:
--------------------------------------------------------------------------------
1 | //
2 |
3 | // ***********************************************
4 | // This example commands.js shows you how to
5 | // create various custom commands and overwrite
6 | // existing commands.
7 | //
8 | // For more comprehensive examples of custom
9 | // commands please read more here:
10 | // https://on.cypress.io/custom-commands
11 | // ***********************************************
12 | //
13 | //
14 | // -- This is a parent command --
15 | // Cypress.Commands.add("login", (email, password) => { ... })
16 | //
17 | //
18 | // -- This is a child command --
19 | // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
20 | //
21 | //
22 | // -- This is a dual command --
23 | // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
24 | //
25 | //
26 | // -- This is will overwrite an existing command --
27 | // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
28 |
29 | import '@testing-library/cypress/add-commands';
30 |
31 | Cypress.Commands.add( 'login', ( username, password ) => {
32 | cy.getCookies().then( ( cookies ) => {
33 | let hasMatch = false;
34 | cookies.forEach( ( cookie ) => {
35 | if ( cookie.name.substr( 0, 20 ) === 'wordpress_logged_in_' ) {
36 | hasMatch = true;
37 | }
38 | } );
39 | if ( ! hasMatch ) {
40 | cy.visit( '/wp-login.php' ).wait( 1000 );
41 | cy.get( '#user_login' ).type( username );
42 | cy.get( '#user_pass' ).type( `${ password }{enter}` );
43 |
44 | // Speed up tests by setting permalink structure once
45 | // cy.setPermalinkStructure();
46 | }
47 | } );
48 | } );
49 |
50 | Cypress.Commands.add( 'wpLogin', () => {
51 | cy.login( Cypress.env( 'wpUsername' ), Cypress.env( 'wpPassword' ) );
52 | } );
53 |
54 | Cypress.Commands.add( 'logout', () => {
55 | cy.getCookies().then( ( cookies ) => {
56 | cookies.forEach( ( cookie ) => {
57 | cy.clearCookie( cookie.name );
58 | } );
59 | } );
60 | } );
61 |
62 | Cypress.Commands.add(
63 | 'setPermalinkStructure',
64 | ( structure = '/%postname%/' ) => {
65 | cy.request( {
66 | method: 'GET',
67 | url: '/wp-json/',
68 | failOnStatusCode: false,
69 | } ).then( ( result ) => {
70 | if ( result.isOkStatusCode ) {
71 | return;
72 | }
73 | const permalinkWpCliCommand = `wp rewrite structure "${ structure }" --hard;`;
74 | const permalinkWpEnvCommand = `npx wp-env run cli ${ permalinkWpCliCommand }`;
75 | const permalinkWpEnvTestCommand = `npx wp-env run tests-cli ${ permalinkWpCliCommand }`;
76 | cy.exec( permalinkWpEnvCommand, { failOnNonZeroExit: true } ).then(
77 | ( result ) => {
78 | cy.request( '/wp-json/' );
79 | }
80 | );
81 | cy.exec( permalinkWpEnvTestCommand, {
82 | failOnNonZeroExit: true,
83 | } ).then( ( result ) => {
84 | cy.request( '/wp-json/' );
85 | } );
86 | } );
87 | }
88 | );
89 |
90 | Cypress.Commands.add( 'deletePages', () => {
91 | cy.visit( '/wp-admin/edit.php?post_type=page' ).wait( 1000 );
92 | cy.get( 'body' ).then( ( $body ) => {
93 | // synchronously ask for the body's text
94 | // and do something based on whether it includes
95 | // another string
96 | if ( $body.text().includes( 'No pages found.' ) ) {
97 | // nothing needed
98 | } else {
99 | cy.get( '#cb-select-all-1' ).check();
100 | cy.get( '#bulk-action-selector-top' ).select( 'trash' );
101 | cy.get( '#doaction' ).click();
102 | cy.wait( 2000 );
103 | cy.get( '.subsubsub .trash' ).click();
104 | cy.wait( 2000 );
105 | cy.get( '#delete_all' ).click();
106 | }
107 | } );
108 | } );
109 |
--------------------------------------------------------------------------------
/tests/cypress/support/index.js:
--------------------------------------------------------------------------------
1 | // ***********************************************************
2 | // This example support/index.js is processed and
3 | // loaded automatically before your test files.
4 | //
5 | // This is a great place to put global configuration and
6 | // behavior that modifies Cypress.
7 | //
8 | // You can change the location of this file or turn off
9 | // automatically serving support files with the
10 | // 'supportFile' configuration option.
11 | //
12 | // You can read more here:
13 | // https://on.cypress.io/configuration
14 | // ***********************************************************
15 |
16 | import 'cypress-axe';
17 | import './commands';
18 |
19 | const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/;
20 | Cypress.on( 'uncaught:exception', ( err ) => {
21 | /* returning false here prevents Cypress from failing the test */
22 | if ( resizeObserverLoopErrRe.test( err.message ) ) {
23 | return false;
24 | }
25 | } );
26 |
27 | // This needs to remain until all tests have been updated with testIsolation:
28 | // at that point this can be updated to a beforeEach and testIsolation can be
29 | // removed from the config as the default is true.
30 | before( () => {
31 | cy.wpLogin();
32 | } );
33 |
--------------------------------------------------------------------------------
/tests/phpunit/ExampleTest.php:
--------------------------------------------------------------------------------
1 | assertEquals( true, true );
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/tests/phpunit/bootstrap.php:
--------------------------------------------------------------------------------
1 |