-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Account Creation: Fix broken flow after signing up from the WordPress app #21751
Changes from all commits
38687a6
b87ed54
44d318a
0815f63
fee5a3e
e65bf8c
c4bd935
e5b010b
10ed17e
67e1e15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -38,7 +38,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: true, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -52,7 +52,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: true, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -66,7 +66,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: true, phaseTwo: true, phaseThree: true, phaseFour: true, phaseNewUsers: true, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -81,7 +81,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: true) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -95,7 +95,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: true, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: true) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -109,7 +109,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: true, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -123,7 +123,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: false, phaseTwo: true, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -137,7 +137,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: true, phaseTwo: true, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -151,7 +151,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: true, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -165,7 +165,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: true, phaseTwo: true, phaseThree: true, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -179,7 +179,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: true, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -193,7 +193,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: true, phaseTwo: true, phaseThree: true, phaseFour: true, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.generalPhase(featureFlagStore: store) | ||
|
@@ -209,7 +209,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults) | ||
let flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
|
||
// When | ||
let phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store) | ||
|
@@ -225,7 +225,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
// When | ||
var flags = generateFlags(phaseOne: true, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
var phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store) | ||
|
||
// Then | ||
|
@@ -234,7 +234,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
// When | ||
flags = generateFlags(phaseOne: false, phaseTwo: true, phaseThree: false, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
remote.flags = flags | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store) | ||
|
||
// Then | ||
|
@@ -243,7 +243,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
// When | ||
flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: true, phaseFour: false, phaseNewUsers: false, phaseSelfHosted: false) | ||
remote.flags = flags | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store) | ||
|
||
// Then | ||
|
@@ -257,7 +257,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
// When | ||
var flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: true, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
var phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store) | ||
|
||
// Then | ||
|
@@ -266,7 +266,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
// When | ||
flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: true, phaseSelfHosted: false) | ||
remote.flags = flags | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store) | ||
|
||
// Then | ||
|
@@ -280,7 +280,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
// When | ||
var flags = generateFlags(phaseOne: true, phaseTwo: true, phaseThree: true, phaseFour: true, phaseNewUsers: false, phaseSelfHosted: false) | ||
let remote = MockFeatureFlagRemote(flags: flags) | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
var phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store) | ||
|
||
// Then | ||
|
@@ -289,7 +289,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase { | |
// When | ||
flags = generateFlags(phaseOne: true, phaseTwo: true, phaseThree: true, phaseFour: false, phaseNewUsers: true, phaseSelfHosted: false) | ||
remote.flags = flags | ||
store.update(using: remote) | ||
store.update(using: remote, waitOn: self) | ||
phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store) | ||
|
||
// Then | ||
|
@@ -346,3 +346,13 @@ private extension Date { | |
from: self) | ||
} | ||
} | ||
|
||
internal extension RemoteFeatureFlagStore { | ||
func update(using remote: FeatureFlagRemote, waitOn test: XCTestCase) { | ||
let exp = test.expectation(description: "Store finishes update") | ||
update(using: remote) { | ||
exp.fulfill() | ||
} | ||
test.wait(for: [exp], timeout: 1) | ||
} | ||
} | ||
Comment on lines
+350
to
+358
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting approach. For a moment I got worried because it looked like the test was no longer testing application code, but then I looked at the implementation and realized it called the app code internally. This has definitely value because it DRYes what would otherwise be a lot of repeated async expectations. I wonder if the DRY could be pushed even further. Most tests have a similar arrange structure: let store = ...
let flags = ...
let remote = ...
store.update(using: remote, waitOn: self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm reading the code wrong, if
self
isnil
, nothing will happen other than console logs.Have you considered returning early with
guard let self else { return }
?