Skip to content

Commit

Permalink
Merge pull request #2214 from CruGlobal/GT-app-flow-tests
Browse files Browse the repository at this point in the history
GT app flow tests
  • Loading branch information
levieggertcru authored Jul 25, 2024
2 parents 201f6c1 + 750c0ea commit ee7e77e
Show file tree
Hide file tree
Showing 20 changed files with 353 additions and 11 deletions.
16 changes: 16 additions & 0 deletions godtools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
451CCF1D27A9D87600E8D2D3 /* MobileContentCardCollectionPagePositionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451CCF1C27A9D87600E8D2D3 /* MobileContentCardCollectionPagePositionState.swift */; };
451CCF2027A9DB2D00E8D2D3 /* PageNavigationCollectionViewNavigationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451CCF1F27A9DB2D00E8D2D3 /* PageNavigationCollectionViewNavigationModel.swift */; };
451CEDFD282C3239006E5105 /* ToolSettingsFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451CEDFC282C3239006E5105 /* ToolSettingsFlow.swift */; };
451CF5952C4AAC5500CD65C4 /* AppFlowTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451CF5942C4AAC5500CD65C4 /* AppFlowTests.swift */; };
451FB9372896B3DE00423865 /* LanguageDomainModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451FB9342896B3DE00423865 /* LanguageDomainModel.swift */; };
451FB9382896B3DE00423865 /* GetLanguageUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451FB9352896B3DE00423865 /* GetLanguageUseCase.swift */; };
451FB9392896B3DE00423865 /* LanguageDirectionDomainModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 451FB9362896B3DE00423865 /* LanguageDirectionDomainModel.swift */; };
Expand Down Expand Up @@ -1161,6 +1162,7 @@
45C8835D2A93EDDF00F33E6D /* DashboardTabBarItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C8835C2A93EDDF00F33E6D /* DashboardTabBarItemView.swift */; };
45C8835F2A93EE9C00F33E6D /* DashboardTabBarItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C8835E2A93EE9C00F33E6D /* DashboardTabBarItemViewModel.swift */; };
45C925022B45E7AA005947DB /* AppHomeBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C925012B45E7AA005947DB /* AppHomeBarItem.swift */; };
45C94E612C4EDF1C004D80FE /* AccessibilityTapAreaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C94E602C4EDF1C004D80FE /* AccessibilityTapAreaView.swift */; };
45CAB4EA28A2CE8000224B5F /* KeyboardNotificationObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CAB4E928A2CE7F00224B5F /* KeyboardNotificationObserver.swift */; };
45CBD9FB2BA343590007DEC8 /* GetOnboardingTutorialIsAvailableInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CBD9FA2BA343590007DEC8 /* GetOnboardingTutorialIsAvailableInterface.swift */; };
45CBD9FD2BA343DE0007DEC8 /* GetOnboardingTutorialIsAvailable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45CBD9FC2BA343DE0007DEC8 /* GetOnboardingTutorialIsAvailable.swift */; };
Expand Down Expand Up @@ -1810,6 +1812,7 @@
451CCF1C27A9D87600E8D2D3 /* MobileContentCardCollectionPagePositionState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MobileContentCardCollectionPagePositionState.swift; sourceTree = "<group>"; };
451CCF1F27A9DB2D00E8D2D3 /* PageNavigationCollectionViewNavigationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageNavigationCollectionViewNavigationModel.swift; sourceTree = "<group>"; };
451CEDFC282C3239006E5105 /* ToolSettingsFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolSettingsFlow.swift; sourceTree = "<group>"; };
451CF5942C4AAC5500CD65C4 /* AppFlowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppFlowTests.swift; sourceTree = "<group>"; };
451F7A802ABD2F1100006EF2 /* Quick.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Quick.framework; sourceTree = BUILT_PRODUCTS_DIR; };
451F7A822ABD2F1400006EF2 /* Nimble.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; };
451FB9342896B3DE00423865 /* LanguageDomainModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LanguageDomainModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2793,6 +2796,7 @@
45C8835C2A93EDDF00F33E6D /* DashboardTabBarItemView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashboardTabBarItemView.swift; sourceTree = "<group>"; };
45C8835E2A93EE9C00F33E6D /* DashboardTabBarItemViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardTabBarItemViewModel.swift; sourceTree = "<group>"; };
45C925012B45E7AA005947DB /* AppHomeBarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppHomeBarItem.swift; sourceTree = "<group>"; };
45C94E602C4EDF1C004D80FE /* AccessibilityTapAreaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityTapAreaView.swift; sourceTree = "<group>"; };
45CAB4E928A2CE7F00224B5F /* KeyboardNotificationObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardNotificationObserver.swift; sourceTree = "<group>"; };
45CBD9FA2BA343590007DEC8 /* GetOnboardingTutorialIsAvailableInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetOnboardingTutorialIsAvailableInterface.swift; sourceTree = "<group>"; };
45CBD9FC2BA343DE0007DEC8 /* GetOnboardingTutorialIsAvailable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetOnboardingTutorialIsAvailable.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4166,6 +4170,7 @@
children = (
45131A0C2AB498AD0085AF0D /* AccessibilityStrings.swift */,
45C5DDCD2AE6BF1300C70BBA /* AccessibilityScreenElementView.swift */,
45C94E602C4EDF1C004D80FE /* AccessibilityTapAreaView.swift */,
45DEF4DB2AE95237000C8F4B /* UIViewController+AccessibilityScreenId.swift */,
);
path = Accessibility;
Expand Down Expand Up @@ -4264,6 +4269,14 @@
path = ToolSettings;
sourceTree = "<group>";
};
451CF5932C4AAC4B00CD65C4 /* App */ = {
isa = PBXGroup;
children = (
451CF5942C4AAC5500CD65C4 /* AppFlowTests.swift */,
);
path = App;
sourceTree = "<group>";
};
451FB9332896B3DE00423865 /* GetLanguageUseCase */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -7680,6 +7693,7 @@
isa = PBXGroup;
children = (
45DC19162BB5B34D007542A5 /* BaseFlowTests.swift */,
451CF5932C4AAC4B00CD65C4 /* App */,
45DC19132BB5B338007542A5 /* ChooseAppLanguage */,
45DC19102BB5AB21007542A5 /* LanguageSettings */,
450FC7572C49590D00F87282 /* Menu */,
Expand Down Expand Up @@ -12175,6 +12189,7 @@
45FBE5732AB8A33700BFBE92 /* LaunchEnvironmentKey.swift in Sources */,
4585E4B82B05895200223A9B /* BCP47LanguageIdentifier.swift in Sources */,
45DC19152BB5B33F007542A5 /* ChooseAppLanguageFlowTests.swift in Sources */,
451CF5952C4AAC5500CD65C4 /* AppFlowTests.swift in Sources */,
45D318FB2AE7020200D74A87 /* AppLanguageDataModel.swift in Sources */,
45A415F32A99429C0030E2C7 /* OnboardingFlowTests.swift in Sources */,
45DC19122BB5AB2C007542A5 /* LanguageSettingsFlowTests.swift in Sources */,
Expand Down Expand Up @@ -13049,6 +13064,7 @@
D4BE3F702C0907FC00887BFD /* RealmUserToolSettings.swift in Sources */,
450EE2AB29A6719500524F64 /* GodToolsAppLessonsPathDeepLinkParser.swift in Sources */,
454BFDA72AFD8CD200104BC8 /* TractRemoteShareNavigationEvent.swift in Sources */,
45C94E612C4EDF1C004D80FE /* AccessibilityTapAreaView.swift in Sources */,
45EA98FA2AFD67FC00E7EA9A /* ViewCreatingToolScreenShareSessionTimedOutUseCase.swift in Sources */,
458721302BFB7E78005DA242 /* GetDeleteAccountInterfaceStringsRepositoryInterface.swift in Sources */,
45AD1BE325938A4F00A096A0 /* NibBased.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ struct DashboardTabBarView: View {

DashboardTabBarItemView(
viewModel: viewModel.getTabBarItemViewModel(tabIndex: index),
currentTab: $viewModel.currentTab
currentTab: $viewModel.currentTab,
buttonAccessibility: getTabBarItemButtonAccessibility(tabIndex: index)
)
.frame(maxWidth: .infinity)
}
Expand All @@ -40,7 +41,8 @@ struct DashboardTabBarView: View {

DashboardTabBarItemView(
viewModel: viewModel.getTabBarItemViewModel(tabIndex: index),
currentTab: $viewModel.currentTab
currentTab: $viewModel.currentTab,
buttonAccessibility: getTabBarItemButtonAccessibility(tabIndex: index)
)
.frame(maxWidth: .infinity)
}
Expand All @@ -57,6 +59,21 @@ struct DashboardTabBarView: View {
)
.environment(\.layoutDirection, .leftToRight)
}

private func getTabBarItemButtonAccessibility(tabIndex: Int) -> AccessibilityStrings.Button {

switch viewModel.tabs[tabIndex] {

case .lessons:
return .dashboardTabLessons

case .favorites:
return .dashboardTabFavorites

case .tools:
return .dashboardTabTools
}
}
}

struct DashboardTabBarView_Previews: PreviewProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ struct DashboardTabBarItemView: View {

private let unSelectedColor = Color(red: 170 / 255, green: 170 / 255, blue: 170 / 255)
private let selectedColor = ColorPalette.gtBlue.color
private let buttonAccessibility: AccessibilityStrings.Button

private var viewModel: DashboardTabBarItemViewModel

@Binding private var currentTab: Int

init(viewModel: DashboardTabBarItemViewModel, currentTab: Binding<Int>) {
init(viewModel: DashboardTabBarItemViewModel, currentTab: Binding<Int>, buttonAccessibility: AccessibilityStrings.Button) {

self.viewModel = viewModel
self._currentTab = currentTab
self.buttonAccessibility = buttonAccessibility
}

private var isSelected: Bool {
Expand All @@ -41,6 +43,8 @@ struct DashboardTabBarItemView: View {
.foregroundColor(isSelected ? selectedColor : unSelectedColor)
}
}
.accessibility(addTraits: .isButton)
.accessibilityIdentifier(buttonAccessibility.id)
.onTapGesture {
currentTab = viewModel.tabIndex
}
Expand All @@ -55,7 +59,8 @@ struct DashboardTabBarItemView_Preview: PreviewProvider {

DashboardTabBarItemView(
viewModel: DashboardTabBarItemViewModel(tabIndex: 0, title: "Lessons", imageName: ""),
currentTab: $currentTab
currentTab: $currentTab,
buttonAccessibility: .dashboardTabLessons
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import SwiftUI

struct ToolCardFavoritedButton: View {

private let accessibility: AccessibilityStrings.Button = .toggleToolFavorite

let isFavorited: Bool
let tappedClosure: (() -> Void)?

Expand All @@ -28,6 +30,7 @@ struct ToolCardFavoritedButton: View {
.clipped()
}
.frame(width: 44, height: 44)
.accessibilityIdentifier(accessibility.id)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ struct ToolCardView: View {
private let navButtonSpacing: CGFloat = 8
private let contentHorizontalInsets: CGFloat = 15
private let showsCategory: Bool
private let accessibility: AccessibilityStrings.Button?
private let favoriteTappedClosure: (() -> Void)?
private let toolDetailsTappedClosure: (() -> Void)?
private let openToolTappedClosure: (() -> Void)?
private let toolTappedClosure: (() -> Void)?

@ObservedObject private var viewModel: ToolCardViewModel

init(viewModel: ToolCardViewModel, geometry: GeometryProxy, layout: ToolCardLayout, showsCategory: Bool, favoriteTappedClosure: (() -> Void)?, toolDetailsTappedClosure: (() -> Void)?, openToolTappedClosure: (() -> Void)?, toolTappedClosure: (() -> Void)?) {
init(viewModel: ToolCardViewModel, geometry: GeometryProxy, layout: ToolCardLayout, showsCategory: Bool, accessibility: AccessibilityStrings.Button?, favoriteTappedClosure: (() -> Void)?, toolDetailsTappedClosure: (() -> Void)?, openToolTappedClosure: (() -> Void)?, toolTappedClosure: (() -> Void)?) {

var navButtons: [ToolCardNavButtonType] = Array()

Expand All @@ -49,6 +50,7 @@ struct ToolCardView: View {
self.layout = layout
self.navButtons = navButtons
self.showsCategory = showsCategory
self.accessibility = accessibility
self.favoriteTappedClosure = favoriteTappedClosure
self.toolDetailsTappedClosure = toolDetailsTappedClosure
self.openToolTappedClosure = openToolTappedClosure
Expand Down Expand Up @@ -85,6 +87,10 @@ struct ToolCardView: View {

ZStack(alignment: .topLeading) {

if let accessibilityIdentifier = accessibility?.id {
AccessibilityTapAreaView(accessibilityIdentifier: accessibilityIdentifier)
}

backgroundColor

VStack(alignment: .leading, spacing: 0) {
Expand Down Expand Up @@ -141,12 +147,12 @@ struct ToolCardView: View {
Spacer()
}

GTWhiteButton(title: viewModel.detailsButtonTitle, font: navButtonFont, width: navButtonWidth, height: navButtonHeight) {
GTWhiteButton(title: viewModel.detailsButtonTitle, font: navButtonFont, width: navButtonWidth, height: navButtonHeight, accessibility: .toolDetails) {

toolDetailsTappedClosure?()
}

GTBlueButton(title: viewModel.openButtonTitle, font: navButtonFont, width: navButtonWidth, height: navButtonHeight) {
GTBlueButton(title: viewModel.openButtonTitle, font: navButtonFont, width: navButtonWidth, height: navButtonHeight, accessibility: .openTool) {

openToolTappedClosure?()
}
Expand Down Expand Up @@ -218,6 +224,7 @@ struct ToolCardView_Previews: PreviewProvider {
geometry: geometry,
layout: .landscape,
showsCategory: true,
accessibility: nil,
favoriteTappedClosure: nil,
toolDetailsTappedClosure: nil,
openToolTappedClosure: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct ToolSpotlightView: View {
geometry: geometry,
layout: .thumbnail,
showsCategory: false,
accessibility: .spotlightTool,
favoriteTappedClosure: {

viewModel.spotlightToolFavoriteTapped(spotlightTool: spotlightTool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ struct ToolFilterButtonView: View {
private let buttonTitle: String
private let width: CGFloat?
private let backgroundColor: Color = Color.white
private let accessibility: AccessibilityStrings.Button
private let tappedClosure: (() -> Void)?

init(title: String, width: CGFloat? = nil, tappedClosure: (() -> Void)?) {
init(title: String, width: CGFloat? = nil, accessibility: AccessibilityStrings.Button, tappedClosure: (() -> Void)?) {

self.buttonTitle = title
self.width = width
self.accessibility = accessibility
self.tappedClosure = tappedClosure
}

Expand Down Expand Up @@ -62,6 +64,7 @@ struct ToolFilterButtonView: View {
.frame(width: width, height: ToolFilterButtonView.height)
.background(backgroundColor)
.cornerRadius(ToolFilterButtonView.cornerRadius)
.accessibilityIdentifier(accessibility.id)
.shadow(color: Color.black.opacity(0.25), radius: 3, y: 3)
.overlay(
RoundedRectangle(cornerRadius: ToolFilterButtonView.cornerRadius)
Expand All @@ -80,6 +83,7 @@ struct ToolFilterButtonView_Previews: PreviewProvider {
ToolFilterButtonView(
title: "Button Title",
width: 40,
accessibility: .toolsCategoryFilter,
tappedClosure: nil
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct ToolsFilterSectionView: View {
ToolFilterButtonView(
title: viewModel.categoryFilterButtonTitle,
width: buttonWidth,
accessibility: .toolsCategoryFilter,
tappedClosure: {

viewModel.toolCategoryFilterTapped()
Expand All @@ -47,6 +48,7 @@ struct ToolsFilterSectionView: View {
ToolFilterButtonView(
title: viewModel.languageFilterButtonTitle,
width: buttonWidth,
accessibility: .toolsLanguageFilter,
tappedClosure: {

viewModel.toolLanguageFilterTapped()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct ToolsView: View {
geometry: geometry,
layout: .landscape,
showsCategory: true,
accessibility: .tool,
favoriteTappedClosure: {

viewModel.toolFavoriteTapped(tool: tool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct AllYourFavoriteToolsView: View {
geometry: geometry,
layout: .landscape,
showsCategory: true,
accessibility: .favoriteTool,
favoriteTappedClosure: {

viewModel.unfavoriteToolTapped(tool: tool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct YourFavoriteToolsView: View {
geometry: geometry,
layout: .thumbnail,
showsCategory: true,
accessibility: .favoriteTool,
favoriteTappedClosure: {

viewModel.unfavoriteToolTapped(tool: tool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct LessonsView: View {

FixedHorizontalSpacer(width: 30)

ToolFilterButtonView(title: viewModel.languageFilterButtonTitle) {
ToolFilterButtonView(title: viewModel.languageFilterButtonTitle, accessibility: .lessonsLanguageFilter) {
viewModel.lessonLanguageFilterTapped()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct ToolDetailsView: View {

GeometryReader { geometry in

AccessibilityScreenElementView(screenAccessibility: .toolDetails)

let contentWidth: CGFloat = geometry.size.width - contentInsets.leading - contentInsets.trailing

ScrollView(.vertical, showsIndicators: true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct ToolFilterCategorySelectionView: View {

VStack(spacing: 0) {

AccessibilityScreenElementView(screenAccessibility: .toolsCategoryFilters)

SearchBarView(viewModel: viewModel.getSearchBarViewModel(), searchText: $viewModel.searchText)

List {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ struct ToolFilterLanguageSelectionView: View {

VStack(spacing: 0) {

AccessibilityScreenElementView(screenAccessibility: .toolsLanguageFilters)

SearchBarView(viewModel: viewModel.getSearchBarViewModel(), searchText: $viewModel.searchText)

List {
Expand Down
Loading

0 comments on commit ee7e77e

Please sign in to comment.