
/**
 * WordPress dependencies
 */
import { activatePlugin, visitAdminPage } from '@wordpress/e2e-test-utils';

/**
 * The allow list of AMP modes.
 */
export const allowedAMPModes = {
	standard: 'standard',
	transitional: 'transitional',
	reader: 'disabled',
};

/**
 * Activate AMP and set it to the correct mode.
 *
 * @param {string} mode The mode to set AMP to. Possible value of standard, transitional or reader.
 */
export const activateAMPWithMode = async ( mode ) => {
	await activatePlugin( 'amp' );
	await setAMPMode( mode );
};

/**
 * Set AMP Mode
 *
 * @param {string} mode The mode to set AMP to. Possible value of standard, transitional or reader.
 */
export const setAMPMode = async ( mode ) => {
	// Test to be sure that the passed mode is known.
	expect( allowedAMPModes ).toHaveProperty( mode );
	// Set the AMP mode
	await visitAdminPage( 'admin.php', 'page=amp-options' );
	await expect( page ).toClick( `#theme_support_${ allowedAMPModes[ mode ] }` );
	await expect( page ).toClick( '#submit' );
	await page.waitForNavigation();
};


/**
 * WordPress dependencies
 */
import { activatePlugin, visitAdminPage } from '@wordpress/e2e-test-utils';

/**
 * The allow list of AMP modes.
 */
export const allowedAMPModes = {
	primary: 'standard',
	secondary: 'transitional',
	standard: 'standard',
	transitional: 'transitional',
	reader: 'disabled',
};

/**
 * Activate AMP and set it to the correct mode.
 *
 * @param {string} mode The mode to set AMP to. Possible value of standard, transitional or reader.
 */
export const activateAMPWithMode = async ( mode ) => {
	await activatePlugin( 'amp' );
	await setAMPMode( mode );
};

/**
 * Set AMP Mode
 *
 * @param {string} mode The mode to set AMP to. Possible value of standard, transitional or reader.
 */
export const setAMPMode = async ( mode ) => {
	// Test to be sure that the passed mode is known.
	expect( allowedAMPModes ).toHaveProperty( mode );
	// Set the AMP mode
	await visitAdminPage( 'admin.php', 'page=amp-options' );
	await expect( page ).toClick( `#theme_support_${ allowedAMPModes[ mode ] }` );
	await expect( page ).toClick( '#submit' );
	await page.waitForNavigation();
};

Add aliase for primary and secondary AMP modes.
Add aliase for primary and secondary AMP modes.
