-
Notifications
You must be signed in to change notification settings - Fork 634
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
Homepage tests refactor #15078
base: master
Are you sure you want to change the base?
Homepage tests refactor #15078
Conversation
- refactored tests to simplify the async interaction - all tests are now async Task instead of Void - introduced a state monitoring for the HomePage similar to the NotificationExtension
- eliminating possible causes - current assumption is that the concurrent initialization of webView2 from multiple test instances leads to lock
- attempt to resolve potential resource lock by introducing unique user data folder for webView2
I'd like to understand some of the assumptions made here:
@pinzart90 had discovered many issues with the existing tests that used webview2 - @pinzart90 can you share some invariants or best practices that need to be followed to keep these tests from affecting each other? |
var webViewProcess = Process.GetProcessById(webViewProcessId); | ||
|
||
this.dynWebView.Dispose(); | ||
webViewProcess.WaitForExit(3000); |
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.
you might be able to use this event dynWebView.CoreWebView2.Environment.BrowserProcessExited
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.
Oh, great, I can definitely do that. Thank you for the suggestion.
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.
probably have to clean it up too..
@@ -143,14 +145,17 @@ private async void UserControl_Loaded(object sender, System.Windows.RoutedEventA | |||
PathHelper.CreateFolderIfNotExist(userDataDir.ToString()); | |||
var webBrowserUserDataFolder = userDataDir.Exists ? userDataDir : null; | |||
|
|||
var userDataFolder = CreateUniqueUserDataFolder(webBrowserUserDataFolder.FullName); |
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.
this has not been a problem with other vebview2 tests...
Are you certain this solves your test issues ?
Also maybe we should just create and cleanup these unique folders only during testing ? either use the testing flag...or make these APIs accessible to the test project and call them directly from there.
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.
For the time being, testing things locally, I didn't run on any sporadic test failures as before.
I was also thinking that maybe this is only necessary under test environment, so if the build completes correctly, I can make the necessary changes.
Hi @mjkkirschner - I am indeed making a few assumptions here without any more evidence but the previous timing out on master-15.
I will wait for master-15 build to finish or timeout and at least we will have some more data to work with. |
- dynWebView.CoreWebView2.Environment.UserDataFolder was failing
UI Smoke TestsTest: success. 2 passed, 0 failed. |
I also see here that you did not implement a standard Dispose pattern. ALso not sure why we have this font file stuff here https://github.com/DynamoDS/Dynamo/blob/master/src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs#L482 Also I am not sure if we should overly complicate the homepage with unique userData folders if we do not need to. As for the tests, I think it is a good idea to wait for the webview2 control to be initialized before you further interact with it (like scripting) Not sure why you need CloseViewAndCleanup in each test. The HomePageTest class is derived from Also you seem to allocate the HomePageViewModel (oddly called StartPageViewModel) inside each test and then leave it to the view.Close events to clean up the HomePageView which references the HomePageViewModel in its Dispose. You should assume that the StartPageViewModel might be already destroyed when using it inside the HomePageView Also not sure about the TestHook system. If you only need to test the interaction between dynamo UI and web, then why not just override the "scriptObject" in each test ? ex homePage.dynWebView.CoreWebView2.AddHostObjectToScript("scriptObject", lambdas ...) in your tests ? |
Thank you for the very detailed review and response @pinzart90, I really do appreciate it! Let me mull over all the pointers you left, and if it's OK I can ping offline to elaborate if something is not clear. |
- ignoring tests again to see if allowing the HomePage to be initialized at all during Test mode is causing the time out - remove old code
- revert allowing HomePage initialization under test mode
What is the state of this PR? @dnenov Is it now more ready for review? |
Purpose
HomePage tests refactor. So far, async tests have been causing timeout when ran on
master-15
. This PR attempts to address the potential resource lock that might be causing the issue. The assumption is that the lock happens when multiple tests attempt to initializewebView2
at the same time, which points to the same user data folder. Here, we are introducing unique data folders each time the HomePage is initialized. The unique data folder is deleted during theDispose
routine.Declarations
Check these if you believe they are true
*.resx
filesRelease Notes
user data folder
for webView2Reviewers
@QilongTang
@mjkkirschner
@RobertGlobant20
FYIs
@Amoursol