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

Remove Alamofire dependency from WordPressKit #23386

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

kean
Copy link
Contributor

@kean kean commented Jun 25, 2024

It was "needed" for tests.

To test:

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  3. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@kean kean added this to the Pending milestone Jun 25, 2024
@kean kean changed the base branch from trunk to task/remove-unused-dependencies-2 June 25, 2024 13:40
@kean kean force-pushed the task/remove-unused-dependencies-3 branch from a74841c to aca0af7 Compare June 25, 2024 13:48
@kean kean requested a review from jkmassel June 25, 2024 13:53
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 25, 2024

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr23386-706e86c
Version25.1
Bundle IDorg.wordpress.alpha
Commit706e86c
App Center BuildWPiOS - One-Offs #10229
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 25, 2024

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr23386-706e86c
Version25.1
Bundle IDcom.jetpack.alpha
Commit706e86c
App Center Buildjetpack-installable-builds #9278
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@kean kean force-pushed the task/remove-unused-dependencies-3 branch from dab8035 to aca0af7 Compare June 25, 2024 14:29
Copy link
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

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

These tests ensures that we're creating valid multipart requests.

If we were to remove them, we'd lose that validation.

I'm fine to remove Alamofire here, but we should replace it with static test data that can be validated against, not just delete the test entirely.

Base automatically changed from task/remove-unused-dependencies-2 to trunk June 26, 2024 03:47
@kean
Copy link
Contributor Author

kean commented Jun 26, 2024

I honestly didn't read the tests because the use of Alamofire didn't seem to make sense.

but we should replace it with static test data that can be validated against

Done. Right, this way it'll catch if there any regressions.

@kean kean requested a review from jkmassel June 26, 2024 15:12
@kean kean force-pushed the task/remove-unused-dependencies-3 branch from d6bb062 to ccab8a5 Compare June 26, 2024 15:15
Copy link
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

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

Sorry to be annoying – can we use multi-line Swift strings for this so developers can read it right in the code?

It makes the test longer, but more clear IMHO

@kean kean requested a review from jkmassel June 26, 2024 18:21
@kean
Copy link
Contributor Author

kean commented Jun 26, 2024

Sorry to be annoying – can we use multi-line Swift strings for this so developers can read it right in the code?

Can you drop a comment on the lines you are referring to please?

There are inline base64 binary:

let expected = Data(base64Encoded: "LS10ZXN0Ym91bmRhcnkNCkNvbnRlbnQtRGlzcG9zaXRpb246IGZvcm0tZGF0YTsgbmFtZT0ia2V5LTEiDQoNCmENCi0tdGVzdGJvdW5kYXJ5DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImtleS0yIg0KDQpiDQotLXRlc3Rib3VuZGFyeS0tDQo=")!

@jkmassel
Copy link
Contributor

Yeah, all the binary data is just a string like:

--wpkit.boundary.9d4adfc909a08bfa
Content-Disposition: form-data; name="world"

hello
--wpkit.boundary.9d4adfc909a08bfa--

We could probably just use that in the test for easier comparison?

@kean
Copy link
Contributor Author

kean commented Jun 26, 2024

We could probably just use that in the test for easier comparison?

It actually is, isn't it? There are just boundaries and .utf8 "blobs".

I tried it, but there is an issue with newlines. It encodes them as \r\n aka Windows encoding. Swift uses just \n if you have a multiline string.

--testboundary\r\nContent-Disposition: form-data; name=\"key-1\"\r\n\r\na\r\n--testboundary\r\nContent-Disposition: form-data; name=\"key-2\"\r\n\r\nb\r\n--testboundary--\r\n

So this won't be the same:

let expected = """
        --testboundary
        Content-Disposition: form-data; name="key-1"

        a
        --testboundary
        Content-Disposition: form-data; name="key-2"

        b
        --testboundary--

        """.data(using: .utf8)

@kean
Copy link
Contributor Author

kean commented Jun 26, 2024

But this will work:

let expected = "--testboundary\r\nContent-Disposition: form-data; name=\"key-1\"\r\n\r\na\r\n--testboundary\r\nContent-Disposition: form-data; name=\"key-2\"\r\n\r\nb\r\n--testboundary--\r\n".data(using: .utf8)

I'm changing it to that.

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

Successfully merging this pull request may close these issues.

None yet

3 participants