Last active
January 6, 2022 21:03
-
-
Save miminari/cca6307a9811c919824d3592038b28fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WordPress dependencies | |
*/ | |
import { visitAdminPage, switchUserToAdmin, switchUserToTest } from '@wordpress/e2e-test-utils'; | |
/** | |
* Visits general settings page and changes the language to the given vaule. | |
* | |
* @param {string} lang Value of the language to set. | |
* | |
* @return {string} Value of the previous language. | |
*/ | |
export async function changeSiteLang(lang) { | |
await switchUserToAdmin(); | |
await visitAdminPage('options-general.php'); | |
const oldLang = await page.$eval( | |
'#WPLANG', | |
(element) => element.options[element.selectedIndex].text | |
); | |
await page.select('#WPLANG', lang); | |
await Promise.all([ | |
page.click('#submit') | |
]); | |
await switchUserToTest(); | |
return oldLang; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment