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

Add rule id property #28

Merged
merged 5 commits into from
Jan 23, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added Example Rules fail tests.
NatVanG committed Jan 7, 2024

Verified

This commit was signed with the committer’s verified signature.
jeertmans Jérome Eertmans
commit 76af4ad81217678149cc16c8bf9794f5a2708e7d
15 changes: 14 additions & 1 deletion DocsExamples/Example-rules.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
"codepage": 1200,
"rules": [
{
"id": "CHARTS_WIDER_THAN_TALL",
"name": "Charts wider than tall",
"description": "Want to check that your charts are wider than tall?",
"disabled": false,
@@ -49,6 +50,7 @@
]
},
{
"id": "DISABLE_SLOW_DATASOURCE_SETTINGS",
"name": "Disable local slow datasource settings",
"description": "Check that report slow data source settings are all disabled.",
"disabled": false,
@@ -91,6 +93,7 @@
]
},
{
"id": "LOCAL_REPORT_SETTINGS",
"name": "Local report settings",
"disabled": false,
"logType": "warning",
@@ -213,7 +216,8 @@
]
},
{
"name": "Show visual axes title",
"id": "SHOW_AXES_TITLES",
"name": "Show visual axes titles",
"description": "Check that certain charts have both axes title showing.",
"disabled": false,
"logType": "warning",
@@ -282,6 +286,7 @@
]
},
{
"id": "PERCENTAGE_OF_CHARTS_USING_CUSTOM_COLOURS",
"name": "Percentage of charts across the report using custom colours is not greater than 10%",
"description": "Check that charts avoid custom colours and use theme colours instead.",
"disabled": false,
@@ -372,6 +377,7 @@
]
},
{
"id": "ENSURE_ALT_TEXT_DEFINED_FOR_VISUALS",
"name": "Ensure alt-text has been defined for visuals",
"description": "Alt-text is required for screen readers.",
"disabled": true,
@@ -441,6 +447,7 @@
]
},
{
"id": "DISABLE_DROP_SHADOWS_ON_VISUALS",
"name": "Disable drop shadows on visuals",
"description": "Drop shadows are not suitable for everyone, this rule returns an array of visuals with drop shadows enabled.",
"disabled": false,
@@ -485,6 +492,7 @@
]
},
{
"id": "GIVE_VISIBLE_PAGES_MEANINGFUL_NAMES",
"name": "Give visible pages meaningful names",
"description": "Returns an array of visible page names with a default 'Page x' display name.",
"disabled": false,
@@ -533,6 +541,7 @@
]
},
{
"id": "DENEB_CHARTS_PROPERTIES",
"name": "Check Deneb charts properties - work in progress",
"description": "Checks that the drillvar custom rule can read deneb custom visual nested jsonspec properties. This is an example in progress that demonstrates the use of the drillvar custom rule but doesn't yet do anything useful.",
"disabled": true,
@@ -581,6 +590,7 @@
]
},
{
"id": "CHECK_FOR_VISUALS_OVERLAP",
"name": "Check for visuals overlap with a 5px margin",
"description": "Returns names of visuals that overlap while inflating visuals rectangle area by 5px left, right, top and bottom. Currently this does not check for overlap with the sides of report page itself. This rule does not currently work with visual groups.",
"disabled": false,
@@ -691,6 +701,7 @@
]
},
{
"id": "CHECK_FOR_LOCAL_MEASURES",
"name": "Check for locally defined measures",
"description": "Returns an array of report-level measure definitions",
"path": "$.config",
@@ -751,6 +762,7 @@
"codepage": 65001,
"rules": [
{
"id": "REPORT_THEME_NAME",
"name": "Report theme name",
"description": "Check Report theme name",
"disabled": false,
@@ -771,6 +783,7 @@
]
},
{
"id": "REPORT_THEME_TITLE_FONT",
"name": "Report theme title font properties",
"description": "Checks theme's' title foreground, fontface and fontsize",
"disabled": false,
Binary file added PBIXInspectorTests/Files/Example-rules-fails.pbix
Binary file not shown.
10 changes: 8 additions & 2 deletions PBIXInspectorTests/PBIXInspectorTests.csproj
Original file line number Diff line number Diff line change
@@ -30,6 +30,9 @@
<None Include="..\PBIXInspectorWinForm\Files\pbip\Inventory sample - fails.Report\report.json" Link="Files\pbip\Inventory sample - fails.Report\report.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="..\DocsExamples\Example-rules.json" Link="Files\Example-rules.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\PBIXInspectorWinForm\Files\pbip\Inventory sample - fails.Report\StaticResources\RegisteredResources\pbilogo011716949638171492.png" Link="Files\pbip\Inventory sample - fails.Report\StaticResources\RegisteredResources\pbilogo011716949638171492.png" />
<None Include="..\PBIXInspectorWinForm\Files\pbip\Inventory sample - fails.Report\StaticResources\SharedResources\BaseThemes\CY22SU11.json" Link="Files\pbip\Inventory sample - fails.Report\StaticResources\SharedResources\BaseThemes\CY22SU11.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -62,16 +65,19 @@
</ItemGroup>

<ItemGroup>
<None Update="Files\Example-rules-fails.pbix">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory rules sample.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory rules test.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory sample - fails.pbix">
<None Update="Files\Base-rules-fails.pbix">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory sample - passes.pbix">
<None Update="Files\Base-rules-passes.pbix">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Inventory sample.pbix">
126 changes: 124 additions & 2 deletions PBIXInspectorTests/SuiteRunner.cs
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ public void RunPbipTest(TestResult testResult)
#region BasePassSuite
public static IEnumerable<TestCaseData> BasePassPBIXSuite()
{
string PBIXFilePath = @"Files\Inventory sample - passes.pbix";
string PBIXFilePath = @"Files\Base-rules-passes.pbix";
string RulesFilePath = @"Files\Base-rules.json";

Console.WriteLine("Running base pass PBIX suite...");
@@ -86,7 +86,7 @@ public void RunBasePassPBIX(TestResult testResult)
#region BaseFailSuite
public static IEnumerable<TestCaseData> BaseFailPBIXSuite()
{
string PBIXFilePath = @"Files\Inventory sample - fails.pbix";
string PBIXFilePath = @"Files\Base-rules-fails.pbix";
string RulesFilePath = @"Files\Base-rules.json";

Console.WriteLine("Running base fail PBIX suite...");
@@ -213,6 +213,128 @@ private void RunBaseFail(TestResult testResult)
}
#endregion

#region ExampleFailSuite

public static IEnumerable<TestCaseData> ExampleFailPBIXSuite()
{
string PBIXFilePath = @"Files\Example-rules-fails.pbix";
string RulesFilePath = @"Files\Example-rules.json";

Console.WriteLine("Running example fail PBIX suite...");
return Suite(PBIXFilePath, RulesFilePath);
}

[TestCaseSource(nameof(ExampleFailPBIXSuite))]
public void RunExampleFailPBIX(TestResult testResult)
{
RunExampleFail(testResult);
}

private void RunExampleFail(TestResult testResult)
{
string expected = "[]";
switch (testResult.RuleId)
{
case "CHARTS_WIDER_THAN_TALL":
if (testResult.ParentDisplayName == testResult.RuleId)
{
expected = "[\"3f7d302598c1e81e7e78\", \"5094f3ff553da63e610e\"]";
JsonAssert.AreEquivalent(JsonNode.Parse(expected), testResult.Actual);
Assert.False(testResult.Pass, testResult.Message);
}
else
{
Assert.True(testResult.Pass, testResult.Message);
}
break;
case "DISABLE_SLOW_DATASOURCE_SETTINGS":
Assert.False(testResult.Pass, testResult.Message);
break;
case "LOCAL_REPORT_SETTINGS":
Assert.False(testResult.Pass, testResult.Message);
break;
case "SHOW_AXES_TITLES":
if (testResult.ParentDisplayName == testResult.RuleId)
{
expected = "[\"a9243890e8b7ec111322\", \"d65c53d5b679c4cacba0\", \"8a0d8392a2400e899bcc\"]";
JsonAssert.AreEquivalent(JsonNode.Parse(expected), testResult.Actual);
Assert.False(testResult.Pass, testResult.Message);
}
else
{
Assert.True(testResult.Pass, testResult.Message);
}
break;
case "PERCENTAGE_OF_CHARTS_USING_CUSTOM_COLOURS":
//if (testResult.ParentName == "ReportSectiond7d52b137add50d28b88")
//{
// Assert.False(testResult.Pass, testResult.Message);
//}
//else
//{
// Assert.True(testResult.Pass, testResult.Message);
//}
break;
case "ENSURE_ALT_TEXT_DEFINED_FOR_VISUALS":
expected = "[\"9032ab70a7e060d08574\",\"eca6ff83ecb390801c3a\"]";
if (testResult.ParentDisplayName == testResult.RuleId)
{
JsonAssert.AreEquivalent(JsonNode.Parse(expected), testResult.Actual);
Assert.False(testResult.Pass, testResult.Message);
}

break;
case "DISABLE_DROP_SHADOWS_ON_VISUALS":
expected = "[\"bdb3c2666ac0e67947aa\",\"5d4868734a72096e0ada\"]";
if (testResult.ParentDisplayName == testResult.RuleId)
{
JsonAssert.AreEquivalent(JsonNode.Parse(expected), testResult.Actual);
Assert.False(testResult.Pass, testResult.Message);
}
else
{
Assert.True(testResult.Pass, testResult.Message);
}
break;
case "GIVE_VISIBLE_PAGES_MEANINGFUL_NAMES":
if (testResult.ParentDisplayName == "Page 1")
{
Assert.False(testResult.Pass, testResult.Message);
}
else
{
Assert.False(testResult.Pass, testResult.Message);
}
break;
case "DENEB_CHARTS_PROPERTIES":
//TODO: complete this test
//Assert.False(testResult.Pass, testResult.Message);
break;
case "CHECK_FOR_VISUALS_OVERLAP":
expected = "[\"2beb787442a6d0432b4d\",\"11f540db1a90abb52cda\",\"93e80741178005eb0ab4\",\"dead16c359819062e164\"]";
if (testResult.ParentDisplayName == testResult.RuleId)
{
JsonAssert.AreEquivalent(JsonNode.Parse(expected), testResult.Actual);
Assert.False(testResult.Pass, testResult.Message);
}
break;
case "CHECK_FOR_LOCAL_MEASURES":
//TODO: complete this test
//Assert.False(testResult.Pass, testResult.Message);
break;
case "REPORT_THEME_NAME":
Assert.False(testResult.Pass, testResult.Message);
break;
case "REPORT_THEME_TITLE_FONT":
Assert.False(testResult.Pass, testResult.Message);
break;
default:
Assert.True(testResult.Pass, testResult.Message);
break;
}
}
#endregion

#region JsonLogicSuite
/// <summary>
/// Test PBIX using the base JsonLogicTest file to make sure we didn't break JsonLogic