Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Microsoft.PowerApps.TestEngine/Config/TestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,12 @@ public class TestSettings
/// Define settings for Test Engine Extensions
/// </summary>
public TestSettingExtensions ExtensionModules { get; set; } = new TestSettingExtensions();

/// <summary>
/// Gets or sets whether preview functions are enabled.
/// Default is false.
/// If set to true, preview functions like Pause() are available for use.
/// </summary>
public bool Preview { get; set; } = true;
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// This will pause the current test and allow the user to interact with the browser and inspect state when headless mode is false
Expand All @@ -19,8 +19,13 @@ public class PauseFunction : ReflectionFunction
private readonly ITestState _testState;
private readonly ILogger _logger;

/// <summary>
/// Gets a value indicating whether this function is a preview feature
/// </summary>
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;
Expand All @@ -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();
Expand All @@ -47,4 +59,3 @@ public BlankValue Execute()
}
}
}

1 change: 1 addition & 0 deletions src/testengine.module.pause.tests/PauseFunctionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<Compile Remove="obj\**" />
<EmbeddedResource Remove="obj\**" />
<None Remove="obj\**" />
</ItemGroup>

</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Moq" Version="4.20.72" />
Expand Down
1 change: 1 addition & 0 deletions src/testengine.module.pause/PauseModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<Compile Remove="obj\**" />
<EmbeddedResource Remove="obj\**" />
<None Remove="obj\**" />
</ItemGroup>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
Expand Down
Loading