-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
E2E Tests: Adding helpers to install/activate/deactivate and remove plugins #5906
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Node dependencies | ||
*/ | ||
import { visitAdmin } from './utils'; | ||
|
||
export async function installPlugin( name, searchTerm ) { | ||
await visitAdmin( 'plugin-install.php?s=' + encodeURIComponent( searchTerm || name ) + '&tab=search&type=term' ); | ||
await page.click( '.install-now[data-slug="' + name + '"]' ); | ||
await page.waitForSelector( '.activate-now[data-slug="' + name + '"]' ); | ||
} | ||
|
||
export async function activatePlugin( name ) { | ||
await visitAdmin( 'plugins.php' ); | ||
await page.click( 'tr[data-slug="' + name + '"] .activate a' ); | ||
await page.waitForSelector( 'tr[data-slug="' + name + '"] .deactivate a' ); | ||
} | ||
|
||
export async function deactivatePlugin( name ) { | ||
await visitAdmin( 'plugins.php' ); | ||
await page.click( 'tr[data-slug="' + name + '"] .deactivate a' ); | ||
await page.waitForSelector( 'tr[data-slug="' + name + '"] .delete a' ); | ||
} | ||
|
||
export async function uninstallPlugin( name ) { | ||
await visitAdmin( 'plugins.php' ); | ||
const confirmPromise = new Promise( resolve => { | ||
const confirmDialog = ( dialog ) => { | ||
dialog.accept(); | ||
page.removeListener( 'dialog', confirmDialog ); | ||
resolve(); | ||
}; | ||
page.on( 'dialog', confirmDialog ); | ||
} ); | ||
await Promise.all( [ | ||
page.click( 'tr[data-slug="' + name + '"] .delete a' ), | ||
confirmPromise, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it'll suffer the same race conditions as |
||
] ); | ||
await page.waitForSelector( 'tr[data-slug="' + name + '"].deleted' ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the purpose of the second argument here? Not clear by the included documentation 😉