@@ -3,6 +3,7 @@ import myEformsPage from '../../Page objects/MyEforms.page';
33import pluginPage from '../../Page objects/Plugin.page' ;
44
55import { expect } from 'chai' ;
6+ import { $ } from '@wdio/globals' ;
67
78describe ( 'Application settings page - site header section' , function ( ) {
89 before ( async ( ) => {
@@ -17,47 +18,104 @@ describe('Application settings page - site header section', function () {
1718 } ) ;
1819
1920 it ( 'should activate the plugin' , async ( ) => {
20- let plugin = await pluginPage . getFirstPluginRowObj ( ) ;
21- for ( let i = 1 ; i < 10 ; i ++ ) {
21+ // Helper function to activate a plugin by index using action menu
22+ const activatePlugin = async ( index : number , pluginName : string ) => {
23+ // Open action menu
24+ const actionMenuBtn = await $ ( `#action-items-${ index } ` ) . $ ( '#actionMenu' ) ;
25+ await actionMenuBtn . waitForDisplayed ( { timeout : 40000 } ) ;
26+ await actionMenuBtn . waitForClickable ( { timeout : 40000 } ) ;
27+ await actionMenuBtn . click ( ) ;
28+ await browser . pause ( 500 ) ;
29+
30+ // Click on the status button inside the menu
31+ const statusBtn = await $ ( `#plugin-status-button${ index } ` ) ;
32+ await statusBtn . waitForDisplayed ( { timeout : 40000 } ) ;
33+ await statusBtn . waitForClickable ( { timeout : 40000 } ) ;
34+ await statusBtn . click ( ) ;
35+ await browser . pause ( 500 ) ;
36+
37+ // Confirm activation in the modal
38+ const pluginOKBtn = await $ ( '#pluginOKBtn' ) ;
39+ await pluginOKBtn . waitForDisplayed ( { timeout : 40000 } ) ;
40+ await pluginOKBtn . click ( ) ;
41+ await browser . pause ( 100000 ) ; // We need to wait 100 seconds for the plugin to create db etc.
42+
43+ // Re-login and navigate back to plugins page
44+ await loginPage . open ( '/' ) ;
45+ await loginPage . login ( ) ;
46+ await myEformsPage . Navbar . goToPluginsPage ( ) ;
47+ await browser . pause ( 500 ) ;
48+ } ;
49+
50+ // Helper function to check plugin status via action menu
51+ const checkPluginStatus = async ( index : number , expectedStatus : string , pluginName : string ) => {
52+ // Open action menu
53+ const actionMenuBtn = await $ ( `#action-items-${ index } ` ) . $ ( '#actionMenu' ) ;
54+ await actionMenuBtn . waitForDisplayed ( { timeout : 40000 } ) ;
55+ await actionMenuBtn . waitForClickable ( { timeout : 40000 } ) ;
56+ await actionMenuBtn . click ( ) ;
57+ await browser . pause ( 500 ) ;
58+
59+ // Check status
60+ const statusBtn = await $ ( `#plugin-status-button${ index } ` ) ;
61+ await statusBtn . waitForDisplayed ( { timeout : 40000 } ) ;
62+ const statusIcon = await statusBtn . $ ( 'mat-icon' ) ;
63+ const status = await statusIcon . getText ( ) ;
64+ expect ( status , `${ pluginName } status is not ${ expectedStatus } ` ) . eq ( expectedStatus ) ;
65+
66+ // Close the menu
67+ await browser . keys ( [ 'Escape' ] ) ;
68+ await browser . pause ( 300 ) ;
69+ } ;
70+
71+ // Find and activate Microting Items Planning Plugin
72+ for ( let i = 0 ; i < 10 ; i ++ ) {
2273 const plugin = await pluginPage . getPluginRowObjByIndex ( i ) ;
2374 if ( plugin . name === 'Microting Items Planning Plugin' ) {
24- await plugin . enableOrDisablePlugin ( ) ;
75+ await activatePlugin ( i , plugin . name ) ;
2576 break ;
2677 }
2778 }
28- for ( let i = 1 ; i < 10 ; i ++ ) {
79+
80+ // Find and activate Microting Time Planning Plugin
81+ for ( let i = 0 ; i < 10 ; i ++ ) {
2982 const plugin = await pluginPage . getPluginRowObjByIndex ( i ) ;
3083 if ( plugin . name === 'Microting Time Planning Plugin' ) {
31- await plugin . enableOrDisablePlugin ( ) ;
84+ await activatePlugin ( i , plugin . name ) ;
3285 break ;
3386 }
3487 }
35- for ( let i = 1 ; i < 10 ; i ++ ) {
88+
89+ // Find and activate Microting Backend Configuration Plugin
90+ for ( let i = 0 ; i < 10 ; i ++ ) {
3691 const plugin = await pluginPage . getPluginRowObjByIndex ( i ) ;
3792 if ( plugin . name === 'Microting Backend Configuration Plugin' ) {
38- await plugin . enableOrDisablePlugin ( ) ;
93+ await activatePlugin ( i , plugin . name ) ;
3994 break ;
4095 }
4196 }
4297
43- for ( let i = 1 ; i < 10 ; i ++ ) {
98+ // Verify all plugins are activated
99+ for ( let i = 0 ; i < 10 ; i ++ ) {
44100 const plugin = await pluginPage . getPluginRowObjByIndex ( i ) ;
45101 if ( plugin . name === 'Microting Items Planning Plugin' ) {
46- expect ( plugin . status , 'Microting Items Planning Plugin is not enabled' ) . eq ( ' toggle_on') ;
102+ await checkPluginStatus ( i , 'toggle_on' , plugin . name ) ;
47103 break ;
48104 }
49105 }
50- for ( let i = 1 ; i < 10 ; i ++ ) {
106+
107+ for ( let i = 0 ; i < 10 ; i ++ ) {
51108 const plugin = await pluginPage . getPluginRowObjByIndex ( i ) ;
52109 if ( plugin . name === 'Microting Time Planning Plugin' ) {
53- expect ( plugin . status , 'Microting Time Planning Plugin is not enabled' ) . eq ( ' toggle_on') ;
110+ await checkPluginStatus ( i , 'toggle_on' , plugin . name ) ;
54111 break ;
55112 }
56113 }
57- for ( let i = 1 ; i < 10 ; i ++ ) {
114+
115+ for ( let i = 0 ; i < 10 ; i ++ ) {
58116 const plugin = await pluginPage . getPluginRowObjByIndex ( i ) ;
59117 if ( plugin . name === 'Microting Backend Configuration Plugin' ) {
60- expect ( plugin . status , 'Microting Backend Configuration Plugin is not enabled' ) . eq ( ' toggle_on') ;
118+ await checkPluginStatus ( i , 'toggle_on' , plugin . name ) ;
61119 break ;
62120 }
63121 }
0 commit comments