Single Product Page Title<\/h2>\n
This is a premium plugin for $99\/yr<\/p>\n<\/div>" +} \ No newline at end of file diff --git a/tests/cypress/integration/marketplace.cy.js b/tests/cypress/integration/marketplace.cy.js index 2792c52..e149aa5 100644 --- a/tests/cypress/integration/marketplace.cy.js +++ b/tests/cypress/integration/marketplace.cy.js @@ -33,8 +33,8 @@ describe( 'Marketplace Page', function () { cy.checkA11y( appClass + '-app-body' ); } ); - it( 'Product grid has 4 items', () => { - cy.get( '.marketplace-item' ).should( 'have.length', 4 ); + it( 'Product grid has 5 items', () => { + cy.get( '.marketplace-item' ).should( 'have.length', 5 ); } ); it( 'First product card renders correctly', () => { @@ -105,6 +105,25 @@ describe( 'Marketplace Page', function () { .and( 'include', '_blank' ); } ); + it( 'Product page Secondary CTA links properly', () => { + cy.get( '#marketplace-item-a2ff70f1-9670-4e25-a0e1-a068d3e43d55' ).as( + 'card' + ); + + cy.get( '@card' ) + .findByRole( 'link', { name: 'Learn More' } ) + .scrollIntoView() + .should( 'be.visible' ) + .and( 'have.attr', 'target', '_self' ) + .and( 'have.attr', 'href' ) + .and( + 'include', + 'page=' + + Cypress.env( 'pluginId' ) + + '#/marketplace/product/549e5e29-735f-4e09-892e-766ca9b59858' + ); + } ); + it( 'Category Tab Filters properly', () => { cy.get( appClass + '-app-subnavitem-Services' ).click(); cy.get( '.marketplace-item' ).should( 'have.length', 12 ); diff --git a/tests/cypress/integration/product-page.cy.js b/tests/cypress/integration/product-page.cy.js new file mode 100644 index 0000000..2e5008d --- /dev/null +++ b/tests/cypress/integration/product-page.cy.js @@ -0,0 +1,57 @@ +const productPageFixtures = require( '../fixtures/product-page.json' ); + +describe( 'Product Page', function () { + beforeEach( () => { + cy.intercept( + { + method: 'GET', + url: /newfold-marketplace(\/|%2F)v1(\/|%2F)products(\/|%2F)page/, + }, + { + body: productPageFixtures, + delay: 250, + } + ).as( 'productPageData' ); + + cy.visit( + '/wp-admin/admin.php?page=' + + Cypress.env( 'pluginId' ) + + '#/marketplace/product/549e5e29-735f-4e09-892e-766ca9b59858' + ); + } ); + + it( 'Show loading state while fetching', () => { + cy.get( + '.wppbh-app-marketplace-container div[aria-label="Fetching product details"]' + ).should( 'be.visible' ); + } ); + + it( 'Product page content is visible', () => { + cy.wait( '@productPageData' ); + cy.get( '.nfd-product-page-content' ).should( 'be.visible' ); + } ); + + it( 'Show error state if fetching fails', () => { + cy.reload(); + cy.intercept( + { + method: 'GET', + url: /newfold-marketplace(\/|%2F)v1(\/|%2F)products(\/|%2F)page/, + }, + { + status: 404, + body: 'Error', + delay: 250, + } + ).as( 'productPageError' ); + cy.wait( '@productPageError' ); + cy.get( '.wppbh-app-marketplace-container div[role="alert"]' ) + .find( 'img[alt="Dog walking with a leash"]' ) + .should( 'exist' ) + .and( 'be.visible' ); + cy.contains( 'Oops! Something Went Wrong' ).should( 'be.visible' ); + cy.contains( + 'An error occurred while loading the content. Please try again later.' + ).should( 'be.visible' ); + } ); +} );