Skip to content

Commit

Permalink
Merge pull request #373 from newfold-labs/fix/migration-test-again
Browse files Browse the repository at this point in the history
remove button click from test as it is not needed and flaky
  • Loading branch information
circlecube authored Nov 7, 2024
2 parents e691ce7 + 6e22434 commit 556a42d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use function NewfoldLabs\WP\ModuleLoader\register;

define( 'NFD_ECOMMERCE_MODULE_VERSION', '1.4.2' );
define( 'NFD_ECOMMERCE_MODULE_VERSION', '1.4.3' );

if ( function_exists( 'is_admin' ) && is_admin() ) {
$old_woocommerce_module_version = get_option( 'nfd_ecommerce_module_version' );
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@newfold-labs/wp-module-ecommerce",
"description": "Brand Agnostic eCommerce Experience",
"license": "GPL-2.0-or-later",
"version": "1.4.2",
"version": "1.4.3",
"main": "build/index.js",
"files": [
"build/",
Expand Down
59 changes: 39 additions & 20 deletions tests/cypress/integration/Home/migration.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { GetPluginId } from '../wp-module-support/pluginID.cy';
import { EventsAPI, APIList } from '../wp-module-support/eventsAPIs.cy';
import { wpLogin } from '../wp-module-support/utils.cy';
import {
wpLogin,
wpCli,
uninstallPlugins,
} from '../wp-module-support/utils.cy';
const customCommandTimeout = 20000;
const pluginId = GetPluginId();
const helpCenter = JSON.stringify( {
Expand All @@ -12,27 +16,33 @@ describe(
'Home page - post migration events with help center ',
{ testIsolation: true },
() => {
beforeEach( function () {
wpLogin();

before( function () {
if ( pluginId !== 'bluehost' ) {
this.skip();
}
cy.exec(
`npx wp-env run cli wp option set nfd_show_migration_steps "true"`
);
cy.exec(
`npx wp-env run cli wp option delete _transient_nfd_site_capabilities`,
{ failOnNonZeroExit: false }
uninstallPlugins();
} );

beforeEach( () => {
wpLogin();
wpCli(
`option update _transient_nfd_site_capabilities '${ helpCenter }' --format=json`
);
cy.exec(
`npx wp-env run cli wp option set _transient_nfd_site_capabilities '${ helpCenter }' --format=json`,
{ timeout: customCommandTimeout }
const expiry = Math.floor( new Date().getTime() / 1000.0 ) + 3600;
wpCli(
`option update _transient_timeout_nfd_site_capabilities ${ expiry }`
);
cy.reload();
// this resets on longin, so must be reset to true here
wpCli( 'option update nfd_show_migration_steps 1' );

cy.visit( '/wp-admin/admin.php?page=' + pluginId + '#/home' );
} );

after( () => {
wpCli( `transient delete nfd_site_capabilities` );
wpCli( `option delete nfd_show_migration_steps` );
} );

it( 'Verify if Welcome home! section shows', () => {
cy.get( '.nfd-justify-start', { timeout: customCommandTimeout } )
.scrollIntoView()
Expand All @@ -47,39 +57,48 @@ describe(

it( 'Verify when update nameserver clicked', () => {
cy.intercept( APIList.update_nameserver ).as( 'events' );
cy.reload();
cy.get( '#onboarding-list [data-testid="nameservers"]', {
timeout: customCommandTimeout,
} )
.scrollIntoView()
.should( 'exist' )
.click();
EventsAPI( APIList.update_nameserver, pluginId );
cy.wait( 1000 );
cy.get( '.help-container', {
timeout: customCommandTimeout,
} ).should( 'be.visible' );
cy.get( '.help-container button.close-button', {
timeout: 5000,
} ).click();
cy.get( '#search-input-box' )
.should( 'have.attr', 'value' )
.then( ( value ) => {
expect( value.toLowerCase() ).to.contain( 'nameserver' );
} );
} );

it( 'Verify when connect domain to site clicked', () => {
cy.intercept( APIList.connect_domain ).as( 'events' );
cy.reload();
cy.get( '#onboarding-list [data-testid="domain"]', {
timeout: customCommandTimeout,
} )
.scrollIntoView()
.should( 'exist' )
.click();
EventsAPI( APIList.connect_domain, pluginId );
cy.wait( 1000 );
cy.get( '.help-container', {
timeout: customCommandTimeout,
} ).should( 'be.visible' );
cy.get( '.help-container button.close-button', {
timeout: 5000,
} ).click();
cy.get( '#search-input-box' )
.should( 'have.attr', 'value' )
.then( ( value ) => {
expect( value.toLowerCase() ).to.contain( 'domain' );
} );
} );

it( 'Verify when continue with store setup clicked', () => {
cy.reload();
cy.get( '#onboarding-list [data-testid="continue"]', {
timeout: customCommandTimeout,
} )
Expand Down
13 changes: 13 additions & 0 deletions tests/cypress/integration/wp-module-support/utils.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,16 @@ export const deleteCapabilitiesTransient = () => {
export const wpLogin = () => {
cy.login( Cypress.env( 'wpUsername' ), Cypress.env( 'wpPassword' ) );
};

// wp cli wrapper
export const wpCli = ( cmd ) => {
cy.exec( `npx wp-env run cli wp ${ cmd }`, {
env: {
NODE_TLS_REJECT_UNAUTHORIZED: '1',
},
} ).then( ( result ) => {
for ( const [ key, value ] of Object.entries( result ) ) {
cy.log( `${ key }: ${ value }` );
}
} );
};

0 comments on commit 556a42d

Please sign in to comment.