Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Core settings test case #45320

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions packages/e2e-tests/specs/editor/various/core-settings.test.js

This file was deleted.

56 changes: 56 additions & 0 deletions test/e2e/specs/editor/various/core-settings-test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.use({
settingUtils: async ({ page, admin, requestUtils }, use) => {
await use(new SettingUtils({ page, admin, requestUtils }));
},
});
test.describe( 'Settings', () => {

test('Regression: updating a specific option will only change its value and will not corrupt others', async ( {
page,
admin,
settingUtils
} ) => {

const optionsInputsSelector =
'form#all-options table.form-table input:not([id*="_transient"]):not([id="blogdescription"])';
const optionsBefore = await settingUtils.getOptionsValues(optionsInputsSelector);

await admin.visitAdminPage('options-general.php');
await page.type(
'input#blogdescription',
'Just another Gutenberg site'
);
await page.click('role=button[name="Save Changes"i]');

const optionsAfter = await settingUtils.getOptionsValues(optionsInputsSelector);

Object.entries(optionsBefore).forEach((optionBefore) => {
const [id] = optionBefore;
const optionAfter = [id, optionsAfter[id]];
expect(optionAfter).toStrictEqual(optionBefore);
});
} );
} );

class SettingUtils {
constructor({ page, admin }) {
this.page = page;
this.admin = admin;
}

async getOptionsValues(selector) {
await this.admin.visitAdminPage('options.php');
return this.page.evaluate((theSelector) => {
const inputs = Array.from(document.querySelectorAll(theSelector));
return inputs.reduce((memo, input) => {
memo[input.id] = input.value;
return memo;
}, {});
}, selector);
}
}