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

Bail early in deactivatePlugin if plugin is already inactive #16816

Merged
merged 2 commits into from Aug 1, 2019

Conversation

@swissspidy
Copy link
Member

commented Jul 30, 2019

Description

Adjusts the deactivatePlugin e2e util to bail early if the plugin is already inactive.

Matches behavior with activatePlugin util, which also bails early for already active plugins.

How has this been tested?

Manual testing by trying to deactivate in inactive plugin.

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
Bail early in deactivatePlugin if plugin is already inactive
Matches behavior with activatePlugin util, which also bails early for already active plugins.
@gziolo
gziolo approved these changes Jul 30, 2019
Copy link
Member

left a comment

Looks like a good improvement 👍

@gziolo
Copy link
Member

left a comment

I think, there is one potential issue. Don't we still need to switch back the user account if not using Admin role?

@swissspidy

This comment has been minimized.

Copy link
Member Author

commented Jul 30, 2019

@gziolo Good point. I applied the same change to activatePlugin as well.

@swissspidy swissspidy requested a review from gziolo Jul 30, 2019

@@ -13,6 +13,11 @@ import { visitAdminPage } from './visit-admin-page';
export async function deactivatePlugin( slug ) {
await switchUserToAdmin();
await visitAdminPage( 'plugins.php' );
const deleteLink = await page.$( `tr[data-slug="${ slug }"] .delete a` );
if ( deleteLink ) {
await switchUserToTest();

This comment has been minimized.

Copy link
@aduth

aduth Jul 30, 2019

Member

Alternatively, it could be more expressive for "common" logic as:

export async function deactivatePlugin( slug ) {
	await switchUserToAdmin();
	await visitAdminPage( 'plugins.php' );
	const deleteLink = await page.$( `tr[data-slug="${ slug }"] .delete a` );
	if ( ! deleteLink ) {
		await page.click( `tr[data-slug="${ slug }"] .deactivate a` );
		await page.waitForSelector( `tr[data-slug="${ slug }"] .delete a` );
	}
	await switchUserToTest();
}

This comment has been minimized.

Copy link
@swissspidy

swissspidy Jul 31, 2019

Author Member

That works too. No strong opinion about either way.

@gziolo
gziolo approved these changes Jul 31, 2019
Copy link
Member

left a comment

2 potential issues fixed at once. It's even better :)

@youknowriad youknowriad merged commit 173af26 into master Aug 1, 2019

1 of 5 checks passed

Filter opened Filter opened
Details
Filter opened Filter opened
Details
Milestone It Milestone It
Details
Milestone It Milestone It
Details
Travis CI - Pull Request Build Passed
Details

@youknowriad youknowriad deleted the fix/return-early-in-deactivate-plugin-e2e-util branch Aug 1, 2019

@youknowriad youknowriad added this to the Gutenberg 6.3 milestone Aug 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.