Skip to content

Commit

Permalink
Updated Code
Browse files Browse the repository at this point in the history
  • Loading branch information
prashelke committed Aug 1, 2024
1 parent 245d4d0 commit cf08c3e
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Ginger/Ginger/MenusLib/ConfigurationsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static TwoLevelMenu GetMenu()
twoLevelMenu.Add(externalConfigMenu);

TopMenuItem accessiblityRulesMenu = new TopMenuItem(eImageType.Accessibility, $"{GingerCore.General.GetEnumValueDescription(typeof(eTermResKey), nameof(eTermResKey.AccessibilityRules))}", ConsoleKey.T, $"{GingerCore.General.GetEnumValueDescription(typeof(eTermResKey), nameof(eTermResKey.AccessibilityRules))}", "Name & rules of the Accessibility which been present current json");
accessiblityRulesMenu.Add(eImageType.Application, "", GeAccessiblityRulePage, ConsoleKey.T, "", "AID");
accessiblityRulesMenu.Add(eImageType.Application, "", GetAccessibilityRulePage, ConsoleKey.T, "", "AID");
twoLevelMenu.Add(accessiblityRulesMenu);

return twoLevelMenu;
Expand Down Expand Up @@ -160,9 +160,9 @@ private static Page OthersPage()
return new Page();
}

