Skip to content

Commit

Permalink
Accessiblity Review comment handled
Browse files Browse the repository at this point in the history
  • Loading branch information
prashelke committed Aug 6, 2024
1 parent d9b80dd commit 3cea8eb
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 75 deletions.
43 changes: 17 additions & 26 deletions Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,23 @@ public partial class AccessibilityRulePage : Page
{
Solution mSolution;
string AppName;
List<string> DefaultExcludeRulesList;
private AccessibilityConfiguration mAccessibilityConfiguration;
private static ActAccessibilityTesting actAccessibilityTesting;
public AccessibilityRulePage()
{
InitializeComponent();
mSolution = WorkSpace.Instance.Solution;
string allProperties = string.Empty;
WorkSpace.Instance.PropertyChanged += WorkSpacePropertyChanged;
actAccessibilityTesting = new ActAccessibilityTesting();

Check warning on line 43 in Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs#L43

Remove this assignment of 'actAccessibilityTesting' or initialize it statically.
LoadGridData();
SetAppsGrid();
mAccessibilityConfiguration = WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem<AccessibilityConfiguration>();
mAccessibilityConfiguration.DefaultExcludeRule = mAccessibilityConfiguration.DefaultExcludeRule != null ? mAccessibilityConfiguration.DefaultExcludeRule : new ();
}
private void WorkSpacePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(WorkSpace.Solution))
{
mSolution = WorkSpace.Instance.Solution;
LoadGridData();
}
mAccessibilityConfiguration = !WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<AccessibilityConfiguration>().Any() ? new AccessibilityConfiguration() : WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem<AccessibilityConfiguration>();
mAccessibilityConfiguration.ExcludedRules = mAccessibilityConfiguration.ExcludedRules != null ? mAccessibilityConfiguration.ExcludedRules : new ();
}

private void SetAppsGrid()
{
xAccessibilityRulesGrid.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))}", null, null, true);
GridViewDef view = new GridViewDef(GridViewDef.DefaultViewName);
view.GridColsView = new ObservableList<GridColView>();
view.GridColsView.Add(new GridColView()
Expand Down Expand Up @@ -98,15 +90,14 @@ private void SetAppsGrid()
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.");
xAccessibilityRulesGrid.AddLabel("Note: Ginger will only analyze the active accessibility testing rules; inactive rules will not be considered.");

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];
xAccessibilityRulesGrid.DataSourceList = accessibilityRuleDatas;
Expand All @@ -122,26 +113,26 @@ private void CheckBox_Click(object sender, RoutedEventArgs e)
mAccessibilityConfiguration.StartDirtyTracking();
if (!data.Active)
{
if (!mAccessibilityConfiguration.DefaultExcludeRule.Any(x => x.Equals(data.RuleID)))
if(!mAccessibilityConfiguration.ExcludedRules.Any())
{
GingerCoreNET.GeneralLib.General.CreateDefaultAccessiblityconfiguration();
mAccessibilityConfiguration = WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem<AccessibilityConfiguration>();
mAccessibilityConfiguration.ExcludedRules = mAccessibilityConfiguration.ExcludedRules != null ? mAccessibilityConfiguration.ExcludedRules : new();
}

if (!mAccessibilityConfiguration.ExcludedRules.Any(x => x.Equals(data.RuleID)))
{
mAccessibilityConfiguration.DefaultExcludeRule.Add(data);
mAccessibilityConfiguration.ExcludedRules.Add(data);
}

}
else
{
if (mAccessibilityConfiguration.DefaultExcludeRule.Any(x => x.Equals(data.RuleID)))
if (mAccessibilityConfiguration.ExcludedRules.Any(x => x.Equals(data.RuleID)))
{
mAccessibilityConfiguration.DefaultExcludeRule.Remove(data);

mAccessibilityConfiguration.ExcludedRules.Remove(data);
}
}
}
}

