In this section, you will learn how to load a sample Weather application. This application is designed to call the MSN Weather and then have the user save the current weather at the location and categorize how this weather relates to them. This example highlights a number of items:
This section builds on concepts introduced in Simulating Connector and Simulating Dataverse.
To follow the steps in this module carry out the following actions.
WeatherSample_*.zip
solution file from the cloned repository using Import solutions.Verify that the config file in the samples\weather has been configured for your environment, tenant and user1Email
{
"tenantId": "a222222-1111-2222-3333-444455556666",
"environmentId": "12345678-1111-2222-3333-444455556666",
"customPage": "te_snapshots_24d69",
"appDescription": "Weather Sample",
"user1Email": "test@contoso.onmicrosoft.com",
"runInstall": true,
"installPlaywright": true,
"languages": [
{"id":1031, "name": "de-de", "file":"testPlan.eu.fx.yaml"},
{"id":1033, "name": "en-us", "file":"testPlan.fx.yaml"},
{"id":1036, "name": "fr-fr", "file":"testPlan.eu.fx.yaml"}
]
}
You have authenticated with the Power Platform CLI
pac auth create -name Dev --environment 12345678-1111-2222-3333-444455556666
You have logged into the Azure CLI with account that has access to the environment that you have deployed
az login --allow-no-subscriptions
Run the test
cd samples\weather
pwsh -File RunTests.ps1
Lets have a closer look at the weather testPlan.fx.yaml for key concepts it demonstrates
Power Fx commands before test case starts. The yaml file includes onTestSuiteStart
for Power Fx statements to run before the test case starts. In this case it executes Power Fx statements to simulate calls to Dataverse and MSN Weather connector.
Dateverse simulation. Power Fx commands that will watch for queries to dateverse and return test data so that application is an a known state. This approach also allows for edge case and exception cases to be managed without needing to manage and maintain data in dataverse.
Preview.SimulateDataverse({
Action: "Query",
Entity: "te_weathercategories",
Then: Table(
{
'te_categoryname': "Test Category",
'createdon': "2024-12-02T17:52:45Z",
'te_weathercategoryid': "f58de6c-905d-457d-846b-3e0b2aa4c5fd"
}
)
});
Simulating connectors. Setup watch for calls to Power Platform connectors and return test results. For this test the following Power Fx allows the application to be tested for how it uses the results.
Preview.SimulateConnector(
{
name: "msnweather",
then: {
responses: {
weather: {
current: {
temp: 30,
feels: 20,
cap: "Sunny"
}
},
source: { location: "Test Location" }
},
units: { temperature: "^F" }
}
}
)
Verify test data. You can use assert function calls to verify that the simulated data has been applied as expected
Assert(CountRows(WeatherCategory.Items)=1);
Assert(CountRows(Gallery1.Items)=1);
Check application features. You can interact with Power Fx controls and validate how the results are used
Select(SearchNow);
Assert(Summary.Text="Match: Test Location, Temp: 30^F, Feels: 20^F, Sunny");
In this section, you learned how to load and test a sample Weather application. You explored how to call the MSN Weather connector, interact with Dataverse, and use assert statements to verify the application’s functionality. By following the key steps and exploring the sample, you gained insights into simulating connectors and Dataverse interactions to ensure your application works as expected.