Skip to content

Commit

Permalink
Include details page within tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSurgisonGDS committed Oct 3, 2023
1 parent 7b2a55b commit 711c13e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const path = require('path')
const {
loadTemplatesPage,
managePluginsPagePath,
performPluginAction
performPluginAction,
initiatePluginAction
} = require('../plugin-utils')

const panelCompleteQuery = '[aria-live="polite"] #panel-complete'
Expand Down Expand Up @@ -47,15 +48,8 @@ describe('Install and uninstall Local Plugin via UI Test', async () => {

log('Uninstall the local plugin')
cy.get('a').contains('Plugins').click()
cy.get('#installed-plugins-link').click()

cy.get(`[data-plugin-package-name="${dependentPlugin}"]`)
.scrollIntoView()
.find('button')
.contains('Uninstall')
.click()

performPluginAction('uninstall', dependentPlugin, dependentPluginName)
initiatePluginAction('uninstall', dependentPlugin, dependentPluginName)

// ------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const {
getTemplateLink,
loadInstalledPluginsPage,
loadPluginsPage,
manageInstalledPluginsPagePath
manageInstalledPluginsPagePath,
initiatePluginAction
} = require('../plugin-utils')
const { showHideAllLinkQuery, assertVisible, assertHidden } = require('../../step-by-step-utils')

Expand Down Expand Up @@ -93,14 +94,7 @@ describe('Management plugins: ', () => {

loadInstalledPluginsPage()
log(`Update the ${plugin} plugin`)

cy.get(`[data-plugin-package-name="${plugin}"]`)
.scrollIntoView()
.find('button')
.contains('Update')
.click()

performPluginAction('update', plugin, pluginName)
initiatePluginAction('update', plugin, pluginName)
})

it(`Create a page using a template from the ${plugin} plugin`, () => {
Expand Down Expand Up @@ -134,14 +128,7 @@ describe('Management plugins: ', () => {
log(`Uninstall the ${plugin} plugin`)

cy.visit(manageInstalledPluginsPagePath)

cy.get(`[data-plugin-package-name="${plugin}"]`)
.scrollIntoView()
.find('button')
.contains('Uninstall')
.click()

performPluginAction('uninstall', plugin, pluginName)
initiatePluginAction('uninstall', plugin, pluginName)

provePluginFunctionalityFails()

Expand All @@ -150,14 +137,7 @@ describe('Management plugins: ', () => {
log(`Reinstall the ${plugin} plugin`)

cy.visit(managePluginsPagePath)

cy.get(`[data-plugin-package-name="${plugin}"]`)
.scrollIntoView()
.find('button')
.contains('Install')
.click()

performPluginAction('install', plugin, pluginName)
initiatePluginAction('install', plugin, pluginName)

provePluginFunctionalityWorks()
})
Expand Down
15 changes: 15 additions & 0 deletions cypress/e2e/plugins/plugin-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ async function loadTemplatesPage () {
await waitForApplication(manageTemplatesPagePath)
}

function initiatePluginAction (action, plugin, pluginName) {
cy.get(`[data-plugin-package-name="${plugin}"]`)
.scrollIntoView()
.find('a')
.contains(pluginName)
.click()

cy.get('button')
.contains(capitalize(action))
.click()

performPluginAction(action, plugin, pluginName)
}

function performPluginAction (action, plugin, pluginName) {
cy.task('log', `The ${plugin} plugin should be displayed`)
cy.get('h2')
Expand Down Expand Up @@ -105,6 +119,7 @@ module.exports = {
loadInstalledPluginsPage,
loadTemplatesPage,
getTemplateLink,
initiatePluginAction,
performPluginAction,
failAction
}
2 changes: 1 addition & 1 deletion lib/nunjucks/views/manage-prototype/plugin-details.njk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
attributes: { id: "update-" + packageName, formaction: updateLink }
}) }}
{% endif %}
{% if plugin.uninstallLink %}
{% if uninstallLink %}
{{ govukButton({
html: 'Uninstall <span class="govuk-visually-hidden"> ' + plugin.name + '</span>',
classes: "govuk-button--secondary",
Expand Down

0 comments on commit 711c13e

Please sign in to comment.