Skip to content
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

Upgrade PowerFx.Interpreter library to 0.2.6-preview #280

Merged
merged 8 commits into from
Jul 19, 2023
22 changes: 11 additions & 11 deletions samples/calculator/testPlanWithCommaForDecimal.fx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ testSuite:
testSuiteDescription: Verifies that the calculator app works. The calculator is a component.
persona: User1
# appId: fd32a609-eaca-4d91-b5b4-31651d265133
appLogicalName: new_calculator_a3613
appLogicalName: new_calculator2_11d82

# This sample has been written to demonstrate tests written in regions that use commas ',' instead of
# periods '.' for a decimal separator. E.g., "10,22" instead of "10.22". However since all of our tests
Expand All @@ -13,29 +13,29 @@ testSuite:
- testCaseName: Default Check
testSteps: |
= Screenshot("calculator_loaded.png");;
Assert(Calculator_1.Number1Label.Text = "10.12"; "Validate default value for number 1 label");;
Assert(Calculator_1.Number2Label.Text = "2.2"; "Validate default value for number 2 label");;
Assert(Calculator_1.Number1Label.Text = "4.42"; "Validate default value for number 1 label");;
Assert(Calculator_1.Number2Label.Text = "2.5"; "Validate default value for number 2 label");;
- testCaseName: Check Addition
testSteps: |
= Select(Calculator_1.Add);;
Assert(Calculator_1.ResultLabel.Text = "12.32"; "Validate result label has the results of addition");;
Assert(Calculator_1.CalculatorResult = 12,32; "Validate component output calculator result has the results of addition");;
Assert(Calculator_1.ResultLabel.Text = "6.92"; "Validate result label has the results of addition");;
Assert(Calculator_1.CalculatorResult = 6,92; "Validate component output calculator result has the results of addition");;
- testCaseName: Check subtraction
testSteps: |
= Select(Calculator_1.Subtract);;
Assert(Calculator_1.ResultLabel.Text = "7.92"; "Validate result label has the results of subtraction");;
Assert(Calculator_1.CalculatorResult = 7,92; "Validate component output calculator result has the results of subtraction");;
Assert(Calculator_1.ResultLabel.Text = "1.92"; "Validate result label has the results of subtraction");;
Assert(Calculator_1.CalculatorResult = 1,92; "Validate component output calculator result has the results of subtraction");;

- testCaseName: Check multiplication
testSteps: |
= Select(Calculator_1.Multiply);;
Assert(Calculator_1.ResultLabel.Text = "22.264"; "Validate result label has the results of multiplication");;
Assert(Calculator_1.CalculatorResult = 22,264; "Validate component output calculator result has the results of multiplication");;
Assert(Calculator_1.ResultLabel.Text = "11.05"; "Validate result label has the results of multiplication");;
Assert(Calculator_1.CalculatorResult = 11,05; "Validate component output calculator result has the results of multiplication");;
- testCaseName: Check division
testSteps: |
= Select(Calculator_1.Divide);;
Assert(Calculator_1.ResultLabel.Text = "4.6"; "Validate result label has the results of division");;
Assert(Calculator_1.CalculatorResult = 4,6; "Validate component output calculator result has the results of division");;
Assert(Calculator_1.ResultLabel.Text = "1.768"; "Validate result label has the results of division");;
Assert(Calculator_1.CalculatorResult = 1,768; "Validate component output calculator result has the results of division");;
Screenshot("calculator_end.png");;

testSettings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public async Task SetPropertyDateAsyncTest()
var result = await powerAppFunctions.SetPropertyAsync(itemPath, DateValue.NewDateOnly(dt.Date));

Assert.True(result);
MockTestInfraFunctions.Verify(x => x.RunJavascriptAsync<bool>($"PowerAppsTestEngine.setPropertyValue({itemPathString},{{\"SelectedDate\":Date.parse(\"{((DateValue)DateValue.NewDateOnly(dt.Date)).Value}\")}})"), Times.Once());
MockTestInfraFunctions.Verify(x => x.RunJavascriptAsync<bool>($"PowerAppsTestEngine.setPropertyValue({itemPathString},{{\"SelectedDate\":Date.parse(\"{((DateValue)DateValue.NewDateOnly(dt.Date)).GetConvertedValue(null)}\")}})"), Times.Once());
}

[Fact]
Expand Down Expand Up @@ -542,8 +542,8 @@ public async Task LoadPowerAppsObjectModelAsyncWaitsForAppToLoadWithExceptions()
{
MockSingleTestInstanceState.Setup(x => x.GetLogger()).Returns(MockLogger.Object);
MockTestInfraFunctions.Setup(x => x.AddScriptTagAsync(It.IsAny<string>(), It.IsAny<string>())).Returns(Task.CompletedTask);
MockTestInfraFunctions.SetupSequence(x => x.RunJavascriptAsync<string>("typeof PowerAppsTestEngine"))
.Returns(Task.FromResult("object"));
MockTestInfraFunctions.SetupSequence(x => x.RunJavascriptAsync<string>("typeof PowerAppsTestEngine"))
.Returns(Task.FromResult("object"));

MockTestInfraFunctions.Setup(x => x.RunJavascriptAsync<string>("PowerAppsTestEngine.buildObjectModel().then((objectModel) => JSON.stringify(objectModel))")).Returns(Task.FromResult("{}"));
var testSettings = new TestSettings() { Timeout = 12000 };
Expand All @@ -570,7 +570,7 @@ public async Task LoadPowerAppsObjectModelAsyncEmbedJSUndefined()

var powerAppFunctions = new PowerAppFunctions(MockTestInfraFunctions.Object, MockSingleTestInstanceState.Object, MockTestState.Object);
await Assert.ThrowsAsync<TimeoutException>(async () => { await powerAppFunctions.LoadPowerAppsObjectModelAsync(); });

MockTestInfraFunctions.Verify(x => x.RunJavascriptAsync<string>("PowerAppsTestEngine.buildObjectModel().then((objectModel) => JSON.stringify(objectModel))"), Times.AtLeastOnce());
LoggingTestHelper.VerifyLogging(MockLogger, "Start to load power apps object model", LogLevel.Debug, Times.Once());
}
Expand Down Expand Up @@ -820,7 +820,7 @@ public async Task SetPropertyDateAsyncNoPublishedAppFunction()
var powerAppFunctions = new PowerAppFunctions(MockTestInfraFunctions.Object, MockSingleTestInstanceState.Object, MockTestState.Object);
await Assert.ThrowsAsync<Exception>(async () => { await powerAppFunctions.SetPropertyDateAsync(itemPath, DateValue.NewDateOnly(dt.Date)); });

