HEX
Server: Apache
System: Linux efa57bbe-abb1-400d-2985-3b056fbc2701.secureserver.net 6.1.147-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 24 12:33:32 EDT 2025 x86_64
User: root (0)
PHP: 8.0.30.4
Disabled: NONE
Upload Files
File: //var/www/wp-content/mu-plugins/vendor/wpex/godaddy-launch/.dev/tests/cypress/helpers.js
/**
 * Login to our test WordPress site
 */
export function loginToSite() {
	const username = Cypress.env('wpUsername');
	const password = Cypress.env('wpPassword');

	cy.session(
		[username, password],
		() => {
			cy.visit( Cypress.env( 'testURL' ) + '/wp-login.php' );
			cy.wait( 250 );

			cy.get( '#user_login' ).type( username );
			cy.get( '#user_pass' ).type( password );
			cy.get( '#wp-submit' ).click();

			cy.url().should('contain', '/wp-admin');
		},
		{
			cacheAcrossSpecs: true,
		}
	);
}

/**
 * Go to a specific URI.
 *
 * @param {string} path The URI path to go to.
 */
export function goTo( path = '/wp-admin' ) {
	cy.visit( Cypress.env( 'testURL' ) + path );

	return getWindowObject();
}

/**
 * Safely obtain the window object or error
 * when the window object is not available.
 */
export function getWindowObject() {
	const editorUrlStrings = [ 'post-new.php', 'action=edit' ];
	return cy.window().then( ( win ) => {
		const isEditorPage = editorUrlStrings.filter( ( str ) => win.location.href.includes( str ) );

		if ( isEditorPage.length === 0 ) {
			throw new Error( 'Check the previous test, window property was invoked outside of Editor.' );
		}

		if ( ! win?.wp ) {
			throw new Error( 'Window property was invoked within Editor but `win.wp` is not defined.' );
		}

		return win;
	} );
}