From 80265f49e6df9f0f6283b4ef7efbe6d095b63a98 Mon Sep 17 00:00:00 2001 From: George Raduta Date: Thu, 18 Jun 2026 12:42:04 +0200 Subject: [PATCH 1/2] Add warning label instead of start button if environment was running --- .../components/controlEnvironmentPanel.js | 13 +++++++----- Control/test/config/core-grpc.js | 1 + Control/test/public/page-environment-mocha.js | 21 ++++++++++++------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Control/public/pages/Environment/components/controlEnvironmentPanel.js b/Control/public/pages/Environment/components/controlEnvironmentPanel.js index d1b6c37c4..154d3f51e 100644 --- a/Control/public/pages/Environment/components/controlEnvironmentPanel.js +++ b/Control/public/pages/Environment/components/controlEnvironmentPanel.js @@ -28,7 +28,8 @@ import {environmentReadinessStatus} from '../../../common/environment/environmen * @returns {vnode} - panel with actions allowed for the user to apply on the environment */ export const controlEnvironmentPanel = (environmentModel, item, isAllowedToControl = false) => { - const {currentTransition} = item; + const { state, currentTransition } = item; + const { userVars: {run_start_time_ms} } = item; const {model} = environmentModel; const {statusMessage} = environmentReadinessStatus(item, model); return h('.flex-column.justify-center', { @@ -48,10 +49,12 @@ export const controlEnvironmentPanel = (environmentModel, item, isAllowedToContr ]), isAllowedToControl && h('.flex-row.flex-end.g2.items-center', [ statusMessage && h('.danger.flex-end.flex-row.flex-center', statusMessage), - controlButton( - '.btn-success.w-25', environmentModel, item, 'START', 'START_ACTIVITY', 'CONFIGURED', - Boolean(currentTransition) - ), + run_start_time_ms && state !== 'RUNNING' && !currentTransition ? + h('span.warning.text-right#environment_was_in_running_state_once_already', 'Environment was in RUNNING state once already') + : controlButton( + '.btn-success.w-25', environmentModel, item, 'START', 'START_ACTIVITY', 'CONFIGURED', + Boolean(currentTransition) + ), controlButton( '.btn-primary', environmentModel, item, 'CONFIGURE', 'CONFIGURE', '', Boolean(currentTransition) ), // button will not be displayed in any state due to OCTRL-628 diff --git a/Control/test/config/core-grpc.js b/Control/test/config/core-grpc.js index bf289eaa0..bde581b2a 100644 --- a/Control/test/config/core-grpc.js +++ b/Control/test/config/core-grpc.js @@ -58,6 +58,7 @@ const coreGRPCServer = (config) => { break; case 2: // STOP envTest.environment.state = 'CONFIGURED'; + envTest.environment.userVars.run_start_time_ms = '1648121309974'; break; case 3: // CONFIGURE envTest.environment.state = 'CONFIGURED'; diff --git a/Control/test/public/page-environment-mocha.js b/Control/test/public/page-environment-mocha.js index 770408c41..b4feebc1c 100644 --- a/Control/test/public/page-environment-mocha.js +++ b/Control/test/public/page-environment-mocha.js @@ -159,19 +159,26 @@ describe('`pageEnvironment` test-suite', async () => { await waitForTimeout(1000); const configuredState = await page.evaluate(() => window.model.environment.item.payload.state); assert.strictEqual(configuredState, 'CONFIGURED'); - // click RESET + }); + + it('should display warning label for START button in state CONFIGURED', async () => { + await page.waitForSelector('#environment_was_in_running_state_once_already', { timeout: 5000 }); + const startButtonWarning = await page.evaluate(() => document.querySelector('#environment_was_in_running_state_once_already').innerText); + assert.strictEqual(startButtonWarning, 'Environment was in RUNNING state once already'); + }); + + it('should click RESET button to move states (CONFIGURED -> DEPLOYED)', async () => { + // click RESET await page.evaluate(() => document.querySelector('#buttonToRESET').click()); await waitForTimeout(1000); const standbyState = await page.evaluate(() => window.model.environment.item.payload.state); assert.strictEqual(standbyState, 'DEPLOYED'); }); - it('should have one button hidden for START in state DEPLOYED', async () => { - await page.waitForSelector('#buttonToSTART', {timeout: 5000}); - const startButtonTitle = await page.evaluate(() => document.querySelector('#buttonToSTART').title); - const startButtonStyle = await page.evaluate(() => document.querySelector('#buttonToSTART').style); - assert.strictEqual(startButtonTitle, `'START' cannot be used in state 'DEPLOYED'`); - assert.deepStrictEqual(startButtonStyle, {0: 'display'}); + it('should display warning label for START button in state DEPLOYED', async () => { + await page.waitForSelector('#environment_was_in_running_state_once_already', { timeout: 5000 }); + const startButtonWarning = await page.evaluate(() => document.querySelector('#environment_was_in_running_state_once_already').innerText); + assert.strictEqual(startButtonWarning, 'Environment was in RUNNING state once already'); }); it('should have one button hidden for STOP in state DEPLOYED', async () => { From 7538c2b0be37dc6011a362d9c6293d5d0ab3056b Mon Sep 17 00:00:00 2001 From: George Raduta Date: Thu, 18 Jun 2026 13:21:24 +0200 Subject: [PATCH 2/2] Fix ESLINT errors --- .../Environment/components/controlEnvironmentPanel.js | 2 +- Control/test/public/page-environment-mocha.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Control/public/pages/Environment/components/controlEnvironmentPanel.js b/Control/public/pages/Environment/components/controlEnvironmentPanel.js index 154d3f51e..5eb767c1e 100644 --- a/Control/public/pages/Environment/components/controlEnvironmentPanel.js +++ b/Control/public/pages/Environment/components/controlEnvironmentPanel.js @@ -50,7 +50,7 @@ export const controlEnvironmentPanel = (environmentModel, item, isAllowedToContr isAllowedToControl && h('.flex-row.flex-end.g2.items-center', [ statusMessage && h('.danger.flex-end.flex-row.flex-center', statusMessage), run_start_time_ms && state !== 'RUNNING' && !currentTransition ? - h('span.warning.text-right#environment_was_in_running_state_once_already', 'Environment was in RUNNING state once already') + h('span.warning.text-right#start_action_warning', 'Environment was in RUNNING state once already') : controlButton( '.btn-success.w-25', environmentModel, item, 'START', 'START_ACTIVITY', 'CONFIGURED', Boolean(currentTransition) diff --git a/Control/test/public/page-environment-mocha.js b/Control/test/public/page-environment-mocha.js index b4feebc1c..d9c5eea6a 100644 --- a/Control/test/public/page-environment-mocha.js +++ b/Control/test/public/page-environment-mocha.js @@ -162,13 +162,12 @@ describe('`pageEnvironment` test-suite', async () => { }); it('should display warning label for START button in state CONFIGURED', async () => { - await page.waitForSelector('#environment_was_in_running_state_once_already', { timeout: 5000 }); - const startButtonWarning = await page.evaluate(() => document.querySelector('#environment_was_in_running_state_once_already').innerText); + await page.waitForSelector('#start_action_warning', { timeout: 5000 }); + const startButtonWarning = await page.evaluate(() => document.querySelector('#start_action_warning').innerText); assert.strictEqual(startButtonWarning, 'Environment was in RUNNING state once already'); }); it('should click RESET button to move states (CONFIGURED -> DEPLOYED)', async () => { - // click RESET await page.evaluate(() => document.querySelector('#buttonToRESET').click()); await waitForTimeout(1000); const standbyState = await page.evaluate(() => window.model.environment.item.payload.state); @@ -176,8 +175,8 @@ describe('`pageEnvironment` test-suite', async () => { }); it('should display warning label for START button in state DEPLOYED', async () => { - await page.waitForSelector('#environment_was_in_running_state_once_already', { timeout: 5000 }); - const startButtonWarning = await page.evaluate(() => document.querySelector('#environment_was_in_running_state_once_already').innerText); + await page.waitForSelector('#start_action_warning', { timeout: 5000 }); + const startButtonWarning = await page.evaluate(() => document.querySelector('#start_action_warning').innerText); assert.strictEqual(startButtonWarning, 'Environment was in RUNNING state once already'); });