Skip to content

Add Capybara::Apparition::NetworkTraffic::Request#finished?#49

Open
dkniffin wants to merge 2 commits into
twalpole:masterfrom
dkniffin:request-finished
Open

Add Capybara::Apparition::NetworkTraffic::Request#finished?#49
dkniffin wants to merge 2 commits into
twalpole:masterfrom
dkniffin:request-finished

Conversation

@dkniffin

@dkniffin dkniffin commented Apr 13, 2020

Copy link
Copy Markdown

I would like to add this method, which returns whether the request is completed or still pending. I have no idea if this is the correct implementation for it. In fact, testing it on my app, there are requests where this is not true, even after a long period of time. If someone could give me feedback on this, that would be awesome!

@dkniffin

Copy link
Copy Markdown
Author

I just pushed a new version of this change that uses the Network.loadingFinished event to determine this instead.

@twalpole

Copy link
Copy Markdown
Owner

Does the new change work with the requests you said the other wasn’t?

Comment thread lib/capybara/apparition/page.rb Outdated
@dkniffin

Copy link
Copy Markdown
Author

@twalpole I'm actually not sure. I didn't test this with our app. I would definitely want to add unit tests into this PR, but I wanted to make sure you were okay with the approach and willing to accept it before I spent time on that.

@twalpole

Copy link
Copy Markdown
Owner

I’m willing if it works.

@dkniffin

Copy link
Copy Markdown
Author

@twalpole Hmm. Looking at the tests now, I'm not actually sure how I would test this. It looks like there's not a lot of unit tests. How would you suggest I add a test for it?

@twalpole

Copy link
Copy Markdown
Owner

Apparition runs it's test suite plus the whole of the Capybara test suite. I would recommend testing it by making requests to endpoints in the test app (new or existing ones) that delay the response a couple of seconds, verifying that the response isn't completed and then after the expected delay verifying the response is completed - similar to what the network traffic tests do - https://github.com/twalpole/apparition/blob/master/spec/integration/driver_spec.rb#L706

Capybara provided portion of the test suite is at https://github.com/teamcapybara/capybara/tree/master/lib/capybara/spec

@dkniffin

Copy link
Copy Markdown
Author

@twalpole Alright, added a pretty simple test. Let me know if that is sufficient or not.

@twalpole

Copy link
Copy Markdown
Owner

@dkniffin The test you modified is now failing - I'm not sure if it's because of your change or not. Please add a new test that specifically tests the finished? method rather than merging into an existing test so it's clear which part isn't working.

@twalpole

Copy link
Copy Markdown
Owner

@dkniffin Any update on changing this to be its own new test rather than hacking into an existing one?

@dkniffin

Copy link
Copy Markdown
Author

@twalpole sorry, I've been busy. Thank you for the reminder. I'll try to make time to finish it up sometime this week.

@dkniffin

Copy link
Copy Markdown
Author

I finally had a few minutes to take a look at this. I just split it to it's own spec. We'll see if that resolved the failure, or which of the tests is failing now.

@twalpole

twalpole commented Aug 1, 2020

Copy link
Copy Markdown
Owner

@dkniffin The test appears to fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants