Skip to content

Commit

Permalink
Bump my products module to 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wpalani committed Aug 22, 2024
1 parent c852370 commit f56b029
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 80 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"newfold-labs/wp-module-loader": "^1.0.10",
"newfold-labs/wp-module-marketplace": "^2.4.0",
"newfold-labs/wp-module-migration": "^1.0.11",
"newfold-labs/wp-module-my-products": "^1.0.1",
"newfold-labs/wp-module-notifications": "^1.5.0",
"newfold-labs/wp-module-onboarding": "^2.3.11",
"newfold-labs/wp-module-patterns": "^2.3.1",
Expand All @@ -94,7 +95,6 @@
"newfold-labs/wp-module-secure-passwords": "^1.1.1",
"newfold-labs/wp-module-sso": "^1.0.6",
"newfold-labs/wp-module-staging": "^2.1.0",
"newfold-labs/wp-module-my-products": "^0.2.0",
"wp-forge/wp-update-handler": "^1.0.2",
"wp-forge/wp-upgrade-handler": "^1.0"
}
Expand Down
63 changes: 61 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/app/pages/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import WebinarsBanner from 'App/components/webinars-banner';
import AccountCard from './accountCard';
import HelpCard from './helpCard';
import WelcomeSection from './welcomeSection';
import ProductSection from './productSection';
import MyProductSection from './myProductsSection';

const abTestShowMyProducts = NewfoldRuntime.hasCapability(
'abTestShowMyProducts'
Expand All @@ -23,7 +23,7 @@ const Home = () => {
</div>
</Container.Block>
</Container>
{ abTestShowMyProducts && <ProductSection /> }
{ abTestShowMyProducts && <MyProductSection /> }
</Page>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Container } from '@newfold/ui-component-library';
import apiFetch from '@wordpress/api-fetch';
import { useState, useEffect } from '@wordpress/element';
import { NewfoldRuntime } from '@newfold-labs/wp-module-runtime';
import { default as NewfoldMyProducts } from '@modules/wp-module-my-products/components/product';
import { isJarvis } from '../../util/helpers';
import { default as NewfoldMyProducts } from '@modules/wp-module-my-products/components/myProducts';

// constants to pass to module
const moduleConstants = {
Expand Down Expand Up @@ -42,15 +41,13 @@ const moduleMethods = {
isJarvis,
};

const ProductSection = () => {
const MyProductsSection = () => {
return (
<Container className="wppbh-products-section">
<NewfoldMyProducts
methods={ moduleMethods }
constants={ moduleConstants }
/>
</Container>
<NewfoldMyProducts
methods={ moduleMethods }
constants={ moduleConstants }
/>
);
};

export default ProductSection;
export default MyProductsSection;
14 changes: 0 additions & 14 deletions tests/cypress/fixtures/products.json

This file was deleted.

52 changes: 1 addition & 51 deletions tests/cypress/integration/home.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// <reference types="Cypress" />
const productFixtures = require( '../fixtures/products.json' );

describe( 'Home Page', function () {
let NewfoldRuntime;

Expand Down Expand Up @@ -129,54 +129,4 @@ describe( 'Home Page', function () {
cy.reload();
cy.get( '.wppbh-webinars-banner-section' ).should( 'not.exist' );
} );

it( 'Products Section Renders Correctly', () => {
if ( NewfoldRuntime.capabilities.abTestShowMyProducts ) {
cy.intercept(
'GET',
'/index.php?rest_route=%2Fnewfold-my-products%2Fv1%2Fproducts&_locale=user',
productFixtures
);
cy.reload();
// Verify the table contains the correct product data
cy.get( '.wppbh-products-data-section' ).within( () => {
cy.contains( 'Products & Services' ).should( 'be.visible' );
cy.contains( 'Free SSL' ).should( 'be.visible' );
cy.contains( 'SiteLock Lite' ).should( 'be.visible' );
} );
} else {
cy.get( '.wppbh-products-section' ).should( 'not.exist' );
}
} );

it( 'Products Section Renders Correctly for No products response', () => {
if ( NewfoldRuntime.capabilities.abTestShowMyProducts ) {
cy.intercept(
'GET',
'/index.php?rest_route=%2Fnewfold-my-products%2Fv1%2Fproducts&_locale=user',
[]
);
cy.reload();
cy.get( '.wppbh-products-section' )
.contains( 'Sorry, no products. Please, try again later.' )
.scrollIntoView()
.should( 'be.visible' );
} else {
cy.get( '.wppbh-products-section' ).should( 'not.exist' );
}
} );

it( 'Products Section Renders Correctly for Empty response', () => {
if ( NewfoldRuntime.capabilities.abTestShowMyProducts ) {
cy.intercept(
'GET',
'/index.php?rest_route=%2Fnewfold-my-products%2Fv1%2Fproducts&_locale=user',
{}
);
cy.reload();
cy.get( '.wppbh-products-section' ).should( 'not.exist' );
} else {
cy.get( '.wppbh-products-section' ).should( 'not.exist' );
}
} );
} );

0 comments on commit f56b029

Please sign in to comment.