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 UI tests of image optimization setting #22095

Merged
merged 10 commits into from
Nov 28, 2023
Merged

Conversation

fluiddot
Copy link
Contributor

This PR is a follow-up of #21981 and adds UI tests of the new App Setting to optimize images when uploading.

To test:
N/A

Regression Notes

  1. Potential unintended areas of impact
    N/A

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

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

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.

UI Changes testing checklist:

  • 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)

@fluiddot fluiddot added Testing Unit and UI Tests and Tooling App Settings labels Nov 27, 2023
@fluiddot fluiddot added this to the 23.9 milestone Nov 27, 2023
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Nov 27, 2023

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 Numberpr22095-ac3d4d4
Version23.7
Bundle IDorg.wordpress.alpha
Commitac3d4d4
App Center BuildWPiOS - One-Offs #7979
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 Nov 27, 2023

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 Numberpr22095-ac3d4d4
Version23.7
Bundle IDcom.jetpack.alpha
Commitac3d4d4
App Center Buildjetpack-installable-builds #7003
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

We don't strictly need to expect the back button being present. In fact, on iPad, there's no back button in that screen.
@@ -27,7 +27,7 @@ public extension XCTestCase {

appToRemove.firstMatch.press(forDuration: 1)
waitAndTap(Apps.springboard.buttons["Remove App"])
waitAndTap(Apps.springboard.alerts.buttons["Delete App"])
waitForExistenceAndTap(Apps.springboard.alerts.buttons["Delete App"])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that the Delete app button wasn't tapped when running the UI tests locally. For this reason, I decided to change this action to explicitly wait for the element's existence.

@fluiddot fluiddot marked this pull request as ready for review November 27, 2023 15:15
@fluiddot fluiddot requested a review from a team as a code owner November 27, 2023 15:15
@fluiddot fluiddot requested review from twstokes and SiobhyB November 27, 2023 15:15
@twstokes
Copy link
Contributor

Nice @fluiddot! Thanks for going the extra mile to add these.

@pachlava
Copy link
Contributor

@fluiddot 👋

Just leaving a note that I'm looking into a PR — will leave some feedback today a bit later. Thank you for adding the tests! 👍

Copy link
Contributor

@pachlava pachlava left a comment

Choose a reason for hiding this comment

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

@fluiddot 👋

Thank you so much for adding the UI tests, and extending the Screens to support "App Settings" screen ⭐

I executed the tests locally for iPhone with no issues 👍 , and left two minor naming / formatting comments, they're not blocking. :shipit:

P.S. One thing to discuss (@jostnes and @tiagomar 👋): since we try to have mainly critical flows automated, should we consider splitting the tests schemes to Smoke and Full, to keep the execution time under 30 minutes for Smoke? With Xcode 15 incoming, this might become problematic if we keep on running all tests on every push.

WordPress/UITests/Tests/AppSettingsTests.swift Outdated Show resolved Hide resolved
@MainActor
override func setUpWithError() throws {
try super.setUpWithError()
setUpTestSuite(removeBeforeLaunching: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

At first, I was confused why this file uses removeBeforeLaunching, but then I realized that this is to ensure that Image Optimization prompt is shown for both testImageOptimizationIsTurnedOnEditor and testImageOptimizationIsTurnedOffEditor, and that tests in this file are independent/isolated.

We might need to keep this in mind, though, if we add more tests into this file: for other tests deleting the app might not be necessary, but it takes quite a lot of time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first, I was confused why this file uses removeBeforeLaunching, but then I realized that this is to ensure that Image Optimization prompt is shown for both testImageOptimizationIsTurnedOnEditor and testImageOptimizationIsTurnedOffEditor, and that tests in this file are independent/isolated.

Yeah, I should have added a note here explaining why it's necessary to remove it before launching. I'll add an inline comment as a follow-up.

We might need to keep this in mind, though, if we add more tests into this file: for other tests deleting the app might not be necessary, but it takes quite a lot of time.

I agree. This approach is specific to the tests I added. In the future, it's likely to be unnecessary for other tests related to the App Settings screen. I wonder if there's an option to enable removeBeforeLaunching at the test level. If not, we can consider renaming the test file to OptimizeImagesSettingTests to convey that the file should only include test cases related to that logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if there's an option to enable removeBeforeLaunching at the test level

Maybe not the nicest way, but this should do the trick (not tested):

let testsRequiringAppDeletion = [
        "testImageOptimizationEnabledByDefault",
        "testImageOptimizationIsTurnedOnEditor",
        "testImageOptimizationIsTurnedOffEditor"
    ]

let removeBeforeLaunch = testsRequiringAppDeletion.contains(where: { testName in self.name.contains(testName)})

try super.setUpWithError()
setUpTestSuite(removeBeforeLaunching: removeBeforeLaunch)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried your approach and it worked nice, thanks for sharing it. I haven't found another approach to use a different setup depending on the test case, so I think we can apply this workaround. Applied in 00e4d46.

@fluiddot fluiddot merged commit 0317836 into trunk Nov 28, 2023
@fluiddot fluiddot deleted the add/optimize-images-ui-tests branch November 28, 2023 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Settings Testing Unit and UI Tests and Tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants