Skip to content

Commit

Permalink
fix(OnboardingFlow): collect enableBiometrics data
Browse files Browse the repository at this point in the history
- extend the  tests to verify whether we collected the correct data
- some minor improvements
  • Loading branch information
caybro committed Jan 2, 2025
1 parent 970c7a1 commit 50e907b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 23 deletions.
42 changes: 42 additions & 0 deletions storybook/qmlTests/tests/tst_OnboardingLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ Item {
// FINISH
tryCompare(finishedSpy, "count", 1)
compare(finishedSpy.signalArguments[0][0], Onboarding.SecondaryFlow.CreateProfileWithPassword)
const resultData = finishedSpy.signalArguments[0][1]
verify(!!resultData)
compare(resultData.password, mockDriver.dummyNewPassword)
compare(resultData.enableBiometrics, data.biometrics && data.bioEnabled)
compare(resultData.keycardPin, "")
compare(resultData.seedphrase, "")
}

// FLOW: Create Profile -> Use a recovery phrase (create profile with seedphrase)
Expand Down Expand Up @@ -372,6 +378,12 @@ Item {
// FINISH
tryCompare(finishedSpy, "count", 1)
compare(finishedSpy.signalArguments[0][0], Onboarding.SecondaryFlow.CreateProfileWithSeedphrase)
const resultData = finishedSpy.signalArguments[0][1]
verify(!!resultData)
compare(resultData.password, mockDriver.dummyNewPassword)
compare(resultData.enableBiometrics, data.biometrics && data.bioEnabled)
compare(resultData.keycardPin, "")
compare(resultData.seedphrase, mockDriver.mnemonic)
}

