-
Notifications
You must be signed in to change notification settings - Fork 8
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
Documentation for Nimble Tabs UI Testing #362
Comments
@gokulakrishnan-ni, what was the behavior difference that you observed? Could you post a code snippet explaining what you're trying to do (e.g. put contents on a tab, change the active tab, read the visible tab, etc)? |
@jattasNI Our understanding is that the nimble-tabs element hides and shows the nimble-tab-panels based on the nimble-tab clicked. The nimble-tab-panels with "hidden" attribute are hidden in the UI. During development we could see the "hidden" attribute being added to the nimble-tab-panels (refer second image attached) but while running test we couldn't see "hidden" attribute in any of the nimble-tab-panels, making it hard to find which panel is selected as all the panels are displayed. Please let us know if we are missing something in the test environment. This is a screenshot of Elements tab from browser during test |
@jattasNI Similarly in nimble-select, during development the nimble-select element has an attribute "open" when the dropdown list is displayed but during test the "open" attribute is not seen after dispatching click event. |
Thanks for the detailed explanation @gokulakrishnan-ni! Nimble relies on the implementation and test patterns of the underlying FAST library for the tab component. Scanning through their tests, there are a few APIs that are supposed to work:
If none of these are working for you, we'll have to do a little more digging to see what's different between your test setup and FAST's. Some possibilities:
If you try these suggestions and still don't get anywhere, please send us a link to the test in question and we can try to debug it too. |
@jattasNI We tried running the tests under |
In our call today @rajsite showed the patterns used by nimble-tabs.directive.spec.ts. This calls |
Found that the tabs and select tests in nimble had to pause for a full task (setTimeout(..,0)) before running. The PR for the test gave the following description:
|
@gokulakrishnan-ni Something important to know is that any attribute changes in these components won't be reflected until the next animation frame. So if you write an async test, it may look something like this: tab.click();
await new Promise(requestAnimationFrame);
expect(otherTab.getAttribute('hidden')).not.toBeNull(); Or, if you want to use Angular's fakeAsync utility: fakeAsync(() => {
tab.click();
processUpdates(); // this function is exported from nimble-angular
expect(otherTab.getAttribute('hidden')).not.toBeNull();
}) We have some good examples of testing these components with |
We provided guidance in this issue to unblock the request and I captured some notes to include that guidance in future page objects in #265. I think that guidance is too low-level to include in public-facing docs so I'm going to close this issue. |
😯 Problem to Solve
We tried writing UI test for nimble tabs and observed that the nimble tabs showed a different behavior during test. A documentation on writing UI tests for nimble tabs would be helpful.
💁 Proposed Solution
A documentation on writing UI tests for nimble tabs.
The text was updated successfully, but these errors were encountered: