-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2220 from alphagov/2125-allow-plugin-developers-t…
…o-specify-that-their-plugin-is-dependent-on-other-plugins Specify plugin dependencies
- Loading branch information
Showing
28 changed files
with
1,355 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
cypress/e2e/plugins/0-mock-plugin-tests/install-plugin-via-ui-test.cypress.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
const { installPlugin, uninstallPlugin } = require('../../utils') | ||
const path = require('path') | ||
const { loadTemplatesPage, managePluginsPagePath, performPluginAction, loadPluginsPage } = require('../plugin-utils') | ||
|
||
const panelCompleteQuery = '[aria-live="polite"] #panel-complete' | ||
const fixtures = path.join(Cypress.config('fixturesFolder')) | ||
const dependentPlugin = 'plugin-fee' | ||
const dependentPluginName = 'Plugin Fee' | ||
const dependentPluginLocation = path.join(fixtures, 'plugins', dependentPlugin) | ||
const dependencyPlugin = 'govuk-frontend' | ||
const dependencyPluginName = 'GOV.UK Frontend' | ||
|
||
function restore () { | ||
installPlugin(dependencyPlugin) | ||
uninstallPlugin(dependentPlugin) | ||
} | ||
|
||
describe('Install and uninstall Local Plugin via UI Test', async () => { | ||
before(restore) | ||
after(restore) | ||
|
||
it(`The ${dependentPlugin} plugin templates are not available`, () => { | ||
loadTemplatesPage() | ||
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist') | ||
}) | ||
|
||
it(`Install the ${dependentPlugin} plugin`, () => { | ||
cy.task('waitUntilAppRestarts') | ||
cy.visit(`${managePluginsPagePath}/install?package=${encodeURIComponent(dependentPlugin)}&version=${encodeURIComponent(dependentPluginLocation)}`) | ||
cy.get('#plugin-action-button').click() | ||
|
||
cy.get(panelCompleteQuery, { timeout: 20000 }) | ||
.should('be.visible') | ||
cy.get('a').contains('Back to plugins').click() | ||
|
||
cy.get(`[data-plugin-package-name="${dependentPlugin}"] button`).contains('Uninstall') | ||
}) | ||
|
||
it(`The ${dependentPlugin} plugin templates are available`, () => { | ||
loadTemplatesPage() | ||
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('exist') | ||
}) | ||
|
||
it('Uninstall the local plugin', () => { | ||
loadPluginsPage() | ||
|
||
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`) | ||
.scrollIntoView() | ||
.find('button') | ||
.contains('Uninstall') | ||
.click() | ||
|
||
performPluginAction('uninstall', dependentPlugin, dependentPluginName) | ||
}) | ||
|
||
it(`The ${dependentPlugin} plugin templates are not available`, () => { | ||
loadTemplatesPage() | ||
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist') | ||
}) | ||
}) | ||
|
||
describe('Install and uninstall Local Dependent Plugin via UI Test', async () => { | ||
before(restore) | ||
after(restore) | ||
|
||
it(`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`, () => { | ||
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}`, () => { | ||
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() | ||
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('exist') | ||
}) | ||
|
||
it('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() | ||
cy.get(`[data-plugin-package-name="${dependentPlugin}"]`).should('not.exist') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
cypress/fixtures/plugins/plugin-fee/govuk-prototype-kit.config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"templates": [ | ||
{ | ||
"name": "Plugin Fee page", | ||
"path": "/templates/fee.njk", | ||
"type": "nunjucks" | ||
} | ||
], | ||
"sass": "/sass/fee.scss", | ||
"pluginDependencies": [{ | ||
"packageName": "govuk-frontend", | ||
"minVersion": "4.5.0" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "plugin-fee", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"govuk-prototype-kit": "file:../../../.." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.plugin-fee-paragraph { | ||
background: #d4351c; | ||
color: #ffdd00; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% extends "layouts/main.html" %} | ||
|
||
{% block pageTitle %} | ||
GOV.UK page template – {{ serviceName }} – GOV.UK Prototype Kit | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<p class="plugin-fee-paragraph">Plugin fee styled paragraph</p> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.