diff --git a/package.json b/package.json index 3a8c077..093d4af 100644 --- a/package.json +++ b/package.json @@ -19,5 +19,9 @@ "bugs": { "url": "https://github.com/joomla-projects/joomla-cypress/issues" }, - "homepage": "https://github.com/joomla-projects/joomla-cypress#readme" + "homepage": "https://github.com/joomla-projects/joomla-cypress#readme", + "main": "src", + "files": [ + "src" + ] } diff --git a/src/extensions.js b/src/extensions.js new file mode 100644 index 0000000..b6effb5 --- /dev/null +++ b/src/extensions.js @@ -0,0 +1,6 @@ +const extensionsCommands = () => { +} + +module.exports = { + extensionsCommands +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..021dabc --- /dev/null +++ b/src/index.js @@ -0,0 +1,15 @@ +const registerCommands = () => { + const { joomlaCommands } = require('joomla-cypress/src/joomla') + const { extensionsCommands } = require('joomla-cypress/src/extensions') + const { supportCommands } = require('joomla-cypress/src/support') + const { userCommands } = require('joomla-cypress/src/user') + + joomlaCommands() + extensionsCommands() + supportCommands() + userCommands() +} + +module.exports = { + registerCommands +} diff --git a/src/joomla.js b/src/joomla.js new file mode 100644 index 0000000..7c78ad4 --- /dev/null +++ b/src/joomla.js @@ -0,0 +1,48 @@ +const joomlaCommands = () => { + const installJoomla = (config) => { + cy.log(`**Install Joomla**`) + // Load installation page and check for language dropdown + cy.visit('installation/index.php') + cy.get('#jform_language').should('be.visible') + + // Select en-GB as installation language + cy.get('#jform_language').select('English (United Kingdom)') + cy.get('#jform_language-lbl').should('contain', 'Select Language') + + // Fill Sitename + cy.get('#jform_site_name').type(config.sitename) + cy.get('#step1').click() + + // Fill Admin credentials + cy.get('#jform_admin_user').type(config.name) + cy.get('#jform_admin_username').type(config.username) + cy.get('#jform_admin_password').type(config.password) + cy.get('#jform_admin_email').type(config.email) + cy.get('#step2').click() + + // Fill database configuration + cy.get('#jform_db_type').select(config.db_type) + cy.get('#jform_db_host').clear().type(config.db_host) + cy.get('#jform_db_user').type(config.db_user) + if (config.db_password) + cy.get('#jform_db_pass').type(config.db_password) + cy.get('#jform_db_name').clear().type(config.db_name) + cy.get('#jform_db_prefix').clear().type(config.db_prefix) + cy.intercept('index.php?task=installation.*').as('ajax_requests') + cy.get('#setupButton').click() + cy.wait('@ajax_requests') + cy.wait('@ajax_requests') + cy.wait('@ajax_requests') + cy.wait('@ajax_requests') + cy.wait('@ajax_requests') + cy.wait('@ajax_requests') + cy.wait('@ajax_requests') + cy.contains('Congratulations! Your Joomla site is ready.') + } + + Cypress.Commands.add('installJoomla', installJoomla) +} + +module.exports = { + joomlaCommands +} diff --git a/src/support.js b/src/support.js new file mode 100644 index 0000000..0da9f47 --- /dev/null +++ b/src/support.js @@ -0,0 +1,6 @@ +const supportCommands = () => { +} + +module.exports = { + supportCommands +} diff --git a/src/user.js b/src/user.js new file mode 100644 index 0000000..75bffe4 --- /dev/null +++ b/src/user.js @@ -0,0 +1,6 @@ +const userCommands = () => { +} + +module.exports = { + userCommands +}