-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
MatAutocompleteHarness doesn't open on focus()
or getOptions()
#29714
Comments
My experience in cases like this is that sometimes Chrome doesn't set focus if the tab isn't in focus. It's possible that in your test environment something moves the Chrome window to the background (e.g. multiple test runs happening in parallel). |
The MatAutocompleteHarness is not opening when invoking the focus() method or calling getOptions(). This regression appears to have emerged after updating from Puppeteer version 23.1.1 to 23.3.0, potentially linked to how Chromium manages focus. Steps to Resolve typescript Verify the Active Element: After focusing, check that the correct element is active. Use ownerDocument.activeElement to confirm which element is currently focused. typescript const activeElement = matAutocompleteHarness.element().ownerDocument.activeElement; Run Tests Sequentially: Since issues arise when tests run in parallel, ensure that tests are executed sequentially to maintain focus consistency. Use the --single-run flag when running tests to limit test execution. ng test --single-run npm install puppeteer@latest @angular/core@latest @angular/material@latest Check for Focus Interference: If other tests or actions interfere with focus, isolate your tests better. Structure your test cases using describe and it blocks effectively to ensure that focus state does not leak across tests. typescript describe('MatAutocomplete Tests', () => { Fallback and Workaround: If the above methods do not resolve the issue, consider using a manual workaround by directly triggering the dropdown programmatically as a temporary measure while investigating the underlying cause. typescript await matAutocompleteHarness.open(); |
Inserting |
Is this a regression?
The previous version in which this bug was not present was
Puppeteer 23.1.1
Description
I guess somewhere between Puppeteer v. 23.1.1 and 23.3.0 Chromium must have been changed in a significant way.
Seems to be this bug again: #23757
Also
routerHarness.fixture.nativeElement.querySelector(':focus')
returns null whilerouterHarness.routeNativeElement?.ownerDocument.activeElement
works.Somehow these issues don't come up if the specific test is executed in isolation. It might depend on the order of execution.
Environment
Angular 18.2.3 / Jasmine 5.3.0 / Karma 6.4.4 / Puppeteer 23.3.0 / Linux
The text was updated successfully, but these errors were encountered: