Skip to content

Commit

Permalink
Build the enhanced plugin page
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSurgisonGDS committed Aug 25, 2023
1 parent 6901834 commit 965711c
Show file tree
Hide file tree
Showing 16 changed files with 449 additions and 240 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

name: Acceptance ${{ matrix.type }} test kit on Node v${{ matrix.node-version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 25
timeout-minutes: 30

env:
CYPRESS_CACHE_FOLDER: ~/.cache/Cypress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { restoreStarterFiles } = require('../../utils')
const { restoreStarterFiles, log } = require('../../utils')
const path = require('path')
const {
loadTemplatesPage,
managePluginsPagePath,
performPluginAction,
loadPluginsPage
performPluginAction
} = require('../plugin-utils')

const panelCompleteQuery = '[aria-live="polite"] #panel-complete'
Expand All @@ -16,14 +15,16 @@ const dependencyPlugin = 'govuk-frontend'
const dependencyPluginName = 'GOV.UK Frontend'

describe('Install and uninstall Local Plugin via UI Test', async () => {
after(restoreStarterFiles)
afterEach(restoreStarterFiles)

it(`The ${dependentPlugin} plugin templates are not available`, () => {
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')
})

it(`Install the ${dependentPlugin} plugin`, () => {
// ------------------------

log(`Install the ${dependentPlugin} plugin`)
cy.task('waitUntilAppRestarts')
cy.visit(`${managePluginsPagePath}/install?package=${encodeURIComponent(dependentPlugin)}&version=${encodeURIComponent(dependentPluginLocation)}`)
cy.get('#plugin-action-button').click()
Expand All @@ -32,16 +33,21 @@ 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')
})

it(`The ${dependentPlugin} plugin templates are available`, () => {
loadTemplatesPage()
// ------------------------

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

it('Uninstall the local plugin', () => {
loadPluginsPage()
// ------------------------

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()
Expand All @@ -50,54 +56,57 @@ describe('Install and uninstall Local Plugin via UI Test', async () => {
.click()

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

it(`The ${dependentPlugin} plugin templates are not available`, () => {
loadTemplatesPage()
// ------------------------

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

describe('Install and uninstall Local Dependent Plugin via UI Test', async () => {
after(restoreStarterFiles)

it(`The ${dependentPlugin} plugin templates are not available`, () => {
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')
})

it(`Uninstall the ${dependencyPlugin} to force the UI to ask for it later`, () => {
// ------------------------

log(`Uninstall the ${dependencyPlugin} to force the UI to ask for it later`)
cy.task('waitUntilAppRestarts')
cy.visit(`${managePluginsPagePath}/uninstall?package=${encodeURIComponent(dependencyPlugin)}`)
cy.get('#plugin-action-button').click()
performPluginAction('uninstall', dependencyPlugin, dependencyPluginName)
})

it(`Install the ${dependentPlugin} plugin and the ${dependencyPlugin}`, () => {
// ------------------------

log(`Install the ${dependentPlugin} plugin and the ${dependencyPlugin}`)
cy.task('waitUntilAppRestarts')
cy.visit(`${managePluginsPagePath}/install?package=${encodeURIComponent(dependentPlugin)}&version=${encodeURIComponent(dependentPluginLocation)}`)
// Should list the dependency plugin
cy.get('li').contains(dependencyPluginName)
cy.get('#plugin-action-button').click()
performPluginAction('install', dependentPlugin, dependentPluginName)
})

it(`The ${dependentPlugin} plugin templates are available`, () => {
loadTemplatesPage()
// ------------------------

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

it('Uninstall the dependency plugin', () => {
// ------------------------

log('Uninstall the dependency plugin')
cy.task('waitUntilAppRestarts')
cy.visit(`${managePluginsPagePath}/uninstall?package=${encodeURIComponent(dependencyPlugin)}`)
// Should list the dependent plugin
cy.get('li').contains(dependentPluginName)
cy.get('#plugin-action-button').click()
performPluginAction('uninstall', dependencyPlugin, dependencyPluginName)
})

it(`The ${dependentPlugin} plugin templates are not available`, () => {
loadTemplatesPage()
// ------------------------

log(`The ${dependentPlugin} plugin templates are not available`)
cy.get('a').contains('Templates').click()
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist')
})
})
Original file line number Diff line number Diff line change
@@ -1,54 +1,66 @@
// local dependencies
const { uninstallPlugin, restoreStarterFiles } = require('../../utils')
const { managePluginsPagePath, loadTemplatesPage, loadPluginsPage } = require('../plugin-utils')
const { uninstallPlugin, restoreStarterFiles, log } = require('../../utils')
const {
managePluginsPagePath,
loadTemplatesPage,
loadPluginsPage,
manageTemplatesPagePath,
manageInstalledPluginsPagePath
} = require('../plugin-utils')

const panelCompleteQuery = '[aria-live="polite"] #panel-complete'

async function installPluginTests ({ plugin, templates, version }) {
describe(plugin, () => {
after(restoreStarterFiles)

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

it(`Install the ${plugin} plugin`, () => {
// ------------------------

log(`Install the ${plugin} plugin`)
if (version) {
cy.task('waitUntilAppRestarts')
cy.visit(`${managePluginsPagePath}/install?package=${encodeURIComponent(plugin)}&version=${version}`)

cy.get('#plugin-action-button').click()
} else {
loadPluginsPage()
cy.task('log', `Install the ${plugin} plugin`)
log(`Install the ${plugin} plugin`)
cy.get(`[data-plugin-package-name="${plugin}"] button`).contains('Install').click()
}

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')
})

it(`The ${plugin} plugin templates are available`, () => {
loadTemplatesPage()
// ------------------------

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

templates.forEach(({ name, filename }) => {
it(`View ${name} template`, () => {
loadTemplatesPage()
// ------------------------

templates.forEach(({ name, filename }) => {
log(`View ${name} template`)
cy.visit(manageTemplatesPagePath)
cy.get(`[data-plugin-package-name="${plugin}"] a`).contains(`View ${name} page`).click()
cy.url().then(url => expect(url).to.contain(filename))
})
})

it(`Uninstall the ${plugin} plugin`, () => {
loadPluginsPage()
cy.task('log', `Uninstall the ${plugin} plugin`)
// ------------------------

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

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

cy.get(panelCompleteQuery, { timeout: 20000 })
Expand Down
Loading

0 comments on commit 965711c

Please sign in to comment.