Skip to content

[Feature]: Enable PowerApps MDA Media Controls Video, Audio, Microphone for Custom Pages #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Binary file not shown.
33 changes: 33 additions & 0 deletions samples/mdamediacontrols/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Overview

This Power Apps Test Engine example shows how to validate and manipulate the values of Media controls such as Video, Audio, and Microphone within a model-driven application form.

## Usage

1. **Build the Test Engine Solution**
Ensure the Power Apps Test Engine solution is built and ready to be executed.

2. **Get the URL of the Model-Driven Application Form**
Acquire the URL of the specific Model-Driven Application form that you want to test.

3. **Modify the testPlan.fx.yaml**
Update the YAML file to assert expected values of the Video, Audio, and Microphone controls.

> [!NOTE] The controls are referenced using the [logical name](https://learn.microsoft.com/power-apps/developer/data-platform/entity-metadata#table-names).
4. **Update the Domain URL for Your Model-Driven Application**

| URL Part | Description |
|----------|-------------|
| `appid=a1234567-cccc-44444-9999-a123456789123` | The unique identifier of your model-driven application. |
| `etn=` | The name of the entity being validated. |
| `id=26bafa27-ca7d-ee11-8179-0022482a91f4` | The unique identifier of the record being edited. |
| `pagetype=custom` | The type of page to open. |
| `UserAuth=storagestate` | The type of user authentication to use. |
| `UseStaticContext=True` | The Flag to represent usage of Static context. |

5. **Execute the Test for Custom Page**
Change the example below to the URL of your organization:

```pwsh
cd bin\Debug\PowerAppsEngine
dotnet PowerAppsTestEngine.dll -i ..\..\..\samples\mda_imagecontrol\testPlan.fx.yaml -e 00000000-0000-0000-0000-11112223333 -t 11112222-3333-4444-5555-666677778888 -u storagestate -c True --provider mda -d "https://contoso.crm4.dynamics.com/main.aspx?appid=d67b4662-12fb-ef11-bae2-00224823607e&pagetype=custom&name=cr693_mdamediacontrols_f20f0"
33 changes: 33 additions & 0 deletions samples/mdamediacontrols/RunTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Get current directory so we can reset back to it after running the tests
$currentDirectory = Get-Location

$config = Get-Content -Path .\config.json -Raw | ConvertFrom-Json
$tenantId = $config.tenantId
$environmentId = $config.environmentId
$user1Email = $config.user1Email

if ([string]::IsNullOrEmpty($environmentId)) {
Write-Error "Environment not configured. Please update config.json"
return
}

# Build the latest debug version of Test Engine from source
Set-Location ..\..\src
dotnet build

if ($config.installPlaywright) {
Start-Process -FilePath "pwsh" -ArgumentList "-Command `"..\bin\Debug\PowerAppsTestEngine\playwright.ps1 install`"" -Wait
} else {
Write-Host "Skipped playwright install"
}

Set-Location ..\bin\Debug\PowerAppsTestEngine
$env:user1Email = $user1Email
# Run the tests for each user in the configuration file.
dotnet PowerAppsTestEngine.dll -u "storagestate" --provider "mda" -a "none" -i "$currentDirectory\testPlan.fx.yaml" -t $tenantId -e $environmentId

# Reset the location back to the original directory.
Set-Location $currentDirectory
172 changes: 172 additions & 0 deletions samples/mdamediacontrols/testPlan.fx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
testSuite:
testSuiteName: MDA Custom Page tests - Media Control
testSuiteDescription: Verify test cases for Media Control
persona: User1
appLogicalName: NotNeeded

testCases:
# Video Control Test Cases

- testCaseName: Test Video Control - Start Time Property
testCaseDescription: Verify that the Start Time property starts video from the given time.
testSteps: |
SetProperty(Video1.StartTime, 0);
Assert(Video1.StartTime = 0, "Checking if video Started from given time");

- testCaseName: Test Video Control - AutoStart Property
testCaseDescription: Verify that the AutoStart property starts video playback automatically when enabled.
testSteps: |
SetProperty(Video1.AutoStart, true);
Wait(lblVideo, "Text", "Video Playback has started");
Assert(Video1.AutoStart = true, "Checking if video AutoStart is enabled");

- testCaseName: Test Video Control - Start Property
testCaseDescription: Verify that the Start property correctly sets the start position of the video.
testSteps: |
SetProperty(Video1.Start, true);
Wait(lblVideo, "Text", "Video Playback has started");
Assert(Video1.Start = true, "Checking the Start position");

- testCaseName: Test Video Control - Paused Property
testCaseDescription: Verify that the Paused property reflects the correct state of video playback.
testSteps: |
SetProperty(Video1.Paused, true);
Assert(Video1.Paused = true, "Checking if video is paused");
SetProperty(Video1.Paused, false);
Assert(Video1.Paused = false, "Checking if video is playing");

- testCaseName: Test Video Control - ShowControls Property
testCaseDescription: Verify that the Video control's ShowControls property can be enabled and disabled.
testSteps: |
SetProperty(Video1.ShowControls, false);
Assert(Video1.ShowControls = false, "Checking if ShowControls is disabled");
SetProperty(Video1.ShowControls, true);
Assert(Video1.ShowControls = true, "Checking if ShowControls is enabled");


- testCaseName: Test Video Control - Image Property
testCaseDescription: Verify that the Video control's Image property is set correctly as a placeholder.
testSteps: |
SetProperty(Video1.Image, "https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png");
Assert(Video1.Image = "https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png", "Checking the Image source value");

- testCaseName: Test Video Control - Loop Property
testCaseDescription: Verify that the Loop property enables looping of the video.
testSteps: |
SetProperty(Video1.Loop, true);
Wait(lblVideo, "Text", "Video Playback has started");
Assert(Video1.Loop = true, "Checking if video is looping");

- testCaseName: Test Video Control - Media Property
testCaseDescription: Verify that the Video control can set and retrieve the media source correctly.
testSteps: |
SetProperty(Video1.Media, "https://www.youtube.com/watch?v=668nUCeBHyY");
Wait(Video1, "Media", "https://www.youtube.com/watch?v=668nUCeBHyY");
Assert(Video1.Media = "https://www.youtube.com/watch?v=668nUCeBHyY", "Checking the Media source value");


# Audio Control Test Cases

- testCaseName: Test Audio Control - Start Time Property
testCaseDescription: Verify that the Start Time property starts audio from the given time.
testSteps: |
SetProperty(Audio1.StartTime, 0);
Assert(Audio1.StartTime = 0, "Checking if audio Started from given time");

- testCaseName: Test Audio Control - AutoStart Property
testCaseDescription: Verify that the AutoStart property starts audio playback automatically when enabled.
testSteps: |
SetProperty(Audio1.AutoStart, true);
Wait(lblAudio, "Text", "Audio Playback has started");
Assert(Audio1.AutoStart = true, "Checking if audio AutoStart is enabled");

- testCaseName: Test Audio Control - Start Property
testCaseDescription: Verify that the Start property correctly sets the start position of the audio.
testSteps: |
SetProperty(Audio1.Start, true);
Wait(lblAudio, "Text", "Audio Playback has started");
Assert(Audio1.Start = true, "Checking the Start position");

- testCaseName: Test Audio Control - Paused Property
testCaseDescription: Verify that the Paused property reflects the correct state of audio playback.
testSteps: |
SetProperty(Audio1.Paused, true);
Assert(Audio1.Paused = true, "Checking if audio is paused");
SetProperty(Audio1.Paused, false);
Assert(Audio1.Paused = false, "Checking if audio is playing");

- testCaseName: Test Audio Control - ShowControls Property
testCaseDescription: Verify that the Audio control's ShowControls property can be enabled and disabled.
testSteps: |
SetProperty(Audio1.ShowControls, false);
Assert(Audio1.ShowControls = false, "Checking if ShowControls is disabled");
SetProperty(Audio1.ShowControls, true);
Assert(Audio1.ShowControls = true, "Checking if ShowControls is enabled");

