Skip to content

Commit

Permalink
cypress tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
manikantakailasa committed Apr 17, 2024
1 parent f3c4c09 commit dc178e0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/app/pages/pagesAndPosts/ProductsPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button, Card, Title } from '@newfold/ui-component-library';
const ProductsPages = () => {
return (
<Card
className="hover:nfd-bg-[#FEFCEA]"
className="hover:nfd-bg-[#FEFCEA] wppbh-app-products"
style={ {
borderRadius: 0,
} }
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/pagesAndPosts/blogPosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button, Card, Title } from '@newfold/ui-component-library';
const BlogPosts = () => {
return (
<Card
className="hover:nfd-bg-[#F9F5FE]"
className="hover:nfd-bg-[#F9F5FE] wppbh-app-blog-posts"
style={ {
borderRadius: 0,
} }
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/pagesAndPosts/bookingAndAppointments.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button, Card, Title } from '@newfold/ui-component-library';
const BookingAndAppointments = () => {
return (
<Card
className="hover:nfd-bg-[#F2F9FE]"
className="hover:nfd-bg-[#F2F9FE] wppbh-app-bookings"
style={ {
borderRadius: 0,
} }
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/pagesAndPosts/sitePages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button, Card, Title } from '@newfold/ui-component-library';
const SitePages = () => {
return (
<Card
className="hover:nfd-bg-[#F2FDFA]"
className="hover:nfd-bg-[#F2FDFA] wppbh-app-site-page"
style={ {
borderRadius: 0,
} }
Expand Down
94 changes: 55 additions & 39 deletions tests/cypress/integration/pagesAndPosts.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,85 +17,101 @@ describe( 'Pages & Posts', function () {

it( 'Pages & Posts Exists', () => {
cy.get( '.wppbh-app-pagesAndPosts-page' )
.contains( __( 'Pages & Posts', 'wp-plugin-bluehost' ) )
.contains( 'Pages & Posts' )
.scrollIntoView()
.should( 'be.visible' );
} );

it( 'site pages Exists', () => {
cy.findByText( __( 'Site Pages', 'wp-plugin-bluehost' ) ).should(
'exist'
);
cy.get( 'Card a[href="edit.php?post_type=page"]' ).click();
cy.get( '.wppbh-app-site-page' )
.findByText( 'Site Pages' )
.should( 'exist' );
cy.get( '.wppbh-app-site-page' )
.find( 'a[href="edit.php?post_type=page"]' )
.click();
cy.url().should( 'include', 'edit.php?post_type=page' );
cy.go( 'back' );

// Click on "Add New" button and verify action
cy.get(
'.sitePages a[href="post-new.php?post_type=page"] Button'
).click();
cy.get( '.wppbh-app-site-page' )
.find( 'a[href="post-new.php?post_type=page"] Button' )
.click();
cy.url().should( 'include', 'post-new.php?post_type=page' );
cy.go( 'back' );
} );

it( 'Blog posts Exists', () => {
cy.findByText( __( 'Blog Posts', 'wp-plugin-bluehost' ) ).should(
'exist'
);
cy.get( 'Card a[href="edit.php"]' ).click();
cy.get( '.wppbh-app-blog-posts' )
.findByText( 'Blog Posts' )
.should( 'exist' );
cy.get( '.wppbh-app-blog-posts' ).find( 'a[href="edit.php"]' ).click();
cy.url().should( 'include', 'edit.php' );
cy.go( 'back' );

// Click on "Add New" button and verify action
cy.get( 'Card a[href="post-new.php"] Button' ).click();
cy.get( '.wppbh-app-blog-posts' )
.get( 'a[href="post-new.php"] Button' )
.click();
cy.url().should( 'include', 'post-new.php' );
cy.go( 'back' );
} );

it( 'Bookings & Appointments Exists', () => {
if (
NewfoldRuntime.isYithBookingActive &&
NewfoldRuntime.isWoocommerceActive
) {
cy.findByText(
__( 'Bookings & Appointments', 'wp-plugin-bluehost' )
).should( 'exist' );
cy.get(
'Card a[href="edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1"]'
).click();
cy.get( '.wppbh-app-bookings' )
.findByText( 'Bookings & Appointments' )
.should( 'exist' );
cy.get( '.wppbh-app-bookings' )
.find(
'a[href="edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1"]'
)
.first()
.click();
cy.url().should(
'include',
'edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1'
);
cy.go( 'back' );

// Click on "Add New" button and verify action
cy.get(
'Card a[href="edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1"] Button'
).click();
cy.get( '.wppbh-app-bookings' )
.find(
'a[href="edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1"] Button'
)
.last()
.click();
cy.url().should(
'include',
'edit.php?post_type=yith_booking&yith-plugin-fw-panel-skip-redirect=1'
);
cy.go( 'back' );
} else {
cy.findByText(
__( 'Bookings & Appointments', 'wp-plugin-bluehost' )
).should( 'not.exist' );
cy.get( '.wppbh-app-bookings' )
.findByText( 'Bookings & Appointments' )
.should( 'not.exist' );
}
} );

it( 'Products Exists', () => {
if ( NewfoldRuntime.isWoocommerceActive ) {
cy.findByText( __( 'Products', 'wp-plugin-bluehost' ) ).should(
'exist'
);
cy.get( 'Card a[href="edit.php?post_type=product"]' ).click();
cy.get( '.wppbh-app-products' )
.findByText( 'Products' )
.should( 'exist' );
cy.get( '.wppbh-app-products' )
.find( 'a[href="edit.php?post_type=product"]' )
.click();
cy.url().should( 'include', 'edit.php?post_type=product' );
cy.go( 'back' );

// Click on "Add New" button and verify action
cy.get(
'Card a[href="post-new.php?post_type=product"] Button'
).click();
cy.get( '.wppbh-app-products' )
.find( 'a[href="post-new.php?post_type=product"] Button' )
.click();
cy.url().should( 'include', 'post-new.php?post_type=product' );
cy.go( 'back' );
} else {
cy.findByText( __( 'Products', 'wp-plugin-bluehost' ) ).should(
'not.exist'
);
cy.get( '.wppbh-app-products' )
.findByText( 'Products' )
.should( 'not.exist' );
}
} );
} );

0 comments on commit dc178e0

Please sign in to comment.