diff --git a/samples/mdamediacontrols/Mda_MediaControls_1_0_0_2_managed.zip b/samples/mdamediacontrols/Mda_MediaControls_1_0_0_2_managed.zip new file mode 100644 index 000000000..5bb7a8700 Binary files /dev/null and b/samples/mdamediacontrols/Mda_MediaControls_1_0_0_2_managed.zip differ diff --git a/samples/mdamediacontrols/README.md b/samples/mdamediacontrols/README.md new file mode 100644 index 000000000..1f7b6964d --- /dev/null +++ b/samples/mdamediacontrols/README.md @@ -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" \ No newline at end of file diff --git a/samples/mdamediacontrols/RunTests.ps1 b/samples/mdamediacontrols/RunTests.ps1 new file mode 100644 index 000000000..222e4e758 --- /dev/null +++ b/samples/mdamediacontrols/RunTests.ps1 @@ -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 \ No newline at end of file diff --git a/samples/mdamediacontrols/testPlan.fx.yaml b/samples/mdamediacontrols/testPlan.fx.yaml new file mode 100644 index 000000000..108a0515d --- /dev/null +++ b/samples/mdamediacontrols/testPlan.fx.yaml @@ -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 diff --git a/src/Microsoft.PowerApps.TestEngine/Providers/PowerFxModel/MDATypeMapping.cs b/src/Microsoft.PowerApps.TestEngine/Providers/PowerFxModel/MDATypeMapping.cs index 27418f271..560b033c7 100644 --- a/src/Microsoft.PowerApps.TestEngine/Providers/PowerFxModel/MDATypeMapping.cs +++ b/src/Microsoft.PowerApps.TestEngine/Providers/PowerFxModel/MDATypeMapping.cs @@ -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); } diff --git a/src/testengine.provider.mda/ModelDrivenApplicationProvider.cs b/src/testengine.provider.mda/ModelDrivenApplicationProvider.cs index d4dee61aa..2260630a2 100644 --- a/src/testengine.provider.mda/ModelDrivenApplicationProvider.cs +++ b/src/testengine.provider.mda/ModelDrivenApplicationProvider.cs @@ -216,6 +216,11 @@ public string CheckTestEngineObject case "islogovisible": case "istitlevisible": case "checked": + case "autostart": + case "paused": + case "showcontrols": + case "loop": + case "start": case "markers": case "powerbiinteractions": case "autoplay":