Open fredvisser opened 2 years ago
As part of this work it could be helpful to make the helpers in async-test-utilities available to clients via our public API. In this PR a client ended up duplicating one of those APIs.
As part of this work, we need to find a way to capture the async timing behavior: https://github.com/ni/nimble/issues/362#issuecomment-1054457992 Wonder if it is possible to plugin to zonejs for some of that and if zonejs needs an issue for the slotchanged events
Another example use case appeared on this AzDO PR. The page object for the properties list component is explicitly firing an input
event on the nimble-text-field
in order to trigger its change event handler. Nimble might want to provide a higher level harness that sets a value and triggers the event.
Same for nimble-number-field (this was explicitly requested by the Argon team in a chat with me on 4/6/22). For the number field we should ensure it works well with both 'value' (string) and 'valueAsNumber' (numeric).
@gokulakrishnan-ni wanted to be able to simulate button click interactions in test. The approach that was used was not aware of disabled state. Pointed to the FAST approach which was to run the click
method on the button in test which is disabled state aware: https://github.com/microsoft/fast/blob/231bf286ef7eb981e392d65651621ad4d325162a/packages/web-components/fast-foundation/src/button/button.spec.ts#L583
We should be aware of how users are expected to use JS-based test harnesses in test frameworks like test cafe: https://ni.visualstudio.com/DevCentral/_git/srd-semi-ses-software/pullrequest/278853?discussionId=2905287&_a=files&path=%2fArgon%2fServices%2fEnd2EndTests%2ftests%2fpage-objects%2flogin-page.js
Some more good examples in the pageobject this PR. Specifically all the methods that operate on the nimble-select
but have to do innerText.trim()
to access the correct item in the drop down. Preferably the select would expose a page object that contained methods like selectOption()
and getSelectOptions()
.
In this PR, I had to write a pageObject method implementation to do some fairly specific event dispatching coupled with particular state changes, to achieve an analogous user interaction behavior. It might be beneficial to capture this sort of user interaction with the Combobox in a Nimble test harness.
I'm closing #362 because that issue included a collection of tips that are too low-level to document but would be great candidates to include in a page object for nimble-tabs. If we work on this issue we should mine that discussion thread for ideas around fakeAsync
and requestAnimationFrame
.
Some interesting topics:
As part of this work it could be helpful to make the helpers in async-test-utilities available to clients via our public API. In this PR a client ended up duplicating one of those APIs.
A bit on the fence about exposing the waitMicrotask
and waitTask
helpers publically. Those aren't nimble-specific but general tools for the web. If sharing them is useful maybe they should be their own library.
Another way to look at the issue is that clients are needing to be aware of those implementation details of nimble controls (I make an update and need to waitMicrotask or waitTask for X ms). Talking to @atmgrifter00 hopefully user's needing to be aware of those details could be mitigated altogether with good page objects for the controls.
@rajsite pointed out that the FAST element 2 refactor of the task queue now exposes a mode to process async tasks synchronously in tests. We could consider telling clients to use that mode (and maybe have our page objects only work in that mode) and avoid us manually managing the queue via processUpdates
.
Another use case from this PR:
title-hidden
set)Playwright page objects might be a good way to address #1339. The way to check if an element is disabled changes depending on the type of element and that logic could be encapsulated in a page object.
I spent an innovation day trying to write a page object for select. Got it fairly far along but didn't end up submitting it, so linking it here as a starting point if we ever prioritize this. #1500
We have slowly made progress on this issue by adding a few new page objects. But there are open questions on best practices that we should reach consensus on and document somewhere. Some of this was discussed in this thread.
@internal
commentstable/testing/tests/table.pageobject.spec.ts
(while component tests are in table/tests/table.spec.ts
: note the extra testing
folder). This allows /tests
to be excluded from package contents and also for clients to import page objects from a different /testing
entry point than the component itself and potentially enforce via linting that production code doesn't rely on page objectsfakeAsync
and should call processUpdates
not waitForUpdatesAsync
)
processUpdates
more generally when possible since it should work in both contexts and will be faster (avoids 16ms wait)In a discussion today the team agreed on items 1-5 and want to continue refining the items in 6. I will capture those guidelines in CONTRIBUTING and update some page objects to follow them in an upcoming PR.
Copied from User Story 1537054: Evaluate testing APIs that components should expose to client applications
(See also the comments in that US)
It should be easy for a client application to write a test which includes a component in the page, configures it, interacts with it, and inspects its visual state.
We've had good success following Angular Material's test harness/page object pattern and we had many challenges with the testability of Smart elements. We should evaluate what testing APIs the nimble components need to expose to be delightful for client applications to consume them.
The primary goal for now is Angular client applications, but we should see if we can write this layer at the nimble-components level so that other frameworks could take advantage of it too.
Current status
A branch exists that includes:
A not building branch exists that shows what it looks like to use that page object in an Angular app.
Possible next steps