Skip to content

Commit

Permalink
small changes to exec statement
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeetha-nayak committed Dec 29, 2023
1 parent 7844297 commit 98fce6e
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions tests/cypress/integration/Site-Capabilities/siteCapabilities.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ import { GetPluginId, getAppId } from '../wp-module-support/pluginID.cy';

const customCommandTimeout = 60000;
const mediumWait = 30000;
const pluginId = GetPluginId()
const pluginId = GetPluginId();
const appId = getAppId();

describe( 'Verify Wondercart accessibility as per capabilities', () => {
const cTBAndYithTrue = JSON.stringify( {
canAccessAI: true,
canAccessHelpCenter: true,
canAccessGlobalCTB: true,
hasEcomdash: false,
hasYithExtended: true,
isEcommerce: true,
isJarvis: true,
"canAccessAI": true,
"canAccessHelpCenter": true,
"canAccessGlobalCTB": true,
"hasEcomdash": false,
"hasYithExtended": true,
"isEcommerce": true,
"isJarvis": true,
} );

const cTBTrueYithFalse = JSON.stringify( {
...cTBAndYithTrue,
hasYithExtended: false,
isEcommerce: false,
"hasYithExtended": false,
"isEcommerce": false,
} );

before( () => {
Expand All @@ -43,41 +43,45 @@ describe( 'Verify Wondercart accessibility as per capabilities', () => {
} );
} );

beforeEach(() => {
beforeEach( () => {
if ( pluginId !== 'bluehost' ) {
this.skip();
}
cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' );
});
} );

after(() => {
after( () => {
cy.exec(
`npx wp-env run cli wp option delete _transient_nfd_site_capabilities`,
{ failOnNonZeroExit: false }
);
})
it('Verify if Sales and Discounts sub tab is displayed', () => {
} );

it( 'Verify if Sales and Discounts sub tab is displayed', () => {
cy.exec(
`npx wp-env run cli wp option delete _transient_nfd_site_capabilities`,
{ failOnNonZeroExit: false }
);
cy.exec(
`npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ cTBAndYithTrue }' --format=json`,
{ timeout: customCommandTimeout }
)
);
cy.reload();
cy.get( `.${ appId }-app-navitem-Store`, {
timeout: mediumWait,
} ).click();
cy.get( `.${ appId }-app-subnavitem` )
.contains( 'Sales & Discounts' )
.should( 'exist' );
})
} );

it( 'Verify Buy Now is shown when canAccessGlobalCTB is true and commerce addon is false', () => {
cy.exec(
`npx wp-env run cli wp option update _transient_nfd_site_capabilities '${ cTBTrueYithFalse }'`,
`npx wp-env run cli wp option delete _transient_nfd_site_capabilities`,
{ failOnNonZeroExit: false }
);
cy.exec(
`npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ cTBTrueYithFalse }'`,
{ timeout: customCommandTimeout }
).then( ( result ) => {
cy.log( result.stdout );
Expand Down Expand Up @@ -119,9 +123,13 @@ describe( 'Verify Wondercart accessibility as per capabilities', () => {

it( 'Verify Install Now is shown when customer has ecommerce addon', () => {
cy.exec(
`npx wp-env run cli wp option update _transient_nfd_site_capabilities '${ cTBAndYithTrue }' --format=json`,
`npx wp-env run cli wp option delete _transient_nfd_site_capabilities`,
{ failOnNonZeroExit: false }
);
cy.exec(
`npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ cTBAndYithTrue }' --format=json`,
{ timeout: customCommandTimeout }
)
);
cy.reload();
cy.get( `.${ appId }-app-navitem-Store`, {
timeout: mediumWait,
Expand Down Expand Up @@ -159,5 +167,5 @@ describe( 'Verify Wondercart accessibility as per capabilities', () => {
cy.contains( 'Create campaign', { timeout: mediumWait } ).should(
'exist'
);
});
} );
} );

0 comments on commit 98fce6e

Please sign in to comment.