function test_flow_createProfile_withKeycardAndNewSeedphrase_data() {
Expand Down Expand Up @@ -535,6 +547,12 @@ Item {
// FINISH
tryCompare(finishedSpy, "count", 1)
compare(finishedSpy.signalArguments[0][0], Onboarding.SecondaryFlow.CreateProfileWithKeycardNewSeedphrase)
const resultData = finishedSpy.signalArguments[0][1]
verify(!!resultData)
compare(resultData.password, "")
compare(resultData.enableBiometrics, data.biometrics && data.bioEnabled)
compare(resultData.keycardPin, !!data.pin ? data.pin : "123321")
compare(resultData.seedphrase, "") // TODO check seed here as well?
}

function test_flow_createProfile_withKeycardAndExistingSeedphrase_data() {
Expand Down Expand Up @@ -640,6 +658,12 @@ Item {
// FINISH
tryCompare(finishedSpy, "count", 1)
compare(finishedSpy.signalArguments[0][0], Onboarding.SecondaryFlow.CreateProfileWithKeycardExistingSeedphrase)
const resultData = finishedSpy.signalArguments[0][1]
verify(!!resultData)
compare(resultData.password, "")
compare(resultData.enableBiometrics, data.biometrics && data.bioEnabled)
compare(resultData.keycardPin, !!data.pin ? data.pin : "123321")
compare(resultData.seedphrase, mockDriver.mnemonic)
}

// FLOW: Log in -> Log in with recovery phrase
Expand Down Expand Up @@ -727,6 +751,12 @@ Item {

tryCompare(finishedSpy, "count", 1)
compare(finishedSpy.signalArguments[0][0], Onboarding.SecondaryFlow.LoginWithSeedphrase)
const resultData = finishedSpy.signalArguments[0][1]
verify(!!resultData)
compare(resultData.password, mockDriver.dummyNewPassword)
compare(resultData.enableBiometrics, data.biometrics && data.bioEnabled)
compare(resultData.keycardPin, "")
compare(resultData.seedphrase, mockDriver.mnemonic)
}

// FLOW: Log in -> Log in by syncing
Expand Down Expand Up @@ -813,6 +843,12 @@ Item {
// FINISH
tryCompare(finishedSpy, "count", 1)
compare(finishedSpy.signalArguments[0][0], Onboarding.SecondaryFlow.LoginWithSyncing)
const resultData = finishedSpy.signalArguments[0][1]
verify(!!resultData)
compare(resultData.password, "")
compare(resultData.enableBiometrics, data.biometrics && data.bioEnabled)
compare(resultData.keycardPin, "")
compare(resultData.seedphrase, "")
}

// FLOW: Log in -> Log in with Keycard
Expand Down Expand Up @@ -872,6 +908,12 @@ Item {
// FINISH
tryCompare(finishedSpy, "count", 1)
compare(finishedSpy.signalArguments[0][0], Onboarding.SecondaryFlow.LoginWithKeycard)
const resultData = finishedSpy.signalArguments[0][1]
verify(!!resultData)
compare(resultData.password, "")
compare(resultData.enableBiometrics, data.biometrics && data.bioEnabled)
compare(resultData.keycardPin, mockDriver.existingPin)
compare(resultData.seedphrase, "")
}
}
}
6 changes: 5 additions & 1 deletion ui/app/AppLayouts/Onboarding2/KeycardCreateProfileFlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SQUtils.QObject {
signal loginWithKeycardRequested
signal keycardFactoryResetRequested
signal keycardPinCreated(string pin)
signal seedphraseSubmitted(string seedphrase)

signal keypairAddTryAgainRequested
signal reloadKeycardRequested
Expand Down Expand Up @@ -152,7 +153,10 @@ SQUtils.QObject {
title: qsTr("Create profile on empty Keycard using a recovery phrase")

isSeedPhraseValid: root.isSeedPhraseValid
onSeedphraseSubmitted: root.stackView.push(keycardCreatePinPage)
onSeedphraseSubmitted: (seedphrase) => {
root.seedphraseSubmitted(seedphrase)
root.stackView.push(keycardCreatePinPage)
}

StackView.onActivated: d.fromBackupSeedphrase = true
}
Expand Down
22 changes: 12 additions & 10 deletions ui/app/AppLayouts/Onboarding2/OnboardingFlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ SQUtils.QObject {
required property int remainingAttempts
required property int splashScreenDurationMs

property bool biometricsAvailable
property bool displayKeycardPromoBanner
property bool networkChecksEnabled
required property bool biometricsAvailable
required property bool displayKeycardPromoBanner
required property bool networkChecksEnabled

// functions
required property var passwordStrengthScoreFunction
Expand Down Expand Up @@ -145,8 +145,8 @@ SQUtils.QObject {
isSeedPhraseValid: root.isSeedPhraseValid
passwordStrengthScoreFunction: root.passwordStrengthScoreFunction

onSeedphraseSubmitted: root.seedphraseSubmitted(seedphrase)
onSetPasswordRequested: root.setPasswordRequested(password)
onSeedphraseSubmitted: (seedphrase) => root.seedphraseSubmitted(seedphrase)
onSetPasswordRequested: (password) => root.setPasswordRequested(password)
onFinished: d.pushOrSkipBiometricsPage()
}

Expand All @@ -162,7 +162,7 @@ SQUtils.QObject {
splashScreenDurationMs: root.splashScreenDurationMs

onReloadKeycardRequested: root.reloadKeycardRequested()
onKeycardPinCreated: root.keycardPinCreated(pin)
onKeycardPinCreated: (pin) => root.keycardPinCreated(pin)
onLoginWithKeycardRequested: loginWithKeycardFlow.init()

onCreateProfileWithoutKeycardRequested: {
Expand All @@ -172,6 +172,8 @@ SQUtils.QObject {
stackView.replace(page, createProfilePage, StackView.PopTransition)
}

onSeedphraseSubmitted: (seedphrase) => root.seedphraseSubmitted(seedphrase)

onFinished: (fromBackupSeedphrase) => {
d.flow = fromBackupSeedphrase
? Onboarding.SecondaryFlow.CreateProfileWithKeycardExistingSeedphrase
Expand All @@ -190,8 +192,8 @@ SQUtils.QObject {

splashScreenDurationMs: root.splashScreenDurationMs

onSyncProceedWithConnectionString:
root.syncProceedWithConnectionString(connectionString)
onSyncProceedWithConnectionString: (connectionString) =>
root.syncProceedWithConnectionString(connectionString)

onLoginWithSeedphraseRequested: {
d.flow = Onboarding.SecondaryFlow.LoginWithSeedphrase
Expand All @@ -213,7 +215,7 @@ SQUtils.QObject {
displayKeycardPromoBanner: root.displayKeycardPromoBanner
tryToSetPinFunction: root.tryToSetPinFunction

onKeycardPinEntered: root.keycardPinEntered(pin)
onKeycardPinEntered: (pin) => root.keycardPinEntered(pin)
onReloadKeycardRequested: root.reloadKeycardRequested()
onCreateProfileWithEmptyKeycardRequested: keycardCreateProfileFlow.init()

Expand All @@ -227,7 +229,7 @@ SQUtils.QObject {
id: enableBiometricsPage

EnableBiometricsPage {
onEnableBiometricsRequested: {
onEnableBiometricsRequested: (enable) => {
root.enableBiometricsRequested(enable)
root.finished(d.flow)
}
Expand Down
22 changes: 12 additions & 10 deletions ui/app/AppLayouts/Onboarding2/OnboardingLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Page {
objectName: "stack"
anchors.fill: parent

property bool backAvailable:
readonly property bool backAvailable:
stack.currentItem ? (stack.currentItem.backAvailableHint ?? true)
: false
}
Expand All @@ -95,6 +95,7 @@ Page {
anchors.fill: parent
acceptedButtons: Qt.BackButton
enabled: stack.depth > 1 && !stack.busy
cursorShape: undefined
onClicked: stack.pop()
}

Expand Down Expand Up @@ -137,32 +138,33 @@ Page {
tryToSetPinFunction: root.onboardingStore.setPin
remainingAttempts: root.onboardingStore.keycardRemainingPinAttempts

onKeycardPinCreated: {
onKeycardPinCreated: (pin) => {
d.keycardPin = pin
root.onboardingStore.setPin(pin)
}

onKeycardPinEntered: {
onKeycardPinEntered: (pin) => {
d.keycardPin = pin
root.onboardingStore.setPin(pin)
}

onShareUsageDataRequested: {
onShareUsageDataRequested: (enabled) => {
root.metricsStore.toggleCentralizedMetrics(enabled)
Global.addCentralizedMetricIfEnabled(
"usage_data_shared",
{ placement: Constants.metricsEnablePlacement.onboarding })
localAppSettings.metricsPopupSeen = true
}

onSyncProceedWithConnectionString:
root.onboardingStore.inputConnectionStringForBootstrapping(
connectionString)
onSyncProceedWithConnectionString: (connectionString) =>
root.onboardingStore.inputConnectionStringForBootstrapping(connectionString)

onSeedphraseSubmitted: d.seedphrase = seedphrase
onSetPasswordRequested: d.password = password
onSeedphraseSubmitted: (seedphrase) => d.seedphrase = seedphrase
onSetPasswordRequested: (password) => d.password = password

onFinished: d.finishFlow(flow)
onEnableBiometricsRequested: (enabled) => d.enableBiometrics = enabled

onFinished: (flow) => d.finishFlow(flow)
}

Connections {
Expand Down
1 change: 0 additions & 1 deletion ui/app/AppLayouts/Onboarding2/OnboardingStackView.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import QtQuick 2.15
import QtQuick.Controls 2.15


StackView {
id: root

Expand Down
2 changes: 1 addition & 1 deletion ui/app/AppLayouts/Onboarding2/UseRecoveryPhraseFlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SQUtils.QObject {
title: qsTr("Create profile using a recovery phrase")
isSeedPhraseValid: root.isSeedPhraseValid

onSeedphraseSubmitted: {
onSeedphraseSubmitted: (seedphrase) => {
root.seedphraseSubmitted(seedphrase)
root.stackView.push(createPasswordPage)
}
Expand Down

0 comments on commit 50e907b

Please sign in to comment.