Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Breaking specs #569

Closed
wants to merge 5 commits into from
Closed

Breaking specs #569

wants to merge 5 commits into from

Conversation

pboling
Copy link

@pboling pboling commented Nov 3, 2016

Proposed changes in this pull request

This PR is to show what is broken. Some of the things broken are mentioned in the Readme as expected to be working.

Checklist

  • New tests have been added
  • npm test passes successfully
  • Documentation has been updated

@amir20 to review

it('#property() works with input params', async () => {
let page = await phantom.createPage();
let outObj = phantom.createOutObject();
describe('#property', () => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Property specs here in this describe block pass. All other specs in this change set fail.

await page.property('onResourceReceived', function(response, out) {
out.lastResponse = response;
}, outObj);
await page.property('onResourceRequested', true, function(requestData, networkRequest, out) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pboling why you passing true to property? That's supposed to be for on only according to the read me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. This is supposed to be a test of on, not property. Fixed in latest commit.

@amir20
Copy link
Owner

amir20 commented Nov 5, 2016

Almost all of your examples are using page.property('onResourceReceived', true, function(response, out) which isn't right. The README says that's only supported for on. Am I missing something?

Copy link
Owner

@amir20 amir20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for changes for property

@pboling
Copy link
Author

pboling commented Nov 6, 2016

Sorry, that was a transcription error.

The specs that I care most about, because property is not a viable solution for my needs, are the ones with on that pass true. Fixing now.

@pboling
Copy link
Author

pboling commented Nov 6, 2016

@amir20 the specs have been switched to call on, with true.

@pboling
Copy link
Author

pboling commented Nov 6, 2016

It is a little strange that I get 9 failures locally and Travis only gets 7, but even still all the ones testing the feature I need are failing on Travis as well as locally.

@amir20
Copy link
Owner

amir20 commented Nov 6, 2016

I see what's going on. The problem is that on and createOutObject have never been tested together. I don't think the README file suggest that it works togther, but I could see how it is confusing. I added property with outobject a long time ago and then someone else added on.

Probably worth doing one of two things:

  1. Update README file to say both don't work. I remember asking in the pull request what is the difference of on with runOnPhantom=true and property . I forget the reason.
  2. Probably deprecate on run with runOnPhantom=true. And fix it so that it works.

await page.property('onResourceReceived', function(response, out) {
out.lastResponse = response;
}, outObj);
await page.on('onResourceRequested', true, function(requestData, networkRequest, out) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await page.property('onResourceRequested', function(requestData, networkRequest, out) {
                    out.lastRequest = requestData;
                }, outObj);

works. So probably on and outobject have not been tested.

See my other comment

@pboling
Copy link
Author

pboling commented Nov 6, 2016

@amir20 the second to last line of the Readme section for page#on says the outObject can be used with on, but I agree, it looks like it does not work.

https://github.com/amir20/phantomjs-node#pageon

The same as in property, you can pass additional params to the function in the same way, and even use the object created by #createOutObject().

@pboling
Copy link
Author

pboling commented Nov 6, 2016

@amir20 I have added robust working examples that accomplish what I need via property to this PR!

if (out.isMatch) {
responseObj.status = 'aborted';
out.urls_aborted.push(responseObj);
networkRequest.abort();
Copy link
Author

@pboling pboling Nov 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

networkRequest.abort() does work within property!!!

The thing I was doing that appears to have been breaking it was passing a regex into the outObj. It seems that is not possible. The specs show passing in of simple, JSON-valid data types. Perhaps a Regex is too complex to pass within an outObj?

@amir20
Copy link
Owner

amir20 commented Nov 22, 2016

This PR is no longer valid. Closing. The original issue is still valid and documentation needs to be updated.

@amir20 amir20 closed this Nov 22, 2016
@amir20 amir20 removed the On Hold label Nov 22, 2016
@pboling
Copy link
Author

pboling commented Nov 22, 2016

@amir20 Checking my understanding here:

  1. The failing specs I added are things that are not expected to work, and the documentation just needs to be updated to reflect that.
  2. The passing specs I added are good but tainted in this PR because of the presence of all the failing specs.

If that is correct I will add a new PR that corrects the documentation and also adds the additional specs.

NOTE: I was able to get my code working following the model of the passing specs!

@amir20
Copy link
Owner

amir20 commented Nov 22, 2016

The failing specs I added are things that are not expected to work, and the documentation just needs to be updated to reflect that.

Yes.

The passing specs I added are good but tainted in this PR because of the presence of all the failing specs.

Also yes. I actually didn't know you had added new tests. I'd be more than happy to add those in as a separate PR if you have 'em available. I love more tests. I just couldn't pass through the broken tests.

@pboling
Copy link
Author

pboling commented Dec 2, 2016

I'll separate out the passing ones in a new PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants