diff --git a/secant.xcodeproj/project.pbxproj b/secant.xcodeproj/project.pbxproj index 63683c3..598aae9 100644 --- a/secant.xcodeproj/project.pbxproj +++ b/secant.xcodeproj/project.pbxproj @@ -141,6 +141,7 @@ 9E9ECC6F285741980099D5A2 /* ImportWalletSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9ECC6E285741980099D5A2 /* ImportWalletSnapshotTests.swift */; }; 9E9ECC72285749750099D5A2 /* RecoveryPhraseDisplaySnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9ECC71285749750099D5A2 /* RecoveryPhraseDisplaySnapshotTests.swift */; }; 9E9ECC7528574B590099D5A2 /* RecoveryPhraseValidationFlowSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9ECC7428574B590099D5A2 /* RecoveryPhraseValidationFlowSnapshotTests.swift */; }; + 9E9ECC7828575F6D0099D5A2 /* HomeSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E9ECC7728575F6D0099D5A2 /* HomeSnapshotTests.swift */; }; 9EAFEB822805793200199FC9 /* AppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EAFEB812805793200199FC9 /* AppTests.swift */; }; 9EAFEB84280597B700199FC9 /* WrappedSecItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EAFEB83280597B700199FC9 /* WrappedSecItem.swift */; }; 9EAFEB862805A23100199FC9 /* WrappedSecItemTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EAFEB852805A23100199FC9 /* WrappedSecItemTests.swift */; }; @@ -342,6 +343,7 @@ 9E9ECC6E285741980099D5A2 /* ImportWalletSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportWalletSnapshotTests.swift; sourceTree = ""; }; 9E9ECC71285749750099D5A2 /* RecoveryPhraseDisplaySnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecoveryPhraseDisplaySnapshotTests.swift; sourceTree = ""; }; 9E9ECC7428574B590099D5A2 /* RecoveryPhraseValidationFlowSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecoveryPhraseValidationFlowSnapshotTests.swift; sourceTree = ""; }; + 9E9ECC7728575F6D0099D5A2 /* HomeSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeSnapshotTests.swift; sourceTree = ""; }; 9EAFEB812805793200199FC9 /* AppTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTests.swift; sourceTree = ""; }; 9EAFEB83280597B700199FC9 /* WrappedSecItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WrappedSecItem.swift; sourceTree = ""; }; 9EAFEB852805A23100199FC9 /* WrappedSecItemTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WrappedSecItemTests.swift; sourceTree = ""; }; @@ -798,6 +800,7 @@ 9E9ECC6D2857417F0099D5A2 /* ImportWalletSnapshotTests */, 9E9ECC702857495B0099D5A2 /* RecoveryPhraseDisplaySnapshotTests */, 9E9ECC7328574B470099D5A2 /* RecoveryPhraseValidationFlowSnapshotTests */, + 9E9ECC7628575F5E0099D5A2 /* HomeSnapshotTests */, 9E391163284E3EDE0073DD9A /* WelcomeSnapshotTests */, 9E92AF0728530EBF007367AD /* View+UIImage.swift */, ); @@ -1011,6 +1014,12 @@ 9E9ECC7428574B590099D5A2 /* RecoveryPhraseValidationFlowSnapshotTests.swift */, ); path = RecoveryPhraseValidationFlowSnapshotTests; + 9E9ECC7628575F5E0099D5A2 /* HomeSnapshotTests */ = { + isa = PBXGroup; + children = ( + 9E9ECC7728575F6D0099D5A2 /* HomeSnapshotTests.swift */, + ); + path = HomeSnapshotTests; sourceTree = ""; }; 9EAFEB802805791400199FC9 /* AppTests */ = { @@ -1485,6 +1494,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9E9ECC7828575F6D0099D5A2 /* HomeSnapshotTests.swift in Sources */, 0DFE93DF272C6D4B000FCCA5 /* RecoveryPhraseBackupTests.swift in Sources */, 9EDDEAA22829610D00B4100C /* CurrencySelectionTests.swift in Sources */, 9E01F8282833CDA0000EFC57 /* ScanTests.swift in Sources */, diff --git a/secant/Features/Home/HomeStore.swift b/secant/Features/Home/HomeStore.swift index 608433d..e10530d 100644 --- a/secant/Features/Home/HomeStore.swift +++ b/secant/Features/Home/HomeStore.swift @@ -63,6 +63,18 @@ struct HomeEnvironment { let walletStorage: WrappedWalletStorage } +extension HomeEnvironment { + static let demo = HomeEnvironment( + audioServices: .silent, + derivationTool: .live(), + feedbackGenerator: .silent, + mnemonic: .mock, + scheduler: DispatchQueue.main.eraseToAnyScheduler(), + SDKSynchronizer: MockWrappedSDKSynchronizer(), + walletStorage: .throwing + ) +} + // MARK: - Reducer extension HomeReducer { diff --git a/secantTests/SnapshotTests/HomeSnapshotTests/HomeSnapshotTests.swift b/secantTests/SnapshotTests/HomeSnapshotTests/HomeSnapshotTests.swift new file mode 100644 index 0000000..40b1558 --- /dev/null +++ b/secantTests/SnapshotTests/HomeSnapshotTests/HomeSnapshotTests.swift @@ -0,0 +1,63 @@ +// +// HomeSnapshotTests.swift +// secantTests +// +// Created by Lukáš Korba on 13.06.2022. +// + +import XCTest +@testable import secant_testnet +import ComposableArchitecture + +class HomeSnapshotTests: XCTestCase { + func testHomeSnapshot() throws { + let transactionsHelper: [TransactionStateMockHelper] = [ + TransactionStateMockHelper(date: 1651039202, amount: Zatoshi(amount: 1), status: .paid(success: false), uuid: "1"), + TransactionStateMockHelper(date: 1651039101, amount: Zatoshi(amount: 2), uuid: "2"), + TransactionStateMockHelper(date: 1651039000, amount: Zatoshi(amount: 3), status: .paid(success: true), uuid: "3"), + TransactionStateMockHelper(date: 1651039505, amount: Zatoshi(amount: 4), uuid: "4"), + TransactionStateMockHelper(date: 1651039404, amount: Zatoshi(amount: 5), uuid: "5") + ] + let transactions = transactionsHelper.map { + TransactionState.placeholder( + date: Date.init(timeIntervalSince1970: $0.date), + amount: $0.amount, + shielded: $0.shielded, + status: $0.status, + subtitle: $0.subtitle, + uuid: $0.uuid + ) + } + + let balance = Balance(verified: 12_345_000, total: 12_345_000) + + let store = HomeStore( + initialState: .init( + drawerOverlay: .partial, + profileState: .placeholder, + requestState: .placeholder, + sendState: .placeholder, + scanState: .placeholder, + synchronizerStatus: "", + totalBalance: Zatoshi(amount: balance.total), + transactionHistoryState: .init(transactions: IdentifiedArrayOf(uniqueElements: transactions)), + verifiedBalance: Zatoshi(amount: balance.verified) + ), + reducer: .default, + environment: .demo + ) + + // landing home screen + addAttachments( + name: "\(#function)_initial", + HomeView(store: store) + ) + + // all transactions + ViewStore(store).send(.updateDrawer(.full)) + addAttachments( + name: "\(#function)_fullTransactionHistory", + HomeView(store: store) + ) + } +}