diff --git a/README.md b/README.md index 7921aa9..9cca6da 100644 --- a/README.md +++ b/README.md @@ -298,14 +298,15 @@ cy.installJoomlaMultilingualSite(config, languages); --- +'Welcome to Joomla!' guided tour overlay window + #### `cancelTour` -Since Joomla version 5 there is a guided tour with the overlay 'Welcome to Joomla!' -after first administrator login. -The command `cancelTour` closes this guided tour overlay. -The Joomla administrator must be logged in to do this. -This is only possible once after installation and the first login. -The timeout is extended to 40 seconds. +With Joomla 5.1 the 'Welcome to Joomla!' guided tour starts automatically the very first time an user logs in to the Administrator backend. As this overlay window (see screenshot) blocks interaction with the underlying content, it must be closed. The overlay of the guided tour is closed with the `cancelTour` command. + +In Joomla 5.1 the overlay window is closed with the cancel `X`-button. Since Joomla 5.2 there is an additional button `Hide Forever`. This is preferably used. + +A Joomla administrator must be logged in for this. This command can only be executed once after a Joomla installation and only from version 5.1 upwards. ##### Usage diff --git a/images/cancelTour.png b/images/cancelTour.png new file mode 100644 index 0000000..3b59dff Binary files /dev/null and b/images/cancelTour.png differ diff --git a/src/joomla.js b/src/joomla.js index 0285468..937c1b8 100644 --- a/src/joomla.js +++ b/src/joomla.js @@ -49,28 +49,45 @@ const joomlaCommands = () => { Cypress.Commands.add('installJoomla', installJoomla) - - // Cancel Tour - const cancelTour = () => { - cy.log('**Cancel Tour**') - cy.get('.shepherd-cancel-icon', { timeout: 40000 }).should('exist').click() + /** + * Cancel the guided tour. + * Custom Cypress command to close the guided tour overlay window 'Welcome to Joomla!'. + * + * @memberof Cypress.Commands + * @method cancelTour + * @returns {Cypress.Chainable} + * + * With Joomla 5.1 the 'Welcome to Joomla!' guided tour starts automatically the very first time an user logs in + * to the Administrator backend. As this overlay window is blocking interaction with the underlying content + * it needs to be closed. + * + * In Joomla 5.1 the overlay window is closed with the cancel button. + * Since Joomla 5.2 there is an additional function to hide tours forever. This is preferably used. + * + * A Joomla administrator must be logged in for this. + * This command can only be executed once after a Joomla installation and only from version 5.1 upwards. + */ + Cypress.Commands.add('cancelTour', () => { + cy.log('**Cancel Tour**') + const startButton = '.shepherd-button-primary' // 'Start' + const cancelButton = '.shepherd-cancel-icon' // 'X' + const skipButton = '.shepherd-button-secondary' // 'Hide Forever' + + // Wait for the overlay window of the guided tour, as it is generated by JavaScript. + cy.get(startButton).should('exist') + cy.get('body').then(($body) => { + // First attempt: As introduced with Joomla 5.2, skip the guided tour with the 'Hide Forever' button. + if ($body.find(skipButton).length > 0) { + cy.get(skipButton).click() + } else { + // Second attempt: As introduced with Joomla 5.1 cancel guided tour with button 'X'. + cy.get(cancelButton).click() + } + }) cy.log('--Cancel Tour--') - } - - Cypress.Commands.add('cancelTour', cancelTour) - - // Skip Tour - const skipTour = () => { - cy.log('**Skip Tour**') - - cy.get('.shepherd-button-secondary', { timeout: 40000 }).should('exist').click() - - cy.log('--Skip Tour--') - } - - Cypress.Commands.add('skipTour', skipTour) + }) /**