Skip to content
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

Add tests for changes from #937: ignoring 3rd party load failures while redirecting #945

Merged
merged 2 commits into from
May 24, 2018

Conversation

danj-stripe
Copy link
Contributor

Summary

Recap of behavior change: only report errors in initial load on iOS 11+, and only if
the latest URL was a stripe.com URL.

When unit tests were run against iOS 11, this was still true, and the existing test passed.

This adds two more tests: for pre-iOS 11 and for iOS 11 with a redirect to non-stripe.com.
Both of those cases should not report an error, and should not close the Safari View
Controller.

Motivation

I didn't realize that STPRedirectContext was as well tested as it is. I ran into test
failures when executing on iOS 10 (our CI executes against iOS 11), and realized this
needed to be updated.

Testing

These are just additional tests, so I ran the test suite on iOS 10 + 11 simulators.


PS: We don't have guard-let in Obj-C, nor can we check !@available(...), but I have
emulated that structure at the beginning of these tests. I think it's worth it, and
Joey didn't think it was unreasonable.

…le redirecting

I didn't realize that `STPRedirectContext` was as well tested as it is. I ran into test
failures when executing on iOS 10 (our CI executes against iOS 11), and realized this
needed to be updated.

Recap of behavior change: only report errors in initial load on iOS 11+, and only if
the latest URL was a `stripe.com` URL.

When unit tests were run against iOS 11, this was still true, and the existing test passed.

This adds two more tests: for pre-iOS 11 and for iOS 11 with a redirect to non-stripe.com.
Both of those cases should not report an error, and should not close the Safari View
Controller.

We don't have `guard-let` in Obj-C, nor can we check `!@available(...)`, but I have
emulated that structure at the beginning of these tests. I think it's worth it, and
Joey didn't think it was unreasonable.
};
OCMVerify([mockVC presentViewController:[OCMArg checkWithBlock:checker]
animated:YES
completion:[OCMArg any]]);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to call [self unsubscribeContext:context] here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch. I found another (pre-existing) test case that wasn't unsubscribing, and have updated them both.

Per documentation at the top of the class:

> [If] Your `sut` doesn't call unsubscribe and you explicitly `OCMReject` it firing
> [Then] call `[self unsubscribeContext:context]` at the end of your test (use the original
> `context` object here and _NOT_ the `sut` or it will not work).

I missed that in one of the tests I just added, and while auditing all the tests I found
another one that wasn't unsubscribing.
@danj-stripe danj-stripe merged commit ca207fa into master May 24, 2018
@danj-stripe danj-stripe deleted the danj/bugfix/ios10-test-failure branch May 24, 2018 20:07
mludowise-stripe pushed a commit that referenced this pull request Apr 4, 2022
* Update checkbox for new mocks

* update snapshots

* Use compBackground when unselected

* Use fill color contrasting color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants