Enhance testing framework with WordPress Playground integration
This commit is contained in:
@@ -28,11 +28,11 @@ describe('WordPress Multisite Tests', () => {
|
||||
});
|
||||
|
||||
it('Plugin is network activated', () => {
|
||||
cy.loginAsAdmin();
|
||||
// Use our custom command to check and network activate the plugin if needed
|
||||
cy.networkActivatePlugin('wp-plugin-starter-template-for-ai-coding');
|
||||
|
||||
// Check plugins page
|
||||
cy.visit('/wp-admin/network/plugins.php');
|
||||
cy.contains('tr', 'WP Plugin Starter Template').should('contain', 'Network Active');
|
||||
// Verify it's network active
|
||||
cy.get('tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .network_active').should('exist');
|
||||
});
|
||||
|
||||
it('Network settings page loads correctly', () => {
|
||||
|
||||
@@ -11,11 +11,11 @@ describe('WordPress Single Site Tests', () => {
|
||||
});
|
||||
|
||||
it('Plugin is activated', () => {
|
||||
cy.loginAsAdmin();
|
||||
// Use our custom command to check and activate the plugin if needed
|
||||
cy.activatePlugin('wp-plugin-starter-template-for-ai-coding');
|
||||
|
||||
// Check plugins page
|
||||
cy.visit('/wp-admin/plugins.php');
|
||||
cy.contains('tr', 'WP Plugin Starter Template').should('contain', 'Deactivate');
|
||||
// Verify it's active
|
||||
cy.get('tr[data-slug="wp-plugin-starter-template-for-ai-coding"] .deactivate').should('exist');
|
||||
});
|
||||
|
||||
it('Plugin settings page loads correctly', () => {
|
||||
|
||||
@@ -13,8 +13,61 @@
|
||||
*/
|
||||
Cypress.Commands.add('loginAsAdmin', () => {
|
||||
cy.visit('/wp-admin');
|
||||
cy.get('#user_login').type('admin');
|
||||
cy.get('#user_pass').type('password');
|
||||
cy.get('#wp-submit').click();
|
||||
cy.get('body.wp-admin').should('exist');
|
||||
|
||||
// Check if we're already logged in
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find('body.wp-admin').length > 0) {
|
||||
// Already logged in
|
||||
cy.log('Already logged in as admin');
|
||||
return;
|
||||
}
|
||||
|
||||
// Need to log in
|
||||
cy.get('#user_login').type('admin');
|
||||
cy.get('#user_pass').type('password');
|
||||
cy.get('#wp-submit').click();
|
||||
cy.get('body.wp-admin').should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Custom command to activate plugin
|
||||
*/
|
||||
Cypress.Commands.add('activatePlugin', (pluginSlug) => {
|
||||
cy.loginAsAdmin();
|
||||
cy.visit('/wp-admin/plugins.php');
|
||||
|
||||
// Check if plugin is already active
|
||||
cy.get(`tr[data-slug="${pluginSlug}"]`).then(($tr) => {
|
||||
if ($tr.find('.deactivate').length > 0) {
|
||||
// Plugin is already active
|
||||
cy.log(`Plugin ${pluginSlug} is already active`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Activate the plugin
|
||||
cy.get(`tr[data-slug="${pluginSlug}"] .activate a`).click();
|
||||
cy.get(`tr[data-slug="${pluginSlug}"] .deactivate`).should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Custom command to network activate plugin
|
||||
*/
|
||||
Cypress.Commands.add('networkActivatePlugin', (pluginSlug) => {
|
||||
cy.loginAsAdmin();
|
||||
cy.visit('/wp-admin/network/plugins.php');
|
||||
|
||||
// Check if plugin is already network active
|
||||
cy.get(`tr[data-slug="${pluginSlug}"]`).then(($tr) => {
|
||||
if ($tr.find('.network_active').length > 0) {
|
||||
// Plugin is already network active
|
||||
cy.log(`Plugin ${pluginSlug} is already network active`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Network activate the plugin
|
||||
cy.get(`tr[data-slug="${pluginSlug}"] .activate a`).click();
|
||||
cy.get(`tr[data-slug="${pluginSlug}"] .network_active`).should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user