From ce3790ecfd32653d8ea9a36103ed37a3a28c734b Mon Sep 17 00:00:00 2001 From: Paul Von Schrottky Date: Tue, 2 Feb 2021 18:17:02 -0300 Subject: [PATCH 01/11] Remove editor switch for WP.com Simple sites MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the "Use block editor" setting from My Site → Settings on Simple WP.com sites. In light of the fact that the Classic editor is not available to users on on Simple WP.com sites (except via wp-admin), this PR brings the WordPress for iOS app closer to the web in terms of behavior. --- .../Blog/Site Settings/SiteSettingsViewController.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m b/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m index 03f0af22befe..94a1a98386a4 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m @@ -194,7 +194,10 @@ - (NSArray *)tableSections [sections addObject:@(SiteSettingsSectionAccount)]; } - [sections addObject:@(SiteSettingsSectionEditor)]; + // Only add the editor section if the site is not a Simple WP.com site + if (self.blog.isAtomic || !self.blog.isHostedAtWPcom) { + [sections addObject:@(SiteSettingsSectionEditor)]; + } if ([self.blog supports:BlogFeatureWPComRESTAPI] && self.blog.isAdmin) { [sections addObject:@(SiteSettingsSectionWriting)]; From 16b22f89887acbf295e593eefe45a3500e0003ab Mon Sep 17 00:00:00 2001 From: Paul Von Schrottky Date: Thu, 4 Feb 2021 15:43:27 -0300 Subject: [PATCH 02/11] Don't check editor pref on new Simple site posts Before this commit, when creating a new post the app would check the site's mobile editor preference (which is different to their web editor preference) and open the corresponding editor (Block editor or Classic editor). With this commit we now do not look at the preference when the user creates a new post and we will now always use the Block editor in this scenario). --- WordPress/Classes/Utility/Editor/GutenbergSettings.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/Utility/Editor/GutenbergSettings.swift b/WordPress/Classes/Utility/Editor/GutenbergSettings.swift index 8ea79d63ec15..f66783bddcf5 100644 --- a/WordPress/Classes/Utility/Editor/GutenbergSettings.swift +++ b/WordPress/Classes/Utility/Editor/GutenbergSettings.swift @@ -181,7 +181,8 @@ class GutenbergSettings { let blog = post.blog if post.isContentEmpty() { - return blog.isGutenbergEnabled + let isSimpleWPComSite = blog.isAtomic() || !blog.isHostedAtWPcom + return isSimpleWPComSite || blog.isGutenbergEnabled } else { // It's an existing post return post.containsGutenbergBlocks() From 88f3dfb72835d1f06bc1589412ec1dc0223d016d Mon Sep 17 00:00:00 2001 From: Paul Von Schrottky Date: Mon, 15 Mar 2021 16:15:56 -0300 Subject: [PATCH 03/11] Fix check for Simple sites Simple sites are WP.com-connected non-Atomic sites. --- WordPress/Classes/Utility/Editor/GutenbergSettings.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Classes/Utility/Editor/GutenbergSettings.swift b/WordPress/Classes/Utility/Editor/GutenbergSettings.swift index f66783bddcf5..2ec94383510a 100644 --- a/WordPress/Classes/Utility/Editor/GutenbergSettings.swift +++ b/WordPress/Classes/Utility/Editor/GutenbergSettings.swift @@ -181,7 +181,7 @@ class GutenbergSettings { let blog = post.blog if post.isContentEmpty() { - let isSimpleWPComSite = blog.isAtomic() || !blog.isHostedAtWPcom + let isSimpleWPComSite = !blog.isAtomic() && blog.isHostedAtWPcom return isSimpleWPComSite || blog.isGutenbergEnabled } else { // It's an existing post From 5f023aeddee44f4db3476f206d6b0e4083094b68 Mon Sep 17 00:00:00 2001 From: Paul Von Schrottky Date: Mon, 15 Mar 2021 16:22:29 -0300 Subject: [PATCH 04/11] Hide classic option on Simple sites On Simple WP.com sites, we no longer show the option to switch to classic. This is part of the classic deprecation/removal project. --- .../Gutenberg/GutenbergViewController+MoreActions.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController+MoreActions.swift b/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController+MoreActions.swift index aa196afd8334..9d92aecd3265 100644 --- a/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController+MoreActions.swift +++ b/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController+MoreActions.swift @@ -27,8 +27,12 @@ extension GutenbergViewController { } } - alert.addDefaultActionWithTitle(MoreSheetAlert.classicTitle) { [unowned self] _ in - self.savePostEditsAndSwitchToAztec() + // Only add the action if the site is not a Simple WP.com site + let isSimpleWPComSite = !post.blog.isAtomic() && post.blog.isHostedAtWPcom + if !isSimpleWPComSite { + alert.addDefaultActionWithTitle(MoreSheetAlert.classicTitle) { [unowned self] _ in + self.savePostEditsAndSwitchToAztec() + } } let toggleModeTitle: String = { From 7e41a49d2370fed6fc4506e48ee1ec175403c843 Mon Sep 17 00:00:00 2001 From: Paul Von Schrottky Date: Wed, 17 Mar 2021 22:27:48 -0300 Subject: [PATCH 05/11] Point to WordPressMocks dev branch --- Podfile | 4 ++-- Podfile.lock | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Podfile b/Podfile index 956fec4204ff..78ec5619da66 100644 --- a/Podfile +++ b/Podfile @@ -418,9 +418,9 @@ end ## =================== ## def wordpress_mocks - pod 'WordPressMocks', '~> 0.0.9' + # pod 'WordPressMocks', '~> 0.0.9' # pod 'WordPressMocks', :git => 'https://github.com/wordpress-mobile/WordPressMocks.git', :commit => '' - # pod 'WordPressMocks', :git => 'https://github.com/wordpress-mobile/WordPressMocks.git', :branch => '' + pod 'WordPressMocks', :git => 'https://github.com/wordpress-mobile/WordPressMocks.git', :branch => 'update-site-to-atomic' # pod 'WordPressMocks', :path => '../WordPressMocks' end diff --git a/Podfile.lock b/Podfile.lock index fdac0ea81c74..d655b741ad43 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -504,7 +504,7 @@ DEPENDENCIES: - WordPress-Editor-iOS (~> 1.19.4) - WordPressAuthenticator (~> 1.35.2) - WordPressKit (~> 4.29.0-beta.5) - - WordPressMocks (~> 0.0.9) + - WordPressMocks (from `https://github.com/wordpress-mobile/WordPressMocks.git`, branch `update-site-to-atomic`) - WordPressShared (~> 1.15.0) - WordPressUI (~> 1.9.0) - WPMediaPicker (~> 1.7.2) @@ -557,7 +557,6 @@ SPEC REPOS: - UIDeviceIdentifier - WordPress-Aztec-iOS - WordPress-Editor-iOS - - WordPressMocks - WPMediaPicker - wpxmlrpc - ZendeskCommonUISDK @@ -655,6 +654,9 @@ EXTERNAL SOURCES: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.48.1 + WordPressMocks: + :branch: update-site-to-atomic + :git: https://github.com/wordpress-mobile/WordPressMocks.git Yoga: :podspec: https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.48.1/third-party-podspecs/Yoga.podspec.json @@ -670,6 +672,9 @@ CHECKOUT OPTIONS: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.48.1 + WordPressMocks: + :commit: b77731d7d8be61102065e3cc34853904baf0d94c + :git: https://github.com/wordpress-mobile/WordPressMocks.git SPEC CHECKSUMS: 1PasswordExtension: f97cc80ae58053c331b2b6dc8843ba7103b33794 @@ -767,6 +772,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: e100a7a0a1bb5d7d43abbde3338727d985a4986d ZIPFoundation: e27423c004a5a1410c15933407747374e7c6cb6e -PODFILE CHECKSUM: 99470e0137b6ccf2131a45864abbba42a2eda50d +PODFILE CHECKSUM: a10332e320ae624b44b9ab829deed5c785f93998 COCOAPODS: 1.10.0 From 136dd02900582f2efd9708758cce72316aafd0f3 Mon Sep 17 00:00:00 2001 From: Paul Von Schrottky Date: Thu, 18 Mar 2021 21:42:43 -0300 Subject: [PATCH 06/11] Revert "Hide classic option on Simple sites" This reverts commit 5f023aeddee44f4db3476f206d6b0e4083094b68. --- .../Gutenberg/GutenbergViewController+MoreActions.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController+MoreActions.swift b/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController+MoreActions.swift index 9d92aecd3265..aa196afd8334 100644 --- a/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController+MoreActions.swift +++ b/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController+MoreActions.swift @@ -27,12 +27,8 @@ extension GutenbergViewController { } } - // Only add the action if the site is not a Simple WP.com site - let isSimpleWPComSite = !post.blog.isAtomic() && post.blog.isHostedAtWPcom - if !isSimpleWPComSite { - alert.addDefaultActionWithTitle(MoreSheetAlert.classicTitle) { [unowned self] _ in - self.savePostEditsAndSwitchToAztec() - } + alert.addDefaultActionWithTitle(MoreSheetAlert.classicTitle) { [unowned self] _ in + self.savePostEditsAndSwitchToAztec() } let toggleModeTitle: String = { From e9cd034ddd28fa7d1c971a091509795f3e78fed7 Mon Sep 17 00:00:00 2001 From: Paul Von Schrottky Date: Fri, 19 Mar 2021 18:39:22 -0300 Subject: [PATCH 07/11] Pod install --- Podfile.lock | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 824b8c6f4681..86d7eb7b5f44 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -557,7 +557,6 @@ SPEC REPOS: - WordPress-Aztec-iOS - WordPress-Editor-iOS - WordPressKit - - WordPressMocks - WPMediaPicker - wpxmlrpc - ZendeskCommonUISDK @@ -773,6 +772,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: e100a7a0a1bb5d7d43abbde3338727d985a4986d ZIPFoundation: e27423c004a5a1410c15933407747374e7c6cb6e -PODFILE CHECKSUM: acfde13e60a82b0d939b8442c223584b7c87c0ce +PODFILE CHECKSUM: eb7398493d78cec1215c540e3b50c3927d036587 COCOAPODS: 1.10.0 From c062cc3e5c81d992946b8b3c1cf27ff3f82489e2 Mon Sep 17 00:00:00 2001 From: Cameron Voell Date: Thu, 1 Apr 2021 16:11:31 -0700 Subject: [PATCH 08/11] Revert WordPressMocks update. --- Podfile | 4 ++-- Podfile.lock | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Podfile b/Podfile index ff1311e7d346..cb6e26ac0342 100644 --- a/Podfile +++ b/Podfile @@ -418,9 +418,9 @@ end ## =================== ## def wordpress_mocks - # pod 'WordPressMocks', '~> 0.0.9' + pod 'WordPressMocks', '~> 0.0.9' # pod 'WordPressMocks', :git => 'https://github.com/wordpress-mobile/WordPressMocks.git', :commit => '' - pod 'WordPressMocks', :git => 'https://github.com/wordpress-mobile/WordPressMocks.git', :branch => 'update-site-to-atomic' + # pod 'WordPressMocks', :git => 'https://github.com/wordpress-mobile/WordPressMocks.git', :branch => '' # pod 'WordPressMocks', :path => '../WordPressMocks' end diff --git a/Podfile.lock b/Podfile.lock index 86d7eb7b5f44..bd1f94dc7448 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -504,7 +504,7 @@ DEPENDENCIES: - WordPress-Editor-iOS (~> 1.19.4) - WordPressAuthenticator (~> 1.35.2) - WordPressKit (~> 4.29.0-beta) - - WordPressMocks (from `https://github.com/wordpress-mobile/WordPressMocks.git`, branch `update-site-to-atomic`) + - WordPressMocks (~> 0.0.9) - WordPressShared (~> 1.15.0) - WordPressUI (~> 1.9.0) - WPMediaPicker (~> 1.7.2) @@ -557,6 +557,7 @@ SPEC REPOS: - WordPress-Aztec-iOS - WordPress-Editor-iOS - WordPressKit + - WordPressMocks - WPMediaPicker - wpxmlrpc - ZendeskCommonUISDK @@ -654,9 +655,6 @@ EXTERNAL SOURCES: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.49.0 - WordPressMocks: - :branch: update-site-to-atomic - :git: https://github.com/wordpress-mobile/WordPressMocks.git Yoga: :podspec: https://raw.githubusercontent.com/wordpress-mobile/gutenberg-mobile/v1.49.0/third-party-podspecs/Yoga.podspec.json @@ -672,9 +670,6 @@ CHECKOUT OPTIONS: :git: https://github.com/wordpress-mobile/gutenberg-mobile.git :submodules: true :tag: v1.49.0 - WordPressMocks: - :commit: b77731d7d8be61102065e3cc34853904baf0d94c - :git: https://github.com/wordpress-mobile/WordPressMocks.git SPEC CHECKSUMS: 1PasswordExtension: f97cc80ae58053c331b2b6dc8843ba7103b33794 @@ -772,6 +767,6 @@ SPEC CHECKSUMS: ZendeskSupportSDK: e100a7a0a1bb5d7d43abbde3338727d985a4986d ZIPFoundation: e27423c004a5a1410c15933407747374e7c6cb6e -PODFILE CHECKSUM: eb7398493d78cec1215c540e3b50c3927d036587 +PODFILE CHECKSUM: 22d9689249ed8289f1fe131265c67def1bfb89d1 COCOAPODS: 1.10.0 From 82ecea5d43f7ead050309e78eb2a4b07e883a317 Mon Sep 17 00:00:00 2001 From: Cameron Voell Date: Thu, 1 Apr 2021 16:11:59 -0700 Subject: [PATCH 09/11] Disable test for adding new aztec post. Fix Gutenberg test. --- .../WordPressUITests/Flows/EditorFlow.swift | 4 + .../Tests/EditorAztecTests.swift | 108 +++++++++--------- .../Tests/EditorGutenbergTests.swift | 3 +- 3 files changed, 60 insertions(+), 55 deletions(-) diff --git a/WordPress/WordPressUITests/Flows/EditorFlow.swift b/WordPress/WordPressUITests/Flows/EditorFlow.swift index ecfffe73ee9e..763c1a557774 100644 --- a/WordPress/WordPressUITests/Flows/EditorFlow.swift +++ b/WordPress/WordPressUITests/Flows/EditorFlow.swift @@ -7,6 +7,10 @@ class EditorFlow { } } + static func goToMySiteScreen() -> MySiteScreen { + return TabNavComponent().gotoMySiteScreen() + } + static func toggleBlockEditor(to state: SiteSettingsScreen.Toggle) -> SiteSettingsScreen { if !SiteSettingsScreen.isLoaded() { _ = TabNavComponent() diff --git a/WordPress/WordPressUITests/Tests/EditorAztecTests.swift b/WordPress/WordPressUITests/Tests/EditorAztecTests.swift index 8002f40eeafd..fe6384b14d37 100644 --- a/WordPress/WordPressUITests/Tests/EditorAztecTests.swift +++ b/WordPress/WordPressUITests/Tests/EditorAztecTests.swift @@ -24,57 +24,59 @@ class EditorAztecTests: XCTestCase { super.tearDown() } - func testTextPostPublish() { - let title = getRandomPhrase() - let content = getRandomContent() - editorScreen - .enterTextInTitle(text: title) - .enterText(text: content) - .publish() - .viewPublishedPost(withTitle: title) - .verifyEpilogueDisplays(postTitle: title, siteAddress: WPUITestCredentials.testWPcomSitePrimaryAddress) - .done() - } - - func testBasicPostPublish() { - let title = getRandomPhrase() - let content = getRandomContent() - let category = getCategory() - let tag = getTag() - editorScreen - .enterTextInTitle(text: title) - .enterText(text: content) - .addImageByOrder(id: 0) - .openPostSettings() - .selectCategory(name: category) - .addTag(name: tag) - .setFeaturedImage() - .verifyPostSettings(withCategory: category, withTag: tag, hasImage: true) - .removeFeatureImage() - .verifyPostSettings(withCategory: category, withTag: tag, hasImage: false) - .setFeaturedImage() - .verifyPostSettings(withCategory: category, withTag: tag, hasImage: true) - .closePostSettings() - AztecEditorScreen(mode: .rich).publish() - .viewPublishedPost(withTitle: title) - .verifyEpilogueDisplays(postTitle: title, siteAddress: WPUITestCredentials.testWPcomSitePrimaryAddress) - .done() - } - - // Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/385 - func testLongTitle() { - let longTitle = "long title in a galaxy not so far away" - // Title heigh contains of actual textfield height + bottom line. - // 16.5px - is the height of that bottom line. Its not changing with different font sizes - let titleTextView = editorScreen.titleView - let titleLineHeight = titleTextView.frame.height - 16.5 - let oneLineTitleHeight = titleTextView.frame.height - - let repeatTimes = isIPhone ? 6 : 20 - _ = editorScreen.enterTextInTitle(text: String(repeating: "very ", count: repeatTimes) + longTitle) - - let twoLineTitleHeight = titleTextView.frame.height - - XCTAssert(twoLineTitleHeight - oneLineTitleHeight >= titleLineHeight ) - } + // TODO: Re-enable Aztec tests but for editing an existing Aztec post. + // For more information, see Issue: https://github.com/wordpress-mobile/WordPress-iOS/issues/16218 +// func testTextPostPublish() { +// let title = getRandomPhrase() +// let content = getRandomContent() +// editorScreen +// .enterTextInTitle(text: title) +// .enterText(text: content) +// .publish() +// .viewPublishedPost(withTitle: title) +// .verifyEpilogueDisplays(postTitle: title, siteAddress: WPUITestCredentials.testWPcomSitePrimaryAddress) +// .done() +// } +// +// func testBasicPostPublish() { +// let title = getRandomPhrase() +// let content = getRandomContent() +// let category = getCategory() +// let tag = getTag() +// editorScreen +// .enterTextInTitle(text: title) +// .enterText(text: content) +// .addImageByOrder(id: 0) +// .openPostSettings() +// .selectCategory(name: category) +// .addTag(name: tag) +// .setFeaturedImage() +// .verifyPostSettings(withCategory: category, withTag: tag, hasImage: true) +// .removeFeatureImage() +// .verifyPostSettings(withCategory: category, withTag: tag, hasImage: false) +// .setFeaturedImage() +// .verifyPostSettings(withCategory: category, withTag: tag, hasImage: true) +// .closePostSettings() +// AztecEditorScreen(mode: .rich).publish() +// .viewPublishedPost(withTitle: title) +// .verifyEpilogueDisplays(postTitle: title, siteAddress: WPUITestCredentials.testWPcomSitePrimaryAddress) +// .done() +// } +// +// // Github issue https://github.com/wordpress-mobile/AztecEditor-iOS/issues/385 +// func testLongTitle() { +// let longTitle = "long title in a galaxy not so far away" +// // Title heigh contains of actual textfield height + bottom line. +// // 16.5px - is the height of that bottom line. Its not changing with different font sizes +// let titleTextView = editorScreen.titleView +// let titleLineHeight = titleTextView.frame.height - 16.5 +// let oneLineTitleHeight = titleTextView.frame.height +// +// let repeatTimes = isIPhone ? 6 : 20 +// _ = editorScreen.enterTextInTitle(text: String(repeating: "very ", count: repeatTimes) + longTitle) +// +// let twoLineTitleHeight = titleTextView.frame.height +// +// XCTAssert(twoLineTitleHeight - oneLineTitleHeight >= titleLineHeight ) +// } } diff --git a/WordPress/WordPressUITests/Tests/EditorGutenbergTests.swift b/WordPress/WordPressUITests/Tests/EditorGutenbergTests.swift index 2053dd9bd6c7..75a6355af9be 100644 --- a/WordPress/WordPressUITests/Tests/EditorGutenbergTests.swift +++ b/WordPress/WordPressUITests/Tests/EditorGutenbergTests.swift @@ -8,8 +8,7 @@ class EditorGutenbergTests: XCTestCase { _ = LoginFlow.loginIfNeeded(siteUrl: WPUITestCredentials.testWPcomSiteAddress, email: WPUITestCredentials.testWPcomUserEmail, password: WPUITestCredentials.testWPcomPassword) editorScreen = EditorFlow - .toggleBlockEditor(to: .on) - .goBackToMySite() + .goToMySiteScreen() .tabBar.gotoBlockEditorScreen() } From 5ec2cf262b84d7ae7f4acd0160771f465faec624 Mon Sep 17 00:00:00 2001 From: Cameron Voell Date: Thu, 1 Apr 2021 21:06:20 -0700 Subject: [PATCH 10/11] Invalidate CI cache after mocks update --- .circleci/cache-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/cache-version b/.circleci/cache-version index 518db58a1554..fc29f773fa1d 100644 --- a/.circleci/cache-version +++ b/.circleci/cache-version @@ -1,2 +1,2 @@ # To invalidate the cache, generate a new UUID using `uuidgen` on the command line then paste it here -8412DC8E-32C7-48D9-9C6B-E84319AE0436 +BA7CD240-05A5-4C42-AFD5-4C66D94F520C From 519e46cc73d068e3e59c20334c01083b7bf98733 Mon Sep 17 00:00:00 2001 From: Wendy Chen Date: Fri, 2 Apr 2021 12:33:04 -0500 Subject: [PATCH 11/11] Pulling isSimpleWPComSite out into reusable function. Changing capitalization to match existing capitalization. --- .../Classes/Utility/Editor/GutenbergSettings.swift | 13 ++++++++++--- .../Blog/Site Settings/SiteSettingsViewController.m | 2 +- WordPress/WordPressUITests/Flows/EditorFlow.swift | 2 +- .../Tests/EditorGutenbergTests.swift | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/WordPress/Classes/Utility/Editor/GutenbergSettings.swift b/WordPress/Classes/Utility/Editor/GutenbergSettings.swift index 2ec94383510a..219c17f99e81 100644 --- a/WordPress/Classes/Utility/Editor/GutenbergSettings.swift +++ b/WordPress/Classes/Utility/Editor/GutenbergSettings.swift @@ -170,6 +170,10 @@ class GutenbergSettings { // MARK: - Gutenberg Choice Logic + func isSimpleWPComSite(_ blog: Blog) -> Bool { + return !blog.isAtomic() && blog.isHostedAtWPcom + } + /// Call this method to know if Gutenberg must be used for the specified post. /// /// - Parameters: @@ -179,10 +183,8 @@ class GutenbergSettings { /// func mustUseGutenberg(for post: AbstractPost) -> Bool { let blog = post.blog - if post.isContentEmpty() { - let isSimpleWPComSite = !blog.isAtomic() && blog.isHostedAtWPcom - return isSimpleWPComSite || blog.isGutenbergEnabled + return isSimpleWPComSite(post.blog) || blog.isGutenbergEnabled } else { // It's an existing post return post.containsGutenbergBlocks() @@ -206,6 +208,11 @@ class GutenbergSettingsBridge: NSObject { static func postSettingsToRemote(for blog: Blog) { GutenbergSettings().postSettingsToRemote(for: blog) } + + @objc(isSimpleWPComSite:) + static func isSimpleWPComSite(_ blog: Blog) -> Bool { + return GutenbergSettings().isSimpleWPComSite(blog) + } } private extension String { diff --git a/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m b/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m index 94a1a98386a4..79ca014d1d3b 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m @@ -195,7 +195,7 @@ - (NSArray *)tableSections } // Only add the editor section if the site is not a Simple WP.com site - if (self.blog.isAtomic || !self.blog.isHostedAtWPcom) { + if (![GutenbergSettings isSimpleWPComSite:self.blog]) { [sections addObject:@(SiteSettingsSectionEditor)]; } diff --git a/WordPress/WordPressUITests/Flows/EditorFlow.swift b/WordPress/WordPressUITests/Flows/EditorFlow.swift index 763c1a557774..47be99628a11 100644 --- a/WordPress/WordPressUITests/Flows/EditorFlow.swift +++ b/WordPress/WordPressUITests/Flows/EditorFlow.swift @@ -7,7 +7,7 @@ class EditorFlow { } } - static func goToMySiteScreen() -> MySiteScreen { + static func gotoMySiteScreen() -> MySiteScreen { return TabNavComponent().gotoMySiteScreen() } diff --git a/WordPress/WordPressUITests/Tests/EditorGutenbergTests.swift b/WordPress/WordPressUITests/Tests/EditorGutenbergTests.swift index 75a6355af9be..a681a07c13da 100644 --- a/WordPress/WordPressUITests/Tests/EditorGutenbergTests.swift +++ b/WordPress/WordPressUITests/Tests/EditorGutenbergTests.swift @@ -8,7 +8,7 @@ class EditorGutenbergTests: XCTestCase { _ = LoginFlow.loginIfNeeded(siteUrl: WPUITestCredentials.testWPcomSiteAddress, email: WPUITestCredentials.testWPcomUserEmail, password: WPUITestCredentials.testWPcomPassword) editorScreen = EditorFlow - .goToMySiteScreen() + .gotoMySiteScreen() .tabBar.gotoBlockEditorScreen() }