diff --git a/src/Microsoft.PowerApps.TestEngine/Config/TestSettings.cs b/src/Microsoft.PowerApps.TestEngine/Config/TestSettings.cs
index 15e32f262..e67419a69 100644
--- a/src/Microsoft.PowerApps.TestEngine/Config/TestSettings.cs
+++ b/src/Microsoft.PowerApps.TestEngine/Config/TestSettings.cs
@@ -67,5 +67,12 @@ public class TestSettings
/// Define settings for Test Engine Extensions
///
public TestSettingExtensions ExtensionModules { get; set; } = new TestSettingExtensions();
+
+ ///
+ /// Gets or sets whether preview functions are enabled.
+ /// Default is false.
+ /// If set to true, preview functions like Pause() are available for use.
+ ///
+ public bool Preview { get; set; } = true;
}
}
diff --git a/src/testengine.module.pause/PauseFunction.cs b/src/Microsoft.PowerApps.TestEngine/PowerFx/Functions/PauseFunction.cs
similarity index 71%
rename from src/testengine.module.pause/PauseFunction.cs
rename to src/Microsoft.PowerApps.TestEngine/PowerFx/Functions/PauseFunction.cs
index 9cfeb81a6..f49af51ca 100644
--- a/src/testengine.module.pause/PauseFunction.cs
+++ b/src/Microsoft.PowerApps.TestEngine/PowerFx/Functions/PauseFunction.cs
@@ -1,14 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
+using System.Linq;
using Microsoft.Extensions.Logging;
using Microsoft.PowerApps.TestEngine.Config;
using Microsoft.PowerApps.TestEngine.TestInfra;
using Microsoft.PowerFx;
-using Microsoft.PowerFx.Core.Utils;
using Microsoft.PowerFx.Types;
-namespace testengine.module
+namespace Microsoft.PowerApps.TestEngine.PowerFx.Functions
{
///
/// This will pause the current test and allow the user to interact with the browser and inspect state when headless mode is false
@@ -19,8 +19,13 @@ public class PauseFunction : ReflectionFunction
private readonly ITestState _testState;
private readonly ILogger _logger;
+ ///
+ /// Gets a value indicating whether this function is a preview feature
+ ///
+ public bool IsPreview => true;
+
public PauseFunction(ITestInfraFunctions testInfraFunctions, ITestState testState, ILogger logger)
- : base(DPath.Root.Append(new DName("Preview")), "Pause", FormulaType.Blank)
+ : base("Pause", FormulaType.Blank)
{
_testInfraFunctions = testInfraFunctions;
_testState = testState;
@@ -32,6 +37,13 @@ public BlankValue Execute()
_logger.LogInformation("------------------------------\n\n" +
"Executing Pause function.");
+ // Check if Preview features are enabled in settings
+ if (!_testState.GetTestSettings().Preview)
+ {
+ _logger.LogWarning("Pause function is a preview feature. Enable Preview in test settings to use this function.");
+ return FormulaValue.NewBlank();
+ }
+
if (!_testState.GetTestSettings().Headless)
{
var page = _testInfraFunctions.GetContext().Pages.First();
@@ -47,4 +59,3 @@ public BlankValue Execute()
}
}
}
-
diff --git a/src/testengine.module.pause.tests/PauseFunctionTests.cs b/src/testengine.module.pause.tests/PauseFunctionTests.cs
index 8ac6b45d0..e0f03d7a0 100644
--- a/src/testengine.module.pause.tests/PauseFunctionTests.cs
+++ b/src/testengine.module.pause.tests/PauseFunctionTests.cs
@@ -8,6 +8,7 @@
using Microsoft.PowerApps.TestEngine.System;
using Microsoft.PowerApps.TestEngine.TestInfra;
using Microsoft.PowerFx;
+using Microsoft.PowerApps.TestEngine.PowerFx.Functions;
using Moq;
namespace testengine.module.browserlocale.tests
diff --git a/src/testengine.module.pause.tests/testengine.module.pause.tests.csproj b/src/testengine.module.pause.tests/testengine.module.pause.tests.csproj
index 59fb32f4b..d79be140f 100644
--- a/src/testengine.module.pause.tests/testengine.module.pause.tests.csproj
+++ b/src/testengine.module.pause.tests/testengine.module.pause.tests.csproj
@@ -21,8 +21,7 @@
-
-
+
diff --git a/src/testengine.module.pause/PauseModule.cs b/src/testengine.module.pause/PauseModule.cs
index c2ec41d6a..95b0c2035 100644
--- a/src/testengine.module.pause/PauseModule.cs
+++ b/src/testengine.module.pause/PauseModule.cs
@@ -6,6 +6,7 @@
using Microsoft.Playwright;
using Microsoft.PowerApps.TestEngine.Config;
using Microsoft.PowerApps.TestEngine.Modules;
+using Microsoft.PowerApps.TestEngine.PowerFx.Functions;
using Microsoft.PowerApps.TestEngine.Providers;
using Microsoft.PowerApps.TestEngine.System;
using Microsoft.PowerApps.TestEngine.TestInfra;
diff --git a/src/testengine.module.pause/testengine.module.pause.csproj b/src/testengine.module.pause/testengine.module.pause.csproj
index cdc844dee..8bc84ddf6 100644
--- a/src/testengine.module.pause/testengine.module.pause.csproj
+++ b/src/testengine.module.pause/testengine.module.pause.csproj
@@ -39,7 +39,7 @@
-
+