1- const { restoreStarterFiles } = require ( '../../utils' )
1+ const { restoreStarterFiles, log } = require ( '../../utils' )
22const path = require ( 'path' )
33const {
44 loadTemplatesPage,
55 managePluginsPagePath,
6- performPluginAction,
7- loadPluginsPage
6+ performPluginAction
87} = require ( '../plugin-utils' )
98
109const panelCompleteQuery = '[aria-live="polite"] #panel-complete'
@@ -16,14 +15,16 @@ const dependencyPlugin = 'govuk-frontend'
1615const dependencyPluginName = 'GOV.UK Frontend'
1716
1817describe ( 'Install and uninstall Local Plugin via UI Test' , async ( ) => {
19- after ( restoreStarterFiles )
18+ afterEach ( restoreStarterFiles )
2019
21- it ( `The ${ dependentPlugin } plugin templates are not available` , ( ) => {
20+ it ( `The ${ dependentPlugin } plugin will be installed` , ( ) => {
21+ log ( `The ${ dependentPlugin } plugin templates are not available` )
2222 loadTemplatesPage ( )
2323 cy . get ( `[data-plugin-package-name="${ dependentPlugin } "]` ) . should ( 'not.exist' )
24- } )
2524
26- it ( `Install the ${ dependentPlugin } plugin` , ( ) => {
25+ // ------------------------
26+
27+ log ( `Install the ${ dependentPlugin } plugin` )
2728 cy . task ( 'waitUntilAppRestarts' )
2829 cy . visit ( `${ managePluginsPagePath } /install?package=${ encodeURIComponent ( dependentPlugin ) } &version=${ encodeURIComponent ( dependentPluginLocation ) } ` )
2930 cy . get ( '#plugin-action-button' ) . click ( )
@@ -32,16 +33,21 @@ describe('Install and uninstall Local Plugin via UI Test', async () => {
3233 . should ( 'be.visible' )
3334 cy . get ( 'a' ) . contains ( 'Back to plugins' ) . click ( )
3435
36+ cy . get ( '#installed-plugins-link' ) . click ( )
37+
3538 cy . get ( `[data-plugin-package-name="${ dependentPlugin } "] button` ) . contains ( 'Uninstall' )
36- } )
3739
38- it ( `The ${ dependentPlugin } plugin templates are available` , ( ) => {
39- loadTemplatesPage ( )
40+ // ------------------------
41+
42+ log ( `The ${ dependentPlugin } plugin templates are available` )
43+ cy . get ( 'a' ) . contains ( 'Templates' ) . click ( )
4044 cy . get ( `[data-plugin-package-name="${ dependentPlugin } "]` ) . should ( 'exist' )
41- } )
4245
43- it ( 'Uninstall the local plugin' , ( ) => {
44- loadPluginsPage ( )
46+ // ------------------------
47+
48+ log ( 'Uninstall the local plugin' )
49+ cy . get ( 'a' ) . contains ( 'Plugins' ) . click ( )
50+ cy . get ( '#installed-plugins-link' ) . click ( )
4551
4652 cy . get ( `[data-plugin-package-name="${ dependentPlugin } "]` )
4753 . scrollIntoView ( )
@@ -50,54 +56,57 @@ describe('Install and uninstall Local Plugin via UI Test', async () => {
5056 . click ( )
5157
5258 performPluginAction ( 'uninstall' , dependentPlugin , dependentPluginName )
53- } )
5459
55- it ( `The ${ dependentPlugin } plugin templates are not available` , ( ) => {
56- loadTemplatesPage ( )
60+ // ------------------------
61+
62+ log ( `The ${ dependentPlugin } plugin templates are not available` )
63+ cy . get ( 'a' ) . contains ( 'Templates' ) . click ( )
5764 cy . get ( `[data-plugin-package-name="${ dependentPlugin } "]` ) . should ( 'not.exist' )
5865 } )
59- } )
60-
61- describe ( 'Install and uninstall Local Dependent Plugin via UI Test' , async ( ) => {
62- after ( restoreStarterFiles )
6366
64- it ( `The ${ dependentPlugin } plugin templates are not available` , ( ) => {
67+ it ( `The ${ dependentPlugin } plugin and ${ dependencyPlugin } will be installed` , ( ) => {
68+ log ( `The ${ dependentPlugin } plugin templates are not available` )
6569 loadTemplatesPage ( )
6670 cy . get ( `[data-plugin-package-name="${ dependentPlugin } "]` ) . should ( 'not.exist' )
67- } )
6871
69- it ( `Uninstall the ${ dependencyPlugin } to force the UI to ask for it later` , ( ) => {
72+ // ------------------------
73+
74+ log ( `Uninstall the ${ dependencyPlugin } to force the UI to ask for it later` )
7075 cy . task ( 'waitUntilAppRestarts' )
7176 cy . visit ( `${ managePluginsPagePath } /uninstall?package=${ encodeURIComponent ( dependencyPlugin ) } ` )
7277 cy . get ( '#plugin-action-button' ) . click ( )
7378 performPluginAction ( 'uninstall' , dependencyPlugin , dependencyPluginName )
74- } )
7579
76- it ( `Install the ${ dependentPlugin } plugin and the ${ dependencyPlugin } ` , ( ) => {
80+ // ------------------------
81+
82+ log ( `Install the ${ dependentPlugin } plugin and the ${ dependencyPlugin } ` )
7783 cy . task ( 'waitUntilAppRestarts' )
7884 cy . visit ( `${ managePluginsPagePath } /install?package=${ encodeURIComponent ( dependentPlugin ) } &version=${ encodeURIComponent ( dependentPluginLocation ) } ` )
7985 // Should list the dependency plugin
8086 cy . get ( 'li' ) . contains ( dependencyPluginName )
8187 cy . get ( '#plugin-action-button' ) . click ( )
8288 performPluginAction ( 'install' , dependentPlugin , dependentPluginName )
83- } )
8489
85- it ( `The ${ dependentPlugin } plugin templates are available` , ( ) => {
86- loadTemplatesPage ( )
90+ // ------------------------
91+
92+ log ( `The ${ dependentPlugin } plugin templates are available` )
93+ cy . get ( 'a' ) . contains ( 'Templates' ) . click ( )
8794 cy . get ( `[data-plugin-package-name="${ dependentPlugin } "]` ) . should ( 'exist' )
88- } )
8995
90- it ( 'Uninstall the dependency plugin' , ( ) => {
96+ // ------------------------
97+
98+ log ( 'Uninstall the dependency plugin' )
9199 cy . task ( 'waitUntilAppRestarts' )
92100 cy . visit ( `${ managePluginsPagePath } /uninstall?package=${ encodeURIComponent ( dependencyPlugin ) } ` )
93101 // Should list the dependent plugin
94102 cy . get ( 'li' ) . contains ( dependentPluginName )
95103 cy . get ( '#plugin-action-button' ) . click ( )
96104 performPluginAction ( 'uninstall' , dependencyPlugin , dependencyPluginName )
97- } )
98105
99- it ( `The ${ dependentPlugin } plugin templates are not available` , ( ) => {
100- loadTemplatesPage ( )
106+ // ------------------------
107+
108+ log ( `The ${ dependentPlugin } plugin templates are not available` )
109+ cy . get ( 'a' ) . contains ( 'Templates' ) . click ( )
101110 cy . get ( `[data-plugin-package-name="${ dependentPlugin } "]` ) . should ( 'not.exist' )
102111 } )
103112} )
0 commit comments