-
Notifications
You must be signed in to change notification settings - Fork 5
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
TestCafe wait for results #878
Conversation
J=SLAP-1425 TEST= manual & auto
* (default selector timeout of 10 seconds) | ||
*/ | ||
async waitOnSearchComplete () { | ||
if(!this._preSearch.exists) { |
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 my own edification, what is preSearch
?
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.
it's one of the search states from SDK (presearch, loading, completed). I originally thought initial search on page may go from presearch to completed, skipping loading state. Turns out it's just testCafe unable to catch the loading transition. Updated to track query request/responses instead!
await t.expect(this._searchLoading.exists).ok(); | ||
} | ||
await this._searchComplete(); | ||
await t.expect(this._searchComplete.exists).ok(); |
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.
Does await this._searchComplete()
being successful imply t.expect(this._searchComplete.exists).ok()
automatically?
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.
test would still consider passed if await this._searchComplete()
doesn't find any matching element
* wait for results to return based on search complete state | ||
* (default selector timeout of 10 seconds) | ||
*/ | ||
async waitOnSearchComplete () { |
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.
If someone calls this method, but no search has actually been executed, will it timeout? I'm wondering if we should handle that situation gracefully, like it returns immediately. Maybe not something we need to worry about, just a thought.
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.
in this method, and in the updated one, it will timeout eventually. I think if no search is executed and someone uses this method, meaning they are expecting a search or result returned of some sort, it make sense to indicate a failure here to notify that the expected behavior is not met
const waitTimeInterval = 200; | ||
let totalWaitTime = 0; | ||
while (totalWaitTime < responseWaitTimeout | ||
&& this._queryRequestLogger.requests.find(r => !r.response || r.response.statusCode !== 200)) { |
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.
Is this code waiting while an invalid response exists? is there a reason for that approach rather than waiting until a successful response has been logged?
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.
Is it possible to extract the query logger lookup into a variable or a function so that this logic is a litter easier to follow?
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.
Logger will hold all request/response throughout a test so just checking for a successful response might accidentally check on previous requests. But, after some thoughts, I updated this method check for a successful response in the loop, and clear out the logger at the end of this method. This make sure we are always verifying the latest response.
|
||
fixture`Vertical Full Page Map with Filters and Clusters` | ||
.page(`http://localhost:${PORT}/locations_full_page_map_with_filters`) | ||
.beforeEach(async t => { | ||
await VerticalResults.registerLogger(t); | ||
await registerIE11NoCacheHook(t); |
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.
should the ie11 hook go inside registerLogger? like, is there ever a time we would call registerLogger without also registering the ie11 hook?
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.
yeah, that would make sense. Updated!
* Wait for results to load on page by checking query response status and searchComplete state | ||
* (timeout is set to 10 seconds) | ||
*/ | ||
async waitOnSearchComplete() { |
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.
Sorry I know I just recently approved this, but after looking at the SDK half of this item maybe this waitOnSearchComplete should go into its own request logger class instead of inside the VerticalResults component's class?
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.
I agree, if we can move this to it's own class we could easily expand it to universal search. Yen, if we have a new class such as SearchRequestLogger
, we could have a registerVerticalSearchLogger
and a registerUniversalSearchLogger
function so that we could set it up for either type of search
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.
I see, yeah that sounds good
f4362c7
to
f8e9b26
Compare
bafb612
to
b496623
Compare
b496623
to
0881390
Compare
Update cafeTest acceptance test
waitOnSearchComplete
in verticalResults.js to wait till query responses return status 200 and searchComplete state appears on page.- first point: the test first function call is
verticalResults.scrollToBottom()
, which wait onthis._resultsWrapper
when perform scroll on page. This resultsWrapper will always exist because it's set in our page template. The test didn't account for waiting on the actual search result div. CallingwaitOnSearchComplete
before scrolling would prevent this issue.- second point: removed the arbitrary wait time 1s in
dragLeft()
. Replaced with waiting for the response to be returned first using searchComplete state.getNumResults()
which check if results exists after a search. (From testCafe documentation, Selector wait/timeouts functionality have no effect on Selector.exists and Selector.count properties. These properties are evaluated immediately.)J=SLAP-1425
TEST= auto
ran testCafe locally to verify tests and wait time in selectors