Skip to content

Commit

Permalink
🔥🛠[Hotfix] Buy tab crashes (#64)
Browse files Browse the repository at this point in the history
* Hotfix: Set item tags to the proper sequence

* Refactored tests

- Added TabBarViewController Tests
- Added NonUSTabBarViewController Tests
- Fixed Default Currency Test

* version bump
  • Loading branch information
kcw-grunt authored Jun 12, 2021
1 parent 6b3c6c4 commit 5da45ce
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 46 deletions.
38 changes: 20 additions & 18 deletions loafwallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@
C3188E2B26431E810008ADD1 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C3188E2926431E810008ADD1 /* GoogleService-Info.plist */; };
C3188E2C26431E810008ADD1 /* partner-keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = C3188E2A26431E810008ADD1 /* partner-keys.plist */; };
C3188E3326445EA20008ADD1 /* FileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3188E3226445EA20008ADD1 /* FileTests.swift */; };
C31891C1267338D300ECE25C /* NonUSTabBarViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31891C0267338D300ECE25C /* NonUSTabBarViewControllerTests.swift */; };
C31891C326733FD400ECE25C /* TabBarViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31891C226733FD400ECE25C /* TabBarViewControllerTests.swift */; };
C32142EA25C97CD900BECCD0 /* TransactionCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C32142E925C97CD900BECCD0 /* TransactionCellView.swift */; };
C32142FA25C988C800BECCD0 /* TransactionCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C32142F925C988C800BECCD0 /* TransactionCellViewModel.swift */; };
C3270B99259BF7F20073DA7B /* LitecoinCardUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3270B98259BF7F20073DA7B /* LitecoinCardUser.swift */; };
Expand Down Expand Up @@ -1458,6 +1460,8 @@
C3188E2926431E810008ADD1 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
C3188E2A26431E810008ADD1 /* partner-keys.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "partner-keys.plist"; sourceTree = "<group>"; };
C3188E3226445EA20008ADD1 /* FileTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileTests.swift; sourceTree = "<group>"; };
C31891C0267338D300ECE25C /* NonUSTabBarViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonUSTabBarViewControllerTests.swift; sourceTree = "<group>"; };
C31891C226733FD400ECE25C /* TabBarViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarViewControllerTests.swift; sourceTree = "<group>"; };
C32142E925C97CD900BECCD0 /* TransactionCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionCellView.swift; sourceTree = "<group>"; };
C32142F925C988C800BECCD0 /* TransactionCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionCellViewModel.swift; sourceTree = "<group>"; };
C3270B98259BF7F20073DA7B /* LitecoinCardUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LitecoinCardUser.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1609,10 +1613,7 @@
CEAA9E961DC18E1F0066731D /* PhraseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PhraseView.swift; path = src/Views/PhraseView.swift; sourceTree = "<group>"; };
CEAA9E981DC262800066731D /* ConfirmPaperPhraseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ConfirmPaperPhraseViewController.swift; path = src/ViewControllers/ConfirmPaperPhraseViewController.swift; sourceTree = "<group>"; };
CEAA9E9A1DC2B9320066731D /* ConfirmPhrase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ConfirmPhrase.swift; path = src/Views/ConfirmPhrase.swift; sourceTree = "<group>"; };
CEAA9E9D1DC2F90C0066731D /* CircularPro-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "CircularPro-Bold.otf"; path = "Fonts/CircularPro-Bold.otf"; sourceTree = "<group>"; };
CEAA9E9F1DC2F9F50066731D /* UIFont+BRWAdditions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIFont+BRWAdditions.swift"; path = "src/Extensions/UIFont+BRWAdditions.swift"; sourceTree = "<group>"; };
CEAA9EA11DC2FC700066731D /* CircularPro-Book.otf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "CircularPro-Book.otf"; path = "Fonts/CircularPro-Book.otf"; sourceTree = "<group>"; };
CEAA9EA21DC2FC700066731D /* CircularPro-Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "CircularPro-Medium.otf"; path = "Fonts/CircularPro-Medium.otf"; sourceTree = "<group>"; };
CEAA9EA51DC3246F0066731D /* StartNavigationDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StartNavigationDelegate.swift; path = src/FlowControllers/StartNavigationDelegate.swift; sourceTree = "<group>"; };
CEAA9EA71DC3342E0066731D /* PinView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PinView.swift; path = src/Views/PinView.swift; sourceTree = "<group>"; };
CEAFC8601E5D5B0500E4FD06 /* SegmentedButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SegmentedButton.swift; path = src/Controls/SegmentedButton.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2183,6 +2184,8 @@
249C570423B51F9B009CB5A9 /* TransactionsViewControllerTests.swift */,
C3B7C43E25620D4400E98A64 /* SupportLitecoinFoundationViewModelTests.swift */,
C3D783BF2565ECF60004FF70 /* UnstoppableDomainViewModelTests.swift */,
C31891C0267338D300ECE25C /* NonUSTabBarViewControllerTests.swift */,
C31891C226733FD400ECE25C /* TabBarViewControllerTests.swift */,
);
path = "Class Tests";
sourceTree = "<group>";
Expand Down Expand Up @@ -3474,9 +3477,6 @@
24D5F23022599C0B00225462 /* BarlowSemiCondensed-Medium.ttf */,
24D5F23222599C0B00225462 /* BarlowSemiCondensed-Regular.ttf */,
24D5F23422599C0B00225462 /* BarlowSemiCondensed-SemiBold.ttf */,
CEAA9EA11DC2FC700066731D /* CircularPro-Book.otf */,
CEAA9EA21DC2FC700066731D /* CircularPro-Medium.otf */,
CEAA9E9D1DC2F90C0066731D /* CircularPro-Bold.otf */,
);
name = Fonts;
sourceTree = "<group>";
Expand Down Expand Up @@ -4092,6 +4092,7 @@
C345D81525A8D52600657E30 /* LoginViewModelTests.swift in Sources */,
249C570523B51F9B009CB5A9 /* TransactionsViewControllerTests.swift in Sources */,
24470E2523A5EF0D00ADDA27 /* BRAPIClientTests.swift in Sources */,
C31891C326733FD400ECE25C /* TabBarViewControllerTests.swift in Sources */,
24470E3C23A5FFD700ADDA27 /* TouchIdEnabledTests.swift in Sources */,
24470E3023A5F55700ADDA27 /* BRHTTPServerTests.swift in Sources */,
24470E3A23A5FF5700ADDA27 /* TestHelpers.swift in Sources */,
Expand All @@ -4100,6 +4101,7 @@
C345D82525A8D54200657E30 /* RegistrationViewModelTests.swift in Sources */,
24470E3623A5FDE800ADDA27 /* PhraseTests.swift in Sources */,
C308993F2616124800EE6A40 /* CardWalletTests.swift in Sources */,
C31891C1267338D300ECE25C /* NonUSTabBarViewControllerTests.swift in Sources */,
24470E4523A608A700ADDA27 /* AmountTests.swift in Sources */,
C3B7C3EE255FF59200E98A64 /* ConstantsTests.swift in Sources */,
24470E2323A5DB7D00ADDA27 /* WalletManagerTests.swift in Sources */,
Expand Down Expand Up @@ -4758,7 +4760,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = loafwallet/loafwallet.entitlements;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = ZV7987N2ZC;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
Expand All @@ -4773,7 +4775,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.5.0;
MARKETING_VERSION = 3.5.1;
OTHER_SWIFT_FLAGS = "-DDebug $(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.litecoin.loafwallet;
PRODUCT_MODULE_NAME = loafwallet;
Expand Down Expand Up @@ -4866,7 +4868,7 @@
CODE_SIGN_ENTITLEMENTS = TodayExtension/TodayExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = ZV7987N2ZC;
INFOPLIST_FILE = TodayExtension/Info.plist;
Expand All @@ -4876,7 +4878,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 3.5.0;
MARKETING_VERSION = 3.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.litecoin.loafwallet.TodayExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -5177,7 +5179,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = loafwallet/loafwallet.entitlements;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = ZV7987N2ZC;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -5191,7 +5193,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.5.0;
MARKETING_VERSION = 3.5.1;
OTHER_SWIFT_FLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.litecoin.loafwallet;
PRODUCT_MODULE_NAME = loafwallet;
Expand All @@ -5208,7 +5210,7 @@
CODE_SIGN_ENTITLEMENTS = TodayExtension/TodayExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = ZV7987N2ZC;
INFOPLIST_FILE = TodayExtension/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
Expand All @@ -5217,7 +5219,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 3.5.0;
MARKETING_VERSION = 3.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.litecoin.loafwallet.TodayExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -5308,7 +5310,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = loafwallet/loafwallet.entitlements;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = ZV7987N2ZC;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -5322,7 +5324,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.5.0;
MARKETING_VERSION = 3.5.1;
OTHER_SWIFT_FLAGS = "-DDebug -DTestnet $(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = com.litecoin.loafwallet;
PRODUCT_MODULE_NAME = loafwallet;
Expand All @@ -5340,7 +5342,7 @@
CODE_SIGN_ENTITLEMENTS = TodayExtension/TodayExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = ZV7987N2ZC;
INFOPLIST_FILE = TodayExtension/Info.plist;
Expand All @@ -5350,7 +5352,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 3.5.0;
MARKETING_VERSION = 3.5.1;
PRODUCT_BUNDLE_IDENTIFIER = com.litecoin.loafwallet.TodayExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
4 changes: 2 additions & 2 deletions loafwallet/NonUSTabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ class NonUSTabBarViewController: UIViewController, Subscriber, Trackable, UITabB
switch item.tag {
case 0: item.title = S.History.barItemTitle
case 1: item.title = S.Send.barItemTitle
case 3: item.title = S.Receive.barItemTitle
case 4: item.title = S.BuyCenter.barItemTitle
case 2: item.title = S.Receive.barItemTitle
case 3: item.title = S.BuyCenter.barItemTitle
default:
item.title = "NO-TITLE"
NSLog("ERROR: UITabbar item count is wrong")
Expand Down
17 changes: 8 additions & 9 deletions loafwallet/Storyboards/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tabBar contentMode="redraw" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="j3Z-Gw-zod">
<rect key="frame" x="0.0" y="589" width="414" height="98"/>
<rect key="frame" x="0.0" y="638" width="414" height="49"/>
<viewLayoutGuide key="safeArea" id="TzC-tl-jAG"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<items>
Expand Down Expand Up @@ -64,15 +64,14 @@
<color key="backgroundColor" systemColor="systemPinkColor"/>
<constraints>
<constraint firstItem="BXb-8k-gBM" firstAttribute="top" secondItem="81g-U6-NOG" secondAttribute="top" constant="4" id="FgY-7a-fho"/>

<constraint firstAttribute="height" constant="60" id="iBk-qu-OG6"/>
<constraint firstItem="zmH-Ee-H6k" firstAttribute="centerY" secondItem="ZHZ-G5-6k8" secondAttribute="centerY" id="ksC-fB-keg"/>
<constraint firstAttribute="trailing" secondItem="zmH-Ee-H6k" secondAttribute="trailing" constant="10" id="vY4-OJ-KBs"/>
<constraint firstItem="BXb-8k-gBM" firstAttribute="leading" secondItem="81g-U6-NOG" secondAttribute="leading" constant="10" id="wcY-ph-pPP"/>
</constraints>
</view>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="euD-bi-teC">
<rect key="frame" x="0.0" y="60" width="414" height="529"/>
<rect key="frame" x="0.0" y="60" width="414" height="578"/>
<viewLayoutGuide key="safeArea" id="spi-yc-QnP"/>
<connections>
<segue destination="0H7-tx-uMf" kind="embed" id="RDN-fw-P5V"/>
Expand Down Expand Up @@ -114,7 +113,7 @@
<objects>
<viewController id="0H7-tx-uMf" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="z4T-ui-Ve5">
<rect key="frame" x="0.0" y="0.0" width="414" height="529"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="578"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="UuX-cb-qOU"/>
<color key="backgroundColor" red="0.20539733769999999" green="0.36322331429999999" blue="0.61663442850000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -133,14 +132,14 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tabBar contentMode="redraw" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zek-0n-Bbp">
<rect key="frame" x="0.0" y="589" width="414" height="98"/>
<rect key="frame" x="0.0" y="638" width="414" height="49"/>
<viewLayoutGuide key="safeArea" id="qCH-cU-E5L"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<items>
<tabBarItem title="History" image="history_icon" selectedImage="history_icon" id="bcE-8M-dwp" userLabel="History"/>
<tabBarItem tag="1" title="Send" image="send_icon" selectedImage="send_icon" id="RIS-fI-9CG" userLabel="Send"/>
<tabBarItem tag="3" title="Receive" image="receive_icon" selectedImage="receive_icon" id="MWM-XE-gE7" userLabel="Receive"/>
<tabBarItem tag="4" title="Buy" image="litecoin_cutout24" selectedImage="litecoin_cutout24" id="Pzx-4b-zDZ" userLabel="Buy"/>
<tabBarItem tag="2" title="Receive" image="receive_icon" selectedImage="receive_icon" id="MWM-XE-gE7" userLabel="Receive"/>
<tabBarItem tag="3" title="Buy" image="litecoin_cutout24" selectedImage="litecoin_cutout24" id="Pzx-4b-zDZ" userLabel="Buy"/>
</items>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
Expand Down Expand Up @@ -180,7 +179,7 @@
</constraints>
</view>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vHe-dR-fDI">
<rect key="frame" x="0.0" y="60" width="414" height="529"/>
<rect key="frame" x="0.0" y="60" width="414" height="578"/>
<viewLayoutGuide key="safeArea" id="Mbc-cM-i4C"/>
<connections>
<segue destination="OcB-dV-AfP" kind="embed" id="YTB-HG-TRo"/>
Expand Down Expand Up @@ -222,7 +221,7 @@
<objects>
<viewController id="OcB-dV-AfP" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="KFy-EF-Bhg">
<rect key="frame" x="0.0" y="0.0" width="414" height="529"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="578"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="Eg4-W0-GCf"/>
<color key="backgroundColor" red="0.232668072" green="0.40775811670000001" blue="0.65472602840000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down
53 changes: 53 additions & 0 deletions loafwalletTests/Class Tests/NonUSTabBarViewControllerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// NonUSTabBarViewControllerTests.swift
// loafwalletTests
//
// Created by Kerry Washington on 6/11/21.
// Copyright © 2021 Litecoin Foundation. All rights reserved.
//

import XCTest
@testable import loafwallet

class NonUSTabBarViewControllerTests: XCTestCase {
var viewController: NonUSTabBarViewController!

override func setUpWithError() throws {

viewController = UIStoryboard.init(name: "Main",
bundle: nil)
.instantiateViewController(withIdentifier: "NonUSTabBarViewController") as?
NonUSTabBarViewController

viewController.loadViewIfNeeded()

print(viewController.tabBar.items?.count)
}


override func tearDownWithError() throws {
viewController = nil
}

func testTabBarItemCount() throws {

// There should be 4 tabs in this version for non-US users

XCTAssertTrue(viewController.tabBar.items?.count == 4)
}

func testTabBarItemRange() throws {

//Using a tag is risky and this tests that the tab has the correct tag

XCTAssertTrue(viewController.tabBar.items?[0].tag == 0)

XCTAssertTrue(viewController.tabBar.items?[1].tag == 1)

XCTAssertTrue(viewController.tabBar.items?[2].tag == 2)

XCTAssertTrue(viewController.tabBar.items?[3].tag == 3)

}

}
Loading

0 comments on commit 5da45ce

Please sign in to comment.