Skip to content

Commit

Permalink
Improve integration test readability (#2515)
Browse files Browse the repository at this point in the history
* Improve integration test readability

* Fix

* Update to use switch store

* wip
  • Loading branch information
stephencelis authored Oct 11, 2023
1 parent c08d59e commit 20089ee
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 141 deletions.
44 changes: 24 additions & 20 deletions Examples/Integration/Integration/EnumTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,30 @@ struct EnumView: View {
}
}
}
IfLetStore(
self.store.scope(state: \.$destination, action: { .destination($0) }),
state: /Feature.Destination.State.feature1,
action: { .feature1($0) }
) { store in
Section {
BasicsView(store: store)
} header: {
Text("Feature 1")
}
}
IfLetStore(
self.store.scope(state: \.$destination, action: { .destination($0) }),
state: /Feature.Destination.State.feature2,
action: { .feature2($0) }
) { store in
Section {
BasicsView(store: store)
} header: {
Text("Feature 2")
IfLetStore(self.store.scope(state: \.$destination, action: { .destination($0) })) { store in
SwitchStore(store) {
switch $0 {
case .feature1:
CaseLet(
/Feature.Destination.State.feature1, action: Feature.Destination.Action.feature1
) { store in
Section {
BasicsView(store: store)
} header: {
Text("Feature 1")
}
}
case .feature2:
CaseLet(
/Feature.Destination.State.feature2, action: Feature.Destination.Action.feature2
) { store in
Section {
BasicsView(store: store)
} header: {
Text("Feature 2")
}
}
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Examples/Integration/Integration/PresentationTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ struct PresentationView: View {
return .none
}
}
.ifLet(\.$destination, action: /Action.destination) {
Destination()
}
.ifLet(\.$sheet, action: /Action.sheet) {
BasicsView.Feature()
}
Expand Down
113 changes: 71 additions & 42 deletions Examples/Integration/IntegrationUITests/EnumTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ final class EnumTests: BaseIntegrationTests {
"""
BasicsView.body
EnumView.body
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.init
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
PresentationStoreOf<EnumView.Feature.Destination>.scope
StoreOf<BasicsView.Feature>.init
StoreOf<BasicsView.Feature>.init
StoreOf<EnumView.Feature>.scope
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<EnumView.Feature.Destination>.init
StoreOf<EnumView.Feature.Destination>.init
StoreOf<EnumView.Feature.Destination?>.init
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<EnumView.Feature>.scope
"""
Expand All @@ -35,13 +39,17 @@ final class EnumTests: BaseIntegrationTests {
self.assertLogs {
"""
BasicsView.body
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
PresentationStoreOf<EnumView.Feature.Destination>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<EnumView.Feature>.scope
"""
Expand All @@ -57,14 +65,18 @@ final class EnumTests: BaseIntegrationTests {
self.assertLogs {
"""
EnumView.body
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
PresentationStoreOf<EnumView.Feature.Destination>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<EnumView.Feature>.scope
"""
Expand All @@ -81,19 +93,28 @@ final class EnumTests: BaseIntegrationTests {
"""
BasicsView.body
EnumView.body
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.init
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
PresentationStoreOf<EnumView.Feature.Destination>.scope
StoreOf<BasicsView.Feature>.init
StoreOf<BasicsView.Feature>.init
StoreOf<BasicsView.Feature>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<BasicsView.Feature?>.deinit
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<EnumView.Feature>.scope
"""
Expand All @@ -109,21 +130,29 @@ final class EnumTests: BaseIntegrationTests {
self.assertLogs {
"""
EnumView.body
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
Store<PresentationState<EnumView.Feature.Destination.State>, PresentationAction<EnumView.Feature.Destination.Action>>.scope
PresentationStoreOf<EnumView.Feature.Destination>.scope
PresentationStoreOf<EnumView.Feature.Destination>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature.Destination?>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<EnumView.Feature>.scope
StoreOf<EnumView.Feature>.scope
Expand Down
22 changes: 11 additions & 11 deletions Examples/Integration/IntegrationUITests/NavigationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class NavigationTests: BaseIntegrationTests {
self.assertLogs {
"""
BasicsView.body
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.init
StackStoreOf<BasicsView.Feature>.init
StoreOf<BasicsView.Feature>.init
StoreOf<BasicsView.Feature>.init
"""
Expand All @@ -25,7 +25,7 @@ final class NavigationTests: BaseIntegrationTests {
self.assertLogs {
"""
BasicsView.body
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
StackStoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<NavigationTestCaseView.Feature>.scope
"""
Expand All @@ -43,15 +43,15 @@ final class NavigationTests: BaseIntegrationTests {
self.assertLogs {
"""
BasicsView.body
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
Store<StackState<BasicsView.Feature.State>, StackAction<BasicsView.Feature.State, BasicsView.Feature.Action>>.scope
StackStoreOf<BasicsView.Feature>.scope
StackStoreOf<BasicsView.Feature>.scope
StackStoreOf<BasicsView.Feature>.scope
StackStoreOf<BasicsView.Feature>.scope
StackStoreOf<BasicsView.Feature>.scope
StackStoreOf<BasicsView.Feature>.scope
StackStoreOf<BasicsView.Feature>.scope
StackStoreOf<BasicsView.Feature>.scope
StackStoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature>.scope
Expand Down
24 changes: 12 additions & 12 deletions Examples/Integration/IntegrationUITests/OptionalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ final class OptionalTests: BaseIntegrationTests {
"""
BasicsView.body
OptionalView.body
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.init
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<PresentationState<BasicsView.Feature.State>, PresentationAction<BasicsView.Feature.Action>>.scope
PresentationStoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature>.init
StoreOf<BasicsView.Feature>.init
StoreOf<BasicsView.Feature?>.init
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<OptionalView.Feature>.scope
StoreOf<OptionalView.Feature>.scope
"""
Expand All @@ -32,11 +32,11 @@ final class OptionalTests: BaseIntegrationTests {
"""
BasicsView.body
OptionalView.body
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<PresentationState<BasicsView.Feature.State>, PresentationAction<BasicsView.Feature.Action>>.scope
PresentationStoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<OptionalView.Feature>.scope
StoreOf<OptionalView.Feature>.scope
"""
Expand All @@ -60,11 +60,11 @@ final class OptionalTests: BaseIntegrationTests {
"""
BasicsView.body
OptionalView.body
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<BasicsView.Feature.State?, BasicsView.Feature.Action>.scope
Store<PresentationState<BasicsView.Feature.State>, PresentationAction<BasicsView.Feature.Action>>.scope
PresentationStoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<BasicsView.Feature?>.scope
StoreOf<OptionalView.Feature>.scope
StoreOf<OptionalView.Feature>.scope
"""
Expand Down
Loading

0 comments on commit 20089ee

Please sign in to comment.