-
Notifications
You must be signed in to change notification settings - Fork 60
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
Bug fix/39866 TA selecting in POM Page #4029
Bug fix/39866 TA selecting in POM Page #4029
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs (1)
226-233
: Consider adding validation and documentation for platform compatibility.While the logic to show both Mobile and Web platforms for mobile applications is sensible, consider:
- Adding validation to ensure the selected application is compatible with the current test context
- Documenting this behavior in code comments to explain why mobile platforms include web applications
if (targetPlatform == ePlatformType.Mobile) { + // Mobile platforms include Web applications to support hybrid apps and web views xTargetApplicationComboBox.ItemsSource = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.Platform is ePlatformType.Mobile or ePlatformType.Web).ToList(); + // TODO: Add validation to ensure selected application is compatible with current test context }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs
(2 hunks)
🔇 Additional comments (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs (1)
Line range hint 226-255
: Verify the impact of platform filtering changes.
The changes to platform filtering logic could affect existing tests and automation. Let's verify the impact:
✅ Verification successful
Based on the search results, I can now provide a final response:
Platform filtering changes appear to be isolated and safe
The changes to platform filtering logic in POMEditPage.xaml.cs
appear to have limited impact because:
- The
POMEditPage
class is only instantiated in 4 locations across the codebase - No test files were found that directly test this functionality
- The platform filtering pattern
Platform is ePlatformType.Mobile
is unique to this file
The changes only affect the UI filtering of available platforms in the combo box and don't modify any core functionality or data structures.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for POMEditPage usage and potential test files
# Find test files related to POMEditPage
echo "Searching for test files..."
rg -l "POMEditPage" --glob "*Test*.cs"
# Find usages of POMEditPage
echo "Searching for POMEditPage usages..."
ast-grep --pattern 'new POMEditPage($$$)'
# Find similar platform filtering logic that might need updates
echo "Searching for similar platform filtering patterns..."
rg -A 3 "Platform is ePlatformType.Mobile"
Length of output: 7648
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs
Outdated
Show resolved
Hide resolved
…m/Ginger-Automation/Ginger into BugFix/39866_TAnotSelectingIn_POM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs (2)
128-136
: Consider extracting agent initialization logic.The agent initialization loop could be moved to a separate method for better maintainability. Also, consider adding error handling for agent initialization failures.
+private void InitializeAgentOperations(ObservableList<Agent> agents) +{ + foreach (Agent agent in agents) + { + try + { + if (agent.AgentOperations == null) + { + AgentOperations agentOperations = new AgentOperations(agent); + agent.AgentOperations = agentOperations; + } + } + catch (Exception ex) + { + Reporter.ToLog(eLogLevel.ERROR, $"Failed to initialize agent operations for {agent.Name}", ex); + } + } +}Then update the initialization code:
ObservableList<Agent> optionalAgentsList = SupportedAgents(); -foreach (Agent agent in optionalAgentsList) -{ - if (agent.AgentOperations == null) - { - AgentOperations agentOperations = new AgentOperations(agent); - agent.AgentOperations = agentOperations; - } -} +InitializeAgentOperations(optionalAgentsList);
235-241
: Consider using constants and case-insensitive comparison.The string comparison for app type could be more robust:
-string appType = string.Empty; -bool isWebAppType = false; -if (mAgent != null) -{ - appType = mAgent.DriverConfiguration.FirstOrDefault(p => string.Equals(p.Parameter, "AppType"))?.Value ?? ""; - isWebAppType = string.Equals(appType, eAppType.Web.ToString()); -} +const string APP_TYPE_PARAM = "AppType"; +bool isWebAppType = mAgent?.DriverConfiguration + .FirstOrDefault(p => string.Equals(p.Parameter, APP_TYPE_PARAM, StringComparison.OrdinalIgnoreCase)) + ?.Value.Equals(eAppType.Web.ToString(), StringComparison.OrdinalIgnoreCase) ?? false;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs
(5 hunks)
🔇 Additional comments (3)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs (3)
22-22
: LGTM: Import required for mobile platform support.
The added import is necessary for the enhanced mobile platform handling.
71-71
: LGTM: Null-safe agent update.
The null-safe call to SetAgent
prevents potential null reference exceptions.
298-298
: LGTM: Proper collection change handling.
The collection change handler correctly updates the supported target applications when the collection changes.
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs (3)
125-144
: Consider extracting agent initialization logic.The agent initialization logic in the constructor is becoming complex. Consider extracting it to a separate method for better maintainability.
-mAppPlatform = WorkSpace.Instance.Solution.GetTargetApplicationPlatform(POM.TargetApplicationKey); -GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xAgentControlUC, ucAgentControl.SelectedAgentProperty, this, nameof(Agent)); -ObservableList<Agent> optionalAgentsList = SupportedAgents(); -foreach (Agent agent in optionalAgentsList) -{ - if (agent.AgentOperations == null) - { - AgentOperations agentOperations = new AgentOperations(agent); - agent.AgentOperations = agentOperations; - } -} -if (DefaultAgentGuid == null) -{ - xAgentControlUC.Init(optionalAgentsList, mPOM.LastUsedAgent); -} -else -{ - xAgentControlUC.Init(optionalAgentsList, (Guid)DefaultAgentGuid); -} +InitializeAgents(POM); +private void InitializeAgents(ApplicationPOMModel POM) +{ + mAppPlatform = WorkSpace.Instance.Solution.GetTargetApplicationPlatform(POM.TargetApplicationKey); + GingerCore.GeneralLib.BindingHandler.ObjFieldBinding(xAgentControlUC, ucAgentControl.SelectedAgentProperty, this, nameof(Agent)); + + ObservableList<Agent> optionalAgentsList = SupportedAgents(); + InitializeAgentOperations(optionalAgentsList); + + var agentGuid = DefaultAgentGuid ?? mPOM.LastUsedAgent; + xAgentControlUC.Init(optionalAgentsList, agentGuid); +} + +private void InitializeAgentOperations(ObservableList<Agent> agents) +{ + foreach (Agent agent in agents) + { + if (agent.AgentOperations == null) + { + agent.AgentOperations = new AgentOperations(agent); + } + } +}
237-260
: Consider using LINQ for better readability.The
SupportedTargetApplication
method's conditional logic can be simplified using LINQ.-if (targetPlatform != ePlatformType.NA) -{ - if (targetPlatform == ePlatformType.Mobile && MobileWebApptypeFlag) - { - xTargetApplicationComboBox.ItemsSource = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.Platform is ePlatformType.Mobile or ePlatformType.Web).ToList(); - } - else - { - xTargetApplicationComboBox.ItemsSource = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => x.Platform == targetPlatform).ToList(); - } -} -else -{ - xTargetApplicationComboBox.ItemsSource = WorkSpace.Instance.Solution.ApplicationPlatforms.Where(x => ApplicationPOMModel.PomSupportedPlatforms.Contains(x.Platform)).ToList(); -} +var platforms = WorkSpace.Instance.Solution.ApplicationPlatforms; +xTargetApplicationComboBox.ItemsSource = targetPlatform switch +{ + ePlatformType.NA => platforms.Where(x => ApplicationPOMModel.PomSupportedPlatforms.Contains(x.Platform)), + ePlatformType.Mobile when MobileWebApptypeFlag => platforms.Where(x => x.Platform is ePlatformType.Mobile or ePlatformType.Web), + _ => platforms.Where(x => x.Platform == targetPlatform) +}.ToList();
290-319
: Improve null handling in MobileAgentAppTypeValidation.The method could benefit from null coalescing operators and early returns for better readability.
private bool MobileAgentAppTypeValidation() { MobileWebApptypeFlag = false; DefaultAgentGuid = null; var lastAgentID = mPOM.LastUsedAgent; var agents = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<Agent>(); - var lastUsedAgent = mAgent ?? agents.FirstOrDefault(x => x.Guid == lastAgentID); - bool isDefaultUsed = false; + var lastUsedAgent = mAgent ?? agents.FirstOrDefault(x => x.Guid == lastAgentID) + ?? agents.FirstOrDefault(x => x.Platform == mAppPlatform); + bool isDefaultUsed = lastUsedAgent?.Guid != lastAgentID; - if (lastUsedAgent == null) - { - lastUsedAgent = agents.FirstOrDefault(x => x.Platform == mAppPlatform); - isDefaultUsed = true; - } + if (lastUsedAgent == null) return false; - if (lastUsedAgent != null) - { - var appType = lastUsedAgent.DriverConfiguration - .FirstOrDefault(p => string.Equals(p.Parameter, "AppType", StringComparison.OrdinalIgnoreCase))?.Value ?? string.Empty; - MobileWebApptypeFlag = string.Equals(appType, eAppType.Web.ToString(), StringComparison.OrdinalIgnoreCase); + var appType = lastUsedAgent.DriverConfiguration + .FirstOrDefault(p => string.Equals(p.Parameter, "AppType", StringComparison.OrdinalIgnoreCase)) + ?.Value ?? string.Empty; + MobileWebApptypeFlag = string.Equals(appType, eAppType.Web.ToString(), StringComparison.OrdinalIgnoreCase); - if (isDefaultUsed && MobileWebApptypeFlag) - { - DefaultAgentGuid = lastUsedAgent.Guid; - } + if (isDefaultUsed && MobileWebApptypeFlag) + { + DefaultAgentGuid = lastUsedAgent.Guid; } return MobileWebApptypeFlag; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs
(5 hunks)
🔇 Additional comments (3)
Ginger/Ginger/ApplicationModelsLib/POMModels/POMEditPage.xaml.cs (3)
22-22
: LGTM: Mobile driver import added.
The addition of the mobile driver import aligns with the enhanced mobile platform support.
71-71
: LGTM: Agent property update.
The update to set the agent in the POM elements page maintains consistency across the UI.
322-322
: LGTM: Collection changed handler update.
The update to call SupportedTargetApplication
in the collection changed handler maintains UI consistency.
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit
New Features
Bug Fixes