Skip to content

Commit

Permalink
Basic plugin details page
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSurgisonGDS committed Oct 4, 2023
1 parent 6043088 commit 875c4ae
Show file tree
Hide file tree
Showing 14 changed files with 414 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ const path = require('path')
const {
loadTemplatesPage,
managePluginsPagePath,
performPluginAction
performPluginAction,
initiatePluginAction,
provePluginInstalled,
provePluginTemplatesInstalled,
provePluginTemplatesUninstalled
} = require('../plugin-utils')

const panelCompleteQuery = '[aria-live="polite"] #panel-complete'
Expand All @@ -20,7 +24,7 @@ describe('Install and uninstall Local Plugin via UI Test', async () => {
it(`The ${dependentPlugin} plugin will be installed`, () => {
log(`The ${dependentPlugin} plugin templates are not available`)
loadTemplatesPage()
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist')
provePluginTemplatesUninstalled(dependentPlugin)

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

Expand All @@ -33,41 +37,32 @@ describe('Install and uninstall Local Plugin via UI Test', async () => {
.should('be.visible')
cy.get('a').contains('Back to plugins').click()

cy.get('#installed-plugins-link').click()

cy.get(`[data-plugin-package-name="${dependentPlugin}"] button`).contains('Uninstall')
provePluginInstalled(dependentPlugin, dependentPluginName)

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

log(`The ${dependentPlugin} plugin templates are available`)
cy.get('a').contains('Templates').click()
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('exist')
provePluginTemplatesInstalled(dependentPlugin)

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

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)

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

log(`The ${dependentPlugin} plugin templates are not available`)
cy.get('a').contains('Templates').click()
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist')
provePluginTemplatesUninstalled(dependentPlugin)
})

it(`The ${dependentPlugin} plugin and ${dependencyPlugin} will be installed`, () => {
log(`The ${dependentPlugin} plugin templates are not available`)
loadTemplatesPage()
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist')
provePluginTemplatesUninstalled(dependentPlugin)

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

Expand All @@ -91,7 +86,7 @@ describe('Install and uninstall Local Plugin via UI Test', async () => {

log(`The ${dependentPlugin} plugin templates are available`)
cy.get('a').contains('Templates').click()
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('exist')
provePluginTemplatesInstalled(dependentPlugin)

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

Expand All @@ -107,6 +102,6 @@ describe('Install and uninstall Local Plugin via UI Test', async () => {

log(`The ${dependentPlugin} plugin templates are not available`)
cy.get('a').contains('Templates').click()
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist')
provePluginTemplatesUninstalled(dependentPlugin)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ const {
loadTemplatesPage,
loadPluginsPage,
manageTemplatesPagePath,
manageInstalledPluginsPagePath
provePluginInstalled,
provePluginUninstalled,
performPluginAction,
initiatePluginAction,
provePluginTemplatesUninstalled,
provePluginTemplatesInstalled
} = require('../plugin-utils')

const panelCompleteQuery = '[aria-live="polite"] #panel-complete'
Expand All @@ -18,7 +23,7 @@ async function installPluginTests ({ plugin, templates, version }) {
log(`The ${plugin} plugin templates are not available`)
uninstallPlugin(plugin)
loadTemplatesPage()
cy.get(`[data-plugin-package-name="${plugin}"]`).should('not.exist')
provePluginTemplatesUninstalled(plugin)

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

Expand All @@ -30,22 +35,23 @@ async function installPluginTests ({ plugin, templates, version }) {
cy.get('#plugin-action-button').click()
} else {
loadPluginsPage()
provePluginUninstalled(plugin)
log(`Install the ${plugin} plugin`)
cy.get(`[data-plugin-package-name="${plugin}"] button`).contains('Install').click()
performPluginAction('install', plugin)
}

cy.get(panelCompleteQuery, { timeout: 20000 })
.should('be.visible')
cy.get('a').contains('Back to plugins').click()

cy.get('#installed-plugins-link').click()
cy.get(`[data-plugin-package-name="${plugin}"] button`).contains('Uninstall')
provePluginInstalled(plugin)

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

log(`The ${plugin} plugin templates are available`)
cy.get('a').contains('Templates').click()
cy.get(`[data-plugin-package-name="${plugin}"]`).should('exist')

provePluginTemplatesInstalled(plugin)

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

Expand All @@ -59,15 +65,11 @@ async function installPluginTests ({ plugin, templates, version }) {
// ------------------------

log(`Uninstall the ${plugin} plugin`)
cy.visit(manageInstalledPluginsPagePath)

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

cy.get(panelCompleteQuery, { timeout: 20000 })
.should('be.visible')
cy.get('a').contains('Back to plugins').click()
initiatePluginAction('uninstall', plugin)

cy.get(`[data-plugin-package-name="${plugin}"] button`).contains('Install')
provePluginUninstalled(plugin)
})
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const {
getTemplateLink,
loadInstalledPluginsPage,
loadPluginsPage,
manageInstalledPluginsPagePath
manageInstalledPluginsPagePath,
initiatePluginAction,
provePluginUpdated
} = require('../plugin-utils')
const { showHideAllLinkQuery, assertVisible, assertHidden } = require('../../step-by-step-utils')

Expand Down Expand Up @@ -93,14 +95,8 @@ 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)
provePluginUpdated(plugin)
})

it(`Create a page using a template from the ${plugin} plugin`, () => {
Expand Down Expand Up @@ -134,14 +130,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 +139,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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { waitForApplication, uninstallPlugin, restoreStarterFiles } = require('../../utils')
const { provePluginTemplatesInstalled } = require('../plugin-utils')

const manageTemplatesPagePath = '/manage-prototype/templates'
const panelCompleteQuery = '[aria-live="polite"] #panel-complete'
Expand All @@ -25,7 +26,7 @@ describe('Install common templates from templates page', () => {

cy.get('a').contains('Back to templates').click()

cy.get(`[data-plugin-package-name="${plugin}"]`).contains('Common Templates')
provePluginTemplatesInstalled(plugin)

cy.get('a.govuk-button').should('not.exist')
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
const { replaceInFile, waitForApplication, restoreStarterFiles, log } = require('../../utils')
const {
replaceInFile,
waitForApplication,
restoreStarterFiles,
log
} = require('../../utils')
const path = require('path')
const {
provePluginUninstalled,
provePluginInstalledOldVersion
} = require('../plugin-utils')
const plugin = '@govuk-prototype-kit/task-list'
const pluginVersion = '1.1.1'
const originalText = '"dependencies": {'
Expand All @@ -18,11 +27,7 @@ describe('Handle a plugin installation mismatch', () => {

log(`Make sure ${plugin} is displayed as not installed`)
cy.visit(pluginsPage)

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

log('Force the plugins to be installed with an npm install')
cy.exec(`cd ${Cypress.env('projectFolder')} && npm install`)
Expand All @@ -31,10 +36,6 @@ describe('Handle a plugin installation mismatch', () => {
waitForApplication()
cy.visit(pluginsPage)

cy.get('#installed-plugins-link').click()
cy.get(`[data-plugin-package-name="${plugin}"]`)
.scrollIntoView()
.find('button')
.contains('Uninstall')
provePluginInstalledOldVersion(plugin)
})
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import { installPlugin, restoreStarterFiles, uninstallPlugin, waitForApplication } from '../../utils'
import path from 'path'

import {
installPlugin,
restoreStarterFiles,
uninstallPlugin,
waitForApplication
} from '../../utils'

import {
initiatePluginAction,
provePluginInstalled,
provePluginUninstalled
} from '../plugin-utils'

const plugin = '@govuk-prototype-kit/common-templates'
const pluginVersion = '1.1.1'
const pluginsPage = '/manage-prototype/plugins'
Expand Down Expand Up @@ -30,39 +42,19 @@ describe('Handle a plugin update', () => {

waitForApplication(pluginsPage)

cy.get('[data-plugin-group-status="search"]')
.find(`[data-plugin-package-name="${dependencyPlugin}"]`)
.find('button')
.contains('Install')

cy.get('#installed-plugins-link').click()

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

cy.get('#plugin-action-confirmation')
.find('ul')
.contains(dependencyPluginName)

cy.get('#plugin-action-button').click()

cy.get('#panel-complete', { timeout: 20000 })
.should('be.visible')
.contains('Update complete')

cy.get('#instructions-complete a')
.contains('Back to plugins')
.click()
provePluginUninstalled(dependencyPlugin)

cy.get('#installed-plugins-link').click()
initiatePluginAction('update', plugin, null, {
confirmation: () => {
cy.get('#plugin-action-confirmation')
.find('ul')
.contains(dependencyPluginName)

cy.get('[data-plugin-group-status="installed"]')
.find(`[data-plugin-package-name="${dependencyPlugin}"]`)
cy.get('#plugin-action-button').click()
}
})

cy.get('[data-plugin-group-status="installed"]')
.find(`[data-plugin-package-name="${plugin}"]`)
provePluginInstalled(plugin)
provePluginInstalled(dependencyPlugin, dependencyPluginName)
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const { managePluginsPagePath, performPluginAction } = require('../plugin-utils')
const {
managePluginsPagePath,
performPluginAction,
provePluginInstalled,
provePluginUninstalled,
initiatePluginAction
} = require('../plugin-utils')
const { uninstallPlugin, restoreStarterFiles } = require('../../utils')

const plugin = 'govuk-frontend'
Expand All @@ -21,9 +27,8 @@ describe('Manage prototype pages without govuk-frontend', () => {
performPluginAction('uninstall', plugin, pluginName)

cy.task('log', 'Make sure govuk-frontend is uninstalled')
cy.get(`[data-plugin-package-name="${plugin}"]`)
.find('button')
.contains('Install')

provePluginUninstalled(plugin)

cy.task('log', 'Test home page')
cy.get('a').contains('Home').click()
Expand All @@ -39,19 +44,10 @@ describe('Manage prototype pages without govuk-frontend', () => {

cy.task('log', `Install the ${plugin} plugin`)

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

performPluginAction('install', plugin, pluginName)

cy.get('#installed-plugins-link').click()
initiatePluginAction('install', plugin, pluginName)

cy.task('log', 'Make sure govuk-frontend is installed')
cy.get(`[data-plugin-package-name="${plugin}"]`)
.find('button')
.contains('Uninstall')

provePluginInstalled(plugin, pluginName)
})
})
Loading

0 comments on commit 875c4ae

Please sign in to comment.