-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test regression for settings update corrupting some wp_options
- Loading branch information
1 parent
17eb33b
commit eefbff7
Showing
3 changed files
with
158 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { visitAdminPage } from '@wordpress/e2e-test-utils'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
|
||
async function getOptionsValues( selector ) { | ||
await visitAdminPage( 'options.php' ); | ||
return page.evaluate( ( theSelector ) => { | ||
const inputs = Array.from( document.querySelectorAll( theSelector ) ); | ||
return inputs.reduce( ( memo, input ) => { | ||
memo[ input.id ] = input.value; | ||
return memo; | ||
}, {} ); | ||
}, selector ); | ||
} | ||
|
||
describe( 'Settings', () => { | ||
test( 'Regression: updating a specific option will only change its value and will not corrupt others', async () => { | ||
// We won't select the option that we updated and will also remove some _transient options that seem to change at | ||
// every update (?) | ||
const optionsInputsSelector = | ||
'form#all-options table.form-table input:not([id*="_transient"]):not([id="blogdescription"])'; | ||
const optionsBefore = await getOptionsValues( optionsInputsSelector ); | ||
|
||
await visitAdminPage( 'options-general.php' ); | ||
await page.type( | ||
'input#blogdescription', | ||
'Just another Gutenberg site' | ||
); | ||
await page.click( 'input#submit' ); | ||
|
||
const optionsAfter = await getOptionsValues( optionsInputsSelector ); | ||
|
||
Object.entries( optionsBefore ).forEach( ( optionBefore ) => { | ||
const [ id ] = optionBefore; | ||
const optionAfter = [ id, optionsAfter[ id ] ]; | ||
expect( optionAfter ).toStrictEqual( optionBefore ); | ||
} ); | ||
} ); | ||
} ); |