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

splitting and adding js file based on pagetype #374

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
reporter: dotnet-trx # Format of test results

- name: Upload test results
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: test-results-coverage-report
path: src/TestResults/**/coverage.cobertura.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ namespace Microsoft.PowerApps.TestEngine.Tests.PowerApps
{
internal class Common
{
public static string MockJavaScript(string text, string pageType, bool includeMocks = true, bool includeInterface = true)
public static string MockJavaScript(string text, string pageType, bool includeMocks = true, bool includeInterface = true, List<string> interfaceResourceNames = null)
{
// Initialize the list with the default value if it is null
interfaceResourceNames ??= new List<string> { "testengine.provider.mda.PowerAppsTestEngineMDA.js" };

StringBuilder javaScript = new StringBuilder();

Assembly assembly;
Expand All @@ -33,13 +36,15 @@ public static string MockJavaScript(string text, string pageType, bool includeMo
if (includeInterface)
{
assembly = typeof(ModelDrivenApplicationProvider).Assembly;
resourceName = "testengine.provider.mda.PowerAppsTestEngineMDA.js";
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
foreach (string name in interfaceResourceNames)
{
javaScript.Append(reader.ReadToEnd());
using (Stream stream = assembly.GetManifestResourceStream(name))
using (StreamReader reader = new StreamReader(stream))
{
javaScript.Append(reader.ReadToEnd());

javaScript.Append(text + ";");
javaScript.Append(text + ";");
}
}
}
javaScript.Append(text + ";");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void ValidateTestState(string scenario, string javaScript, object expecte
{
// Arrange
var engine = new Engine();
engine.Execute(Common.MockJavaScript("mockPageType = 'custom'", "custom"));
engine.Execute(Common.MockJavaScript("mockPageType = 'custom'", "custom", interfaceResourceNames: new List<string> { "testengine.provider.mda.PowerAppsTestEngineMDA.js", "testengine.provider.mda.PowerAppsTestEngineMDACustom.js" }));
expected = expected == null ? "function" : expected;

scenario += "";
Expand Down Expand Up @@ -109,7 +109,7 @@ public void CanBuildControls(string javaScript)
{
// Arrange
var engine = new Engine();
engine.Execute(Common.MockJavaScript("mockPageType = 'custom'", "custom"));
engine.Execute(Common.MockJavaScript("mockPageType = 'custom'", "custom", interfaceResourceNames: new List<string> { "testengine.provider.mda.PowerAppsTestEngineMDA.js", "testengine.provider.mda.PowerAppsTestEngineMDACustom.js" }));

// Act
var result = engine.Evaluate(javaScript).AsString();
Expand Down Expand Up @@ -170,7 +170,7 @@ public static IEnumerable<object[]> GetPropertyValueFromControlData()
{
// Special case text should use the getValue()
yield return new object[] {
Common.MockJavaScript("mockPageType = 'custom';mockValue = 'Hello'", "custom"),
Common.MockJavaScript("mockPageType = 'custom';mockValue = 'Hello'", "custom", interfaceResourceNames: new List<string> { "testengine.provider.mda.PowerAppsTestEngineMDA.js", "testengine.provider.mda.PowerAppsTestEngineMDACustom.js"}),
"TextInput1",
"Text",
"Hello"
Expand Down Expand Up @@ -227,7 +227,7 @@ public static IEnumerable<object[]> GetControlData()
{
// Default Values
yield return new object[] {
Common.MockJavaScript("mockPageType = 'custom';mockValue = 'Hello'", "custom"),
Common.MockJavaScript("mockPageType = 'custom';mockValue = 'Hello'", "custom", interfaceResourceNames: new List<string> { "testengine.provider.mda.PowerAppsTestEngineMDA.js", "testengine.provider.mda.PowerAppsTestEngineMDACustom.js"}),
"TextInput1",
"{ Text: 'Hello' }"
};
Expand Down
Loading
Loading