Update to version 0.1.5 with testing setup, multisite compatibility, and npm scripts

This commit is contained in:
2025-04-18 14:32:46 +01:00
parent 9d3e67d16b
commit bfac63799b
9 changed files with 269 additions and 19 deletions

9
tests/e2e/cypress.json Normal file
View File

@@ -0,0 +1,9 @@
{
"baseUrl": "http://localhost:8889",
"integrationFolder": "tests/e2e/cypress/integration",
"pluginsFile": "tests/e2e/cypress/plugins/index.js",
"supportFile": "tests/e2e/cypress/support/index.js",
"videosFolder": "tests/e2e/cypress/videos",
"screenshotsFolder": "tests/e2e/cypress/screenshots",
"fixturesFolder": "tests/e2e/cypress/fixtures"
}

View File

@@ -0,0 +1,27 @@
/**
* Basic e2e test for the plugin.
*/
describe('Plugin Basic Tests', () => {
before(() => {
cy.login();
});
it('Should activate the plugin', () => {
cy.visit('/wp-admin/plugins.php');
cy.contains('WP Plugin Starter Template').should('exist');
// Check if plugin is not active, then activate it
cy.get('tr[data-slug="wp-plugin-starter-template-for-ai-coding"]')
.then(($tr) => {
if ($tr.hasClass('inactive')) {
cy.wrap($tr).find('.activate a').click();
cy.contains('Plugin activated.').should('exist');
}
});
});
it('Should have the plugin settings page', () => {
cy.visit('/wp-admin/options-general.php?page=wp-plugin-starter-template');
cy.contains('WP Plugin Starter Template Settings').should('exist');
});
});

View File

@@ -0,0 +1,10 @@
/**
* Cypress plugins file.
*
* @param {Object} on - Cypress events
* @param {Object} config - Cypress config
* @return {Object} - Modified config
*/
module.exports = (on, config) => {
return config;
};

View File

@@ -0,0 +1,12 @@
/**
* Custom Cypress commands.
*/
// Login command
Cypress.Commands.add('login', (username = 'admin', password = 'password') => {
cy.visit('/wp-login.php');
cy.get('#user_login').type(username);
cy.get('#user_pass').type(password);
cy.get('#wp-submit').click();
cy.get('body.wp-admin').should('exist');
});

View File

@@ -0,0 +1,4 @@
/**
* Import commands.js
*/
import './commands';