private void SaveHandler(object sender, RoutedEventArgs e)
{
mSolution.SolutionOperations.SaveSolution(true, Solution.eSolutionItemToSave.DefaultExcludeRule);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ public class AccessibilityConfiguration : RepositoryItemBase



ObservableList<AccessibilityRuleData> mDefaultExcludeRule;
ObservableList<AccessibilityRuleData> mExcludedRules;
[IsSerializedForLocalRepository]
public ObservableList<AccessibilityRuleData> DefaultExcludeRule
public ObservableList<AccessibilityRuleData> ExcludedRules
{
get
{
return mDefaultExcludeRule;
return mExcludedRules;
}
set
{
if (mDefaultExcludeRule != value)
if (mExcludedRules != value)
{
mDefaultExcludeRule = value;
OnPropertyChanged(nameof(DefaultExcludeRule));
mExcludedRules = value;
OnPropertyChanged(nameof(ExcludedRules));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class AccessibilityRuleData : RepositoryItemBase, INotifyPropertyChanged
public ObservableList<AccessibilityRuleData> GetAccessibilityRules(string AccessbiltyString)
{
Root data = new();
data.accessibilityRules = [];
try
{
data = JsonConvert.DeserializeObject<Root>(AccessbiltyString);
Expand Down
23 changes: 1 addition & 22 deletions Ginger/GingerCoreCommon/WorkSpaceLib/Solution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ public class Solution : RepositoryItemBase, ISolution
public Solution()
{
Tags = new ObservableList<RepositoryItemTag>();
DefaultExcludeRule = new AccessibilityConfiguration();
}

public enum eSolutionItemToSave { GeneralDetails, TargetApplications, GlobalVariabels, Tags, ALMSettings, SourceControlSettings, LoggerConfiguration, ReportConfiguration, DefaultExcludeRule }
public enum eSolutionItemToSave { GeneralDetails, TargetApplications, GlobalVariabels, Tags, ALMSettings, SourceControlSettings, LoggerConfiguration, ReportConfiguration }

string mName;
[IsSerializedForLocalRepository]
Expand All @@ -80,26 +79,6 @@ public string Name
public ObservableList<RepositoryItemTag> Tags;


private AccessibilityConfiguration mDefaultExcludeRule;

[IsSerializedForLocalRepository]
public AccessibilityConfiguration DefaultExcludeRule
{
get
{
return mDefaultExcludeRule;
}
set
{
if (mDefaultExcludeRule != value)
{
mDefaultExcludeRule = value;
OnPropertyChanged(nameof(DefaultExcludeRule));
}
}
}


private string mAccount;

/// <summary>
Expand Down
35 changes: 29 additions & 6 deletions Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,31 @@ public ObservableList<AccessibilityRuleData> RulesItemsdata
public ObservableList<AccessibilityRuleData> GetRuleList()
{
AccessibilityRuleData AccessibilityRuleDataObjet = new AccessibilityRuleData();
AccessibilityConfiguration mAccessibilityConfiguration = WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem<AccessibilityConfiguration>();
mAccessibilityConfiguration.DefaultExcludeRule = mAccessibilityConfiguration.DefaultExcludeRule != null ? mAccessibilityConfiguration.DefaultExcludeRule : new();
ObservableList<AccessibilityRuleData> ruleDatalist = new ObservableList<AccessibilityRuleData>();
AccessibilityConfiguration mAccessibilityConfiguration = new ();

Check warning on line 309 in Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs#L309

Remove this useless assignment to local variable 'mAccessibilityConfiguration'.
if (WorkSpace.Instance.SolutionRepository != null)
{
if(!WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<AccessibilityConfiguration>().Any())
{
mAccessibilityConfiguration = new();
}
else
{
mAccessibilityConfiguration = WorkSpace.Instance.SolutionRepository.GetFirstRepositoryItem<AccessibilityConfiguration>();
}
}
else
{
mAccessibilityConfiguration = new ();
}
mAccessibilityConfiguration.ExcludedRules = mAccessibilityConfiguration.ExcludedRules != null ? mAccessibilityConfiguration.ExcludedRules : new();
ObservableList<AccessibilityRuleData> ruleDatalist = new ();

Check warning on line 326 in Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/GingerCoreNET/ActionsLib/UI/Web/ActAccessibilityTesting.cs#L326

Remove this useless assignment to local variable 'ruleDatalist'.
try
{
string AccessbiltyString = GetAccessiblityrules();
ruleDatalist = AccessibilityRuleDataObjet.GetAccessibilityRules(AccessbiltyString);
foreach (AccessibilityRuleData ruleData in ruleDatalist)
{
if (mAccessibilityConfiguration.DefaultExcludeRule != null && mAccessibilityConfiguration.DefaultExcludeRule.Select(x=>x.RuleID).Contains(ruleData.RuleID))
if (mAccessibilityConfiguration.ExcludedRules != null && mAccessibilityConfiguration.ExcludedRules.Select(x=>x.RuleID).Contains(ruleData.RuleID))
{
ruleData.Active = false;
}
Expand All @@ -328,7 +343,7 @@ public ObservableList<AccessibilityRuleData> GetRuleList()
catch (Exception ex)
{
Error = "Error: during accessibility testing:" + ex.Message;
Reporter.ToLog(eLogLevel.ERROR, "Error: during accessibility testing", ex);
Reporter.ToLog(eLogLevel.ERROR, $"Error: during accessibility testing in GetRuleList. Configuration: {mAccessibilityConfiguration?.Name}", ex);
}
return ruleDatalist;
}
Expand Down Expand Up @@ -376,7 +391,15 @@ public enum ReportTypes

private static string GetAccessiblityrules()
{
return EmbeddedResourceProvider.ReadEmbeddedFile("AccessiblityRules.json");
try
{
return EmbeddedResourceProvider.ReadEmbeddedFile("AccessiblityRules.json");
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error reading accessibility rules from embedded file", ex);
return string.Empty;
}
}

public void CreateAxeHtmlReport(ISearchContext context, AxeResult results, string destination, ReportTypes requestedResults)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@
"Issue Type": "failure, needs review",
"ACT Rules": "97a4e1"
},
{
"RuleID": "summary-name",
"Description": "Ensure summary elements have discernible text",
"Impact": "Serious",
"Tags": "cat.name-role-value, wcag2a, wcag412, section508, section508.22.a, TTv5, TT6.a, EN-301-549, EN-9.4.1.2",
"Issue Type": "failure, needs review",
"ACT Rules": ""
},
{
"RuleID": "aria-conditional-attr",
"Description": "Ensure ARIA attributes are used as described in the specification of the element's role",
Expand Down
18 changes: 13 additions & 5 deletions Ginger/GingerCoreNET/GeneralLib/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,14 +619,22 @@ public static string CreateReportLinkPerFlow(string HtmlReportUrl, string Execut

public static bool CreateDefaultAccessiblityconfiguration()
{
if (!WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<AccessibilityConfiguration>().Any())
try
{
AccessibilityConfiguration newAccessibilityConfiguration = new AccessibilityConfiguration() { Name = "Accessibility" };
WorkSpace.Instance.SolutionRepository.AddRepositoryItem(newAccessibilityConfiguration);
return true;
if (!WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<AccessibilityConfiguration>().Any())
{
AccessibilityConfiguration newAccessibilityConfiguration = new AccessibilityConfiguration() { Name = "Accessibility" };
WorkSpace.Instance.SolutionRepository.AddRepositoryItem(newAccessibilityConfiguration);
return true;
}
else
{
return false;
}
}
else
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.ERROR, "Error creating default accessibility configuration", ex);
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions Ginger/GingerCoreNET/WorkSpaceLib/WorkSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ private void CheckForExistingEnterpriseFeaturesConfiguration()
{
WorkSpace.Instance.UserProfile.ShowEnterpriseFeatures = true;
}

}

public bool OpenSolution(string solutionFolder, string encryptionKey = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class AccessiblityTests
{

private static IWebDriver _driver;
static ActAccessibilityTesting mact;
ActAccessibilityTesting mact;

Check notice on line 47 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#L47

Remove the field 'mact' and declare it as a local variable in the relevant methods.
IWebElement e = null;

[ClassInitialize()]
Expand Down Expand Up @@ -164,6 +164,7 @@ public void TestCreateAxeBuilder_IsNotNull()
{
return;
}
mact = new ActAccessibilityTesting();
AxeBuilder axeBuilder = mact.CreateAxeBuilder(_driver);
Assert.AreNotEqual(null, axeBuilder);
}
Expand All @@ -175,9 +176,10 @@ public void TestGetRuleList_isNotNull()
{
return;
}
mact = new ActAccessibilityTesting();
ObservableList<AccessibilityRuleData> ruleList = mact.GetRuleList();
Assert.AreNotEqual(null, ruleList);
Assert.AreEqual(93, ruleList.Count);
Assert.AreEqual(92, ruleList.Count);
}

public static ObservableList<OperationValues> GetStandardTagslist()
Expand Down

0 comments on commit 3cea8eb

Please sign in to comment.