Skip to content

Commit

Permalink
Client: Add activatePlugin() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Mar 22, 2023
1 parent ca25ef5 commit e6c96e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/playground/client/src/lib/activate-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { PlaygroundClient } from '../';
import { asDOM } from './common';

export async function activatePlugin(
playground: PlaygroundClient,
plugin: string
) {
const pluginsPage = asDOM(
await playground.request({
relativeUrl: '/wp-admin/plugins.php',
})
);

const link = pluginsPage.querySelector(
`tr[data-slug="${plugin}"] a`
)! as HTMLAnchorElement;
const href = link.attributes.getNamedItem('href')!.value;

await playground.request({
relativeUrl: '/wp-admin/' + href,
});
}
1 change: 1 addition & 0 deletions packages/playground/client/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export { importFile } from './import-export';
export { login } from './login';
export { installTheme } from './install-theme';
export { installPlugin } from './install-plugin';
export { activatePlugin } from './activate-plugin';
export { installThemeFromDirectory } from './install-theme-from-directory';
export { installPluginsFromDirectory } from './install-plugins-from-directory';

0 comments on commit e6c96e5

Please sign in to comment.