MockTestInfraFunctions.Verify(x => x.RunJavascriptAsync<bool>($"PowerAppsTestEngine.setPropertyValue({itemPathString},{{\"SelectedDate\":Date.parse(\"{((DateValue)DateValue.NewDateOnly(dt.Date)).Value}\")}})"), Times.Once());
MockTestInfraFunctions.Verify(x => x.RunJavascriptAsync<bool>($"PowerAppsTestEngine.setPropertyValue({itemPathString},{{\"SelectedDate\":Date.parse(\"{((DateValue)DateValue.NewDateOnly(dt.Date)).GetConvertedValue(null)}\")}})"), Times.Once());
LoggingTestHelper.VerifyLogging(MockLogger, ExceptionHandlingHelper.PublishedAppWithoutJSSDKMessage, LogLevel.Error, Times.Once());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Moq;
using Newtonsoft.Json;
using Xunit;
using YamlDotNet.Core.Tokens;

namespace Microsoft.PowerApps.TestEngine.Tests.PowerApps.PowerFXModel
{
Expand Down Expand Up @@ -47,8 +46,8 @@ public void SimpleControlRecordValueTest()

Assert.Equal(propertyValue, (controlRecordValue.GetField("Text") as StringValue).Value);
Assert.Equal(numberPropertyValue, (controlRecordValue.GetField("X") as NumberValue).Value);
Assert.Equal(datePropertyValue.ToString(), (controlRecordValue.GetField("SelectedDate") as DateValue).Value.ToString());
Assert.Equal(dateTimePropertyValue.ToString(), (controlRecordValue.GetField("DefaultDate") as DateTimeValue).Value.ToString());
Assert.Equal(datePropertyValue.ToString(), (controlRecordValue.GetField("SelectedDate") as DateValue).GetConvertedValue(null).ToString());
Assert.Equal(dateTimePropertyValue.ToString(), (controlRecordValue.GetField("DefaultDate") as DateTimeValue).GetConvertedValue(null).ToString());

mockPowerAppFunctions.Verify(x => x.GetPropertyValueFromControl<string>(It.Is<ItemPath>((x) => x.PropertyName == "Text" && x.ControlName == controlName)), Times.Once());
mockPowerAppFunctions.Verify(x => x.GetPropertyValueFromControl<string>(It.Is<ItemPath>((x) => x.PropertyName == "X" && x.ControlName == controlName)), Times.Once());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.PowerApps.TestEngine.Config;
using Microsoft.PowerApps.TestEngine.PowerApps;
using Microsoft.PowerApps.TestEngine.PowerApps.PowerFxModel;
using Microsoft.PowerApps.TestEngine.PowerFx;
using Microsoft.PowerApps.TestEngine.PowerFx.Functions;
using Microsoft.PowerApps.TestEngine.Tests.Helpers;
using Microsoft.PowerFx.Types;
Expand Down Expand Up @@ -146,7 +145,7 @@ public void SetPropertyDateFunctionTest()

// check to see if the value of DatePicker1's 'Value' property is the correct datetime (01/01/2030)
Assert.IsType<BooleanValue>(result);
MockPowerAppFunctions.Verify(x => x.SetPropertyAsync(It.Is<ItemPath>((item) => item.ControlName == recordValue.Name), It.Is<DateValue>(dateVal => dateVal.Value == dt)), Times.Once());
MockPowerAppFunctions.Verify(x => x.SetPropertyAsync(It.Is<ItemPath>((item) => item.ControlName == recordValue.Name), It.Is<DateValue>(dateVal => dateVal.GetConvertedValue(null) == dt)), Times.Once());
}

[Fact]
Expand All @@ -157,7 +156,7 @@ public void SetPropertyRecordFunctionTest()

// Make setPropertyFunction contain a component called Dropdown1
var recordType = RecordType.Empty().Add("Selected", RecordType.Empty());
var recordValue = new ControlRecordValue(recordType, MockPowerAppFunctions.Object,"Dropdown1");
var recordValue = new ControlRecordValue(recordType, MockPowerAppFunctions.Object, "Dropdown1");
var setPropertyFunction = new SetPropertyFunction(MockPowerAppFunctions.Object, MockLogger.Object);

// Set the value of Dropdown1's 'Selected' property to {"Value":"2"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public bool GetBoolean()
throw new global::System.NotImplementedException();
}

public decimal GetDecimal()
{
throw new global::System.NotImplementedException();
}

public double GetDouble()
{
throw new global::System.NotImplementedException();
Expand All @@ -36,6 +41,11 @@ public string GetString()
throw new global::System.NotImplementedException();
}

public string GetUntypedNumber()
{
throw new global::System.NotImplementedException();
}

public bool TryGetProperty(string value, out IUntypedObject result)
{
throw new global::System.NotImplementedException();
Expand Down
Loading
Loading