[346] Take Synced home screen snapshot (#356)

- home snapshot with mocked data
- also in the full history view
This commit is contained in:
Lukas Korba 2022-06-14 12:01:51 +02:00 committed by GitHub
parent 05b2d716b1
commit 270a21668a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 0 deletions

View File

@ -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 = "<group>"; };
9E9ECC71285749750099D5A2 /* RecoveryPhraseDisplaySnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecoveryPhraseDisplaySnapshotTests.swift; sourceTree = "<group>"; };
9E9ECC7428574B590099D5A2 /* RecoveryPhraseValidationFlowSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecoveryPhraseValidationFlowSnapshotTests.swift; sourceTree = "<group>"; };
9E9ECC7728575F6D0099D5A2 /* HomeSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeSnapshotTests.swift; sourceTree = "<group>"; };
9EAFEB812805793200199FC9 /* AppTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTests.swift; sourceTree = "<group>"; };
9EAFEB83280597B700199FC9 /* WrappedSecItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WrappedSecItem.swift; sourceTree = "<group>"; };
9EAFEB852805A23100199FC9 /* WrappedSecItemTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WrappedSecItemTests.swift; sourceTree = "<group>"; };
@ -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 = "<group>";
};
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 */,

View File

@ -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 {

View File

@ -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)
)
}
}