private static Page GeAccessiblityRulePage()
private static Page GetAccessibilityRulePage()
{
return (new AccessiblityRulePage());
return (new AccessibilityRulePage());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Page x:Class="Ginger.SolutionWindows.AccessiblityRulePage"
<Page x:Class="Ginger.SolutionWindows.AccessibilityRulePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -7,7 +7,7 @@
xmlns:Ginger="clr-namespace:Ginger"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="Accessiblity Rule Page">
Title="Accessibility Rule Page">

<Page.Resources>
<DataTemplate x:Key="CheckBoxTemplate">
Expand All @@ -22,16 +22,16 @@
<RowDefinition
Height="*" />
</Grid.RowDefinitions>
<TextBlock
<!--<TextBlock
FontSize="10">
<TextBlock.Inlines>
<Run
Text="NOTE: "
FontWeight="Bold" />
<Run
Text="Active items can analysis for accessibility." />
Text="Active items can be analyzed for accessibility." />
</TextBlock.Inlines>
</TextBlock>
<Ginger:ucGrid Grid.Row="1" x:Name="xAccessiblityRulesGrid" Title="Accessibility rule list" ShowRefresh="Collapsed" ShowUndo="Collapsed" ShowAdd="Collapsed" ShowSaveAllChanges="Collapsed" ShowSaveSelectedChanges="Collapsed" ShowEdit="Collapsed" ShowClearAll="Collapsed" ShowDelete="Collapsed" ShowUpDown="Collapsed" d:IsHidden="True"/>
</TextBlock>-->
<Ginger:ucGrid Grid.Row="1" x:Name="xAccessibilityRulesGrid" Title="Accessibility rule list" ShowRefresh="Collapsed" ShowUndo="Collapsed" ShowAdd="Collapsed" ShowSaveAllChanges="Collapsed" ShowSaveSelectedChanges="Collapsed" ShowEdit="Collapsed" ShowClearAll="Collapsed" ShowDelete="Collapsed" ShowUpDown="Collapsed" d:IsHidden="True"/>
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
namespace Ginger.SolutionWindows
{
/// <summary>
/// Interaction logic for AccessiblityRulePage.xaml
/// Interaction logic for AccessibilityRulePage.xaml
/// </summary>
public partial class AccessiblityRulePage : Page
public partial class AccessibilityRulePage : Page
{
Solution mSolution;
string AppName;
List<string> DefaultExcludeRulesList;
private AccessibilityConfiguration mAccessibilityConfiguration;
public AccessiblityRulePage()
public AccessibilityRulePage()
{
InitializeComponent();
mSolution = WorkSpace.Instance.Solution;
Expand All @@ -41,7 +41,7 @@ public AccessiblityRulePage()
LoadGridData();
SetAppsGrid();
mAccessibilityConfiguration = new();
DefaultExcludeRulesList = WorkSpace.Instance.Solution.DefaultExcludeRule.DefaultExcludeRules != null ? WorkSpace.Instance.Solution.DefaultExcludeRule.DefaultExcludeRules.Split(',').ToList() : new();
DefaultExcludeRulesList = WorkSpace.Instance.Solution.DefaultExcludeRule.DefaultExcludeRules?.Split(',').ToList() ?? new List<string>();
}

private void WorkSpacePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
Expand All @@ -55,7 +55,7 @@ private void WorkSpacePropertyChanged(object sender, System.ComponentModel.Prope

private void SetAppsGrid()
{
xAccessiblityRulesGrid.SetGridEnhancedHeader(Amdocs.Ginger.Common.Enums.eImageType.Accessibility, $"{GingerCore.General.GetEnumValueDescription(typeof(eTermResKey), nameof(eTermResKey.AccessibilityRules))}", saveAllHandler: SaveHandler, null, true);
xAccessibilityRulesGrid.SetGridEnhancedHeader(Amdocs.Ginger.Common.Enums.eImageType.Accessibility, $"{GingerCore.General.GetEnumValueDescription(typeof(eTermResKey), nameof(eTermResKey.AccessibilityRules))}", saveAllHandler: SaveHandler, null, true);
GridViewDef view = new GridViewDef(GridViewDef.DefaultViewName);
view.GridColsView = new ObservableList<GridColView>();
view.GridColsView.Add(new GridColView()
Expand All @@ -76,8 +76,9 @@ private void SetAppsGrid()
});
view.GridColsView.Add(new GridColView()
{
Field = nameof(AccessibilityRuleData.Tags),
WidthWeight = 30,
Field = nameof(AccessibilityRuleData.Description),
Header = "Description",
WidthWeight = 40,
ReadOnly = true
});
view.GridColsView.Add(new GridColView()
Expand All @@ -90,23 +91,23 @@ private void SetAppsGrid()
});
view.GridColsView.Add(new GridColView()
{
Field = nameof(AccessibilityRuleData.Description),
Header = "Description",
WidthWeight = 40,
Field = nameof(AccessibilityRuleData.Tags),
WidthWeight = 30,
ReadOnly = true
});

xAccessibilityRulesGrid.AddLabel("Note: We will analyze the active items from the list below for accessibility. Testing and deactivating items won't be taken into account for accessibility testing.");

xAccessiblityRulesGrid.SetAllColumnsDefaultView(view);
xAccessiblityRulesGrid.InitViewItems();
xAccessibilityRulesGrid.SetAllColumnsDefaultView(view);
xAccessibilityRulesGrid.InitViewItems();
}

private void LoadGridData()
{
ActAccessibilityTesting actAccessibilityTesting = new ActAccessibilityTesting();
List<AccessibilityRuleData> sortedList = actAccessibilityTesting.RulesItemsdata.OrderByDescending(data => !data.Active).ToList();
ObservableList<AccessibilityRuleData> accessibilityRuleDatas = [.. sortedList];
xAccessiblityRulesGrid.DataSourceList = accessibilityRuleDatas;
xAccessibilityRulesGrid.DataSourceList = accessibilityRuleDatas;
}

private void CheckBox_Click(object sender, RoutedEventArgs e)
Expand All @@ -117,7 +118,7 @@ private void CheckBox_Click(object sender, RoutedEventArgs e)
// Do something with data, for example:
data.Active = checkBox.IsChecked ?? false;
WorkSpace.Instance.Solution.DefaultExcludeRule.StartDirtyTracking();
if (data.Active == false)
if (!data.Active)
{
if (!DefaultExcludeRulesList.Any(x => x.Equals(data.RuleID)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ namespace Ginger.Configurations
{
public class AccessibilityConfiguration : RepositoryItemBase
{
public override string ItemName { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
private string mName;
[IsSerializedForLocalRepository]
public string Name { get { return mName; } set { if (mName != value) { mName = value; OnPropertyChanged(nameof(Name)); } } }
public override string ItemName { get => "Accessibility Configuration"; set { /* set logic here */ } }

Check failure on line 35 in Ginger/GingerCoreCommon/External/Configurations/AccessibilityConfiguration.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/GingerCoreCommon/External/Configurations/AccessibilityConfiguration.cs#L35

Use the 'value' contextual keyword in this property set accessor declaration.

string mDefaultExcludeRules;
[IsSerializedForLocalRepository]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,16 @@ public class AccessibilityRuleData : RepositoryItemBase, INotifyPropertyChanged

public ObservableList<AccessibilityRuleData> GetAccessibilityRules(string AccessbiltyString)
{
ObservableList<AccessibilityRuleData> accessibilityRules = new ObservableList<AccessibilityRuleData>();
Root data = JsonConvert.DeserializeObject<Root>(AccessbiltyString);
Root data = new();
try
{
data = JsonConvert.DeserializeObject<Root>(AccessbiltyString);
}
catch(Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Failed to deserialize accessibility rules.", ex);
}

return data.accessibilityRules;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,57 @@ limitations under the License.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;

namespace GingerCoreNETUnitTest.ActionsLib.UI.Web
{
[TestClass]
[TestCategory(TestCategory.UnitTest)]
[TestCategory(TestCategory.IntegrationTest)]
[Ignore]
public class AccessiblityTests
{

private static IWebDriver _driver;
static ActAccessibilityTesting mact;
IWebElement e = null;

[ClassInitialize()]
public static void ClassInit(TestContext TC)
[TestInitialize()]
public static void TestInit(TestContext TC)
{
//// Initialize the WebDriver (Chrome in this case)
_driver = new ChromeDriver();
if (!OperatingSystem.IsLinux())
{
return;
}

mact = new ActAccessibilityTesting();
mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Target, ActAccessibilityTesting.eTarget.Page);
mact.SeverityList = GetSeverityList();
mact.StandardList = GetStandardTagslist();
}

[ClassCleanup]
[TestCleanup]
public static void ClassCleanup()
{
_driver.Quit();
}

public void InitDriver()
{
//// Initialize the WebDriver (Chrome in this case)
_driver = new ChromeDriver();

Check failure on line 73 in Ginger/GingerCoreNETUnitTest/ActionsLib/UI/Web/AccessiblityTests.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/GingerCoreNETUnitTest/ActionsLib/UI/Web/AccessiblityTests.cs#L73

Make the enclosing instance method 'static' or remove this set on the 'static' field.
}

[TestMethod]
public void TestAnalyzerAccessibility_Standard_Failed()
{
if (!OperatingSystem.IsLinux())
{
return;
}
InitDriver();
_driver.Navigate().GoToUrl($"https://ginger.amdocs.com/");
mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.ByStandard);
if (mact.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.ByStandard))
Expand All @@ -77,6 +94,11 @@ public void TestAnalyzerAccessibility_Standard_Failed()
[TestMethod]
public void TestAnalyzerAccessibility_Severity_Failed()
{
if (!OperatingSystem.IsLinux())
{
return;
}
InitDriver();
_driver.Navigate().GoToUrl($"https://ginger.amdocs.com/");
mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.BySeverity);
if (mact.GetInputParamValue(ActAccessibilityTesting.Fields.Analyzer) == nameof(ActAccessibilityTesting.eAnalyzer.BySeverity))
Expand All @@ -90,6 +112,11 @@ public void TestAnalyzerAccessibility_Severity_Failed()
[TestMethod]
public void TestAnalyzerAccessibility_Standard_Pass()
{
if (!OperatingSystem.IsLinux())
{
return;
}
InitDriver();
string htmlFilePath = Path.Combine(TestResources.GetTestResourcesFolder("Html"), "TestAccessiblity.html");
_driver.Navigate().GoToUrl(htmlFilePath);
mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.ByStandard);
Expand All @@ -104,6 +131,11 @@ public void TestAnalyzerAccessibility_Standard_Pass()
[TestMethod]
public void TestAnalyzerAccessibility_Severity_Pass()
{
if (!OperatingSystem.IsLinux())
{
return;
}
InitDriver();
string htmlFilePath = Path.Combine(TestResources.GetTestResourcesFolder("Html"), "TestAccessiblity.html");
_driver.Navigate().GoToUrl(htmlFilePath);
mact.GetOrCreateInputParam(ActAccessibilityTesting.Fields.Analyzer, ActAccessibilityTesting.eAnalyzer.BySeverity);
Expand All @@ -116,15 +148,26 @@ public void TestAnalyzerAccessibility_Severity_Pass()
}

[TestMethod]
[TestCategory(TestCategory.UnitTest)]
public void TestCreateAxeBuilder_IsNotNull()
{
if (!OperatingSystem.IsLinux())
{
return;
}
InitDriver();
AxeBuilder axeBuilder = mact.CreateAxeBuilder(_driver);
Assert.AreNotEqual(null, axeBuilder);
}

[TestMethod]
[TestCategory(TestCategory.UnitTest)]
public void TestGetRuleList_isNotNull()
{
if (!OperatingSystem.IsLinux())
{
return;
}
ObservableList<AccessibilityRuleData> ruleList = mact.GetRuleList();
Assert.AreNotEqual(null, ruleList);
Assert.AreEqual(93, ruleList.Count);
Expand Down

0 comments on commit cf08c3e

Please sign in to comment.