- testCaseName: Test Audio Control - Image Property
testCaseDescription: Verify that the Audio control's Image property is set correctly as a placeholder.
testSteps: |
SetProperty(Audio1.Image, "https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png");
Assert(Audio1.Image = "https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png", "Checking the Image source value");

- testCaseName: Test Audio Control - Loop Property
testCaseDescription: Verify that the Loop property enables looping of the audio.
testSteps: |
SetProperty(Audio1.Loop, true);
Wait(lblAudio, "Text", "Audio Playback has started");
Assert(Audio1.Loop = true, "Checking if audio is looping");

- testCaseName: Test Audio Control - Media Property
testCaseDescription: Verify that the Audio control can set and retrieve the media source correctly.
testSteps: |
SetProperty(Audio1.Media, "https://www.youtube.com/watch?v=mDQQFjM5Bfg&list=RDmDQQFjM5Bfg&start_radio=1");
Wait(Audio1, "Media", "https://www.youtube.com/watch?v=mDQQFjM5Bfg&list=RDmDQQFjM5Bfg&start_radio=1");
Assert(Audio1.Media = "https://www.youtube.com/watch?v=mDQQFjM5Bfg&list=RDmDQQFjM5Bfg&start_radio=1", "Checking the Media source value");

# Micrphone Control Test Cases

- testCaseName: Test Microphone Control - Mic Property
testCaseDescription: Verify that the Mic property set to 1.
testSteps: |
SetProperty(Microphone1.Mic, 1);
Assert(Microphone1.Mic = 1, "Checking if microphone mic property set to 1");

- testCaseName: Test Microphone Control - Mic Property
testCaseDescription: Verify that the Mic property starts and stops the microphone recording.
testSteps: |
Select(Microphone1);
Wait(lblMicrophone, "Text", "Recording has Started");
Assert(lblMicrophone.Text = "Recording has Started", "Checking if microphone recording has started");
Select(Microphone1);
Wait(lblMicrophone, "Text", "Recording has Stopped");
Assert(lblMicrophone.Text = "Recording has Stopped", "Checking if microphone recording has stopped");

- testCaseName: Test Microphone Control - Image Property
testCaseDescription: Verify that the Microphone control's Image property is set correctly as a placeholder.
testSteps: |
SetProperty(Microphone1.Image, "https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png");
Assert(Microphone1.Image = "https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png", "Checking the Image source value");

- testCaseName: Test Microphone Control - Audio Property
testCaseDescription: Verify that the Microphone control can set and retrieve the audio source correctly.
testSteps: |
SetProperty(Audio2.Media, Microphone1.Audio);
Wait(Audio2, "Media", Microphone1.Audio);
SetProperty(Audio2.Start, true);
Assert(Audio2.Start = true, "Checking the Audio source value");

testSettings:
headless: false
locale: "en-US"
recordVideo: true
extensionModules:
enable: true
browserConfigurations:
- browser: Chromium
channel: msedge

environmentVariables:
users:
- personaName: User1
emailKey: user1Email
passwordKey: NotNeeded
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public MDATypeMapping()
typeMappings.Add("n", FormulaType.Number);
typeMappings.Add("Z", FormulaType.DateTimeNoTimeZone);
typeMappings.Add("g", FormulaType.Guid);
typeMappings.Add("m", FormulaType.Decimal);
typeMappings.Add("m", FormulaType.String);
typeMappings.Add("v", FormulaType.UntypedObject);
typeMappings.Add("i", FormulaType.String);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ public string CheckTestEngineObject
case "islogovisible":
case "istitlevisible":
case "checked":
case "autostart":
case "paused":
case "showcontrols":
case "loop":
case "start":
case "autoplay":
case "showtitle":
return (T)(object)("{PropertyValue: " + value.ToString().ToLower() + "}");
Expand Down