Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: e2e Reveal Secret Recovery Phrase Quiz answer confirmation #10273

Merged
merged 20 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/components/Views/Quiz/QuizContent/QuizContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const QuizContent = ({
<Text
variant={TextVariant.HeadingLG}
style={{ ...styles.title, ...title.style }}
testID={title.testID}
>
{title.content}
</Text>
Expand All @@ -67,6 +68,7 @@ const QuizContent = ({
onPress={btn.onPress}
label={btn.label}
style={styles.button}
testID={btn.testID}
/>
))}
</View>
Expand Down
36 changes: 36 additions & 0 deletions app/components/Views/Quiz/SRPQuiz/SRPQuiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import { QuizContent } from '../QuizContent';
import stylesheet from './styles';
import { useMetrics } from '../../../../components/hooks/useMetrics';

import {
SecurityQuizGetStartedModalSelectorsIDs,
SecurityQuizGetStartedModalSelectorsText,
SecurityQuestionOneModelSelectorsIDs,
SecurityQuizQuestionOneModalSelectorsText,
SecurityQuestionTwoModelSelectorsIDs,
SecurityQuizQuestionTwoModalSelectorsText,
} from '../../../../../e2e/selectors/Modals/SecurityQuizModal.selectors.js';
const introductionImg = require('../../../../images/reveal-srp.png');

const SRPQuiz = () => {
Expand Down Expand Up @@ -83,6 +91,7 @@ const SRPQuiz = () => {
image={introductionImg}
title={{
content: strings('srp_security_quiz.introduction'),
testID: SecurityQuizGetStartedModalSelectorsText.QUIZ_INTRODUCTION,
}}
buttons={[
{
Expand All @@ -91,6 +100,8 @@ const SRPQuiz = () => {
trackEvent(MetaMetricsEvents.SRP_REVEAL_START_CTA_SELECTED, {});
setStage(QuizStage.questionOne);
},
testID:
SecurityQuizGetStartedModalSelectorsIDs.QUIZ_GET_STARTED_BUTTON,
variant: ButtonVariants.Primary,
},
{
Expand All @@ -111,17 +122,22 @@ const SRPQuiz = () => {
header={`1 ${strings('srp_security_quiz.of')} 2`}
title={{
content: strings('srp_security_quiz.question_one.question'),
testId: SecurityQuizQuestionOneModalSelectorsText.QUIZ_QUESTION_ONE,
}}
buttons={[
{
label: strings('srp_security_quiz.question_one.wrong_answer'),
onPress: () => setStage(QuizStage.wrongAnswerQuestionOne),
variant: ButtonVariants.Secondary,
testID:
SecurityQuestionOneModelSelectorsIDs.QUIZ_QUESTION_ONE_WRONG_ANSWER,
},
{
label: strings('srp_security_quiz.question_one.right_answer'),
onPress: () => setStage(QuizStage.rightAnswerQuestionOne),
variant: ButtonVariants.Secondary,
testID:
SecurityQuestionOneModelSelectorsIDs.QUIZ_QUESTION_ONE_RIGHT_ANSWER,
},
{
label: strings('srp_security_quiz.learn_more'),
Expand All @@ -143,6 +159,8 @@ const SRPQuiz = () => {
title={{
content: strings('srp_security_quiz.question_one.right_answer_title'),
style: styles.rightText,
testID:
SecurityQuizQuestionOneModalSelectorsText.QUIZ_QUESTION_ONE_RIGHT_ANSWER_RESPONSE_TITLE,
}}
content={strings(
'srp_security_quiz.question_one.right_answer_description',
Expand All @@ -152,6 +170,8 @@ const SRPQuiz = () => {
label: strings('srp_security_quiz.continue'),
onPress: () => setStage(QuizStage.questionTwo),
variant: ButtonVariants.Primary,
testID:
SecurityQuestionOneModelSelectorsIDs.QUIZ_QUESTION_ONE_RIGHT_CONTINUE,
},
{
label: strings('srp_security_quiz.learn_more'),
Expand All @@ -173,6 +193,8 @@ const SRPQuiz = () => {
title={{
content: strings('srp_security_quiz.question_one.wrong_answer_title'),
style: styles.wrongText,
testID:
SecurityQuizQuestionOneModalSelectorsText.QUIZ_QUESTION_ONE_WRONG_ANSWER_RESPONSE_TITLE,
}}
content={strings(
'srp_security_quiz.question_one.wrong_answer_description',
Expand All @@ -182,6 +204,8 @@ const SRPQuiz = () => {
label: strings('srp_security_quiz.try_again'),
onPress: () => setStage(QuizStage.questionOne),
variant: ButtonVariants.Primary,
testID:
SecurityQuestionOneModelSelectorsIDs.QUIZ_QUESTION_ONE_WRONG_ANSWER_TRY_AGAIN_BUTTON,
},
{
label: strings('srp_security_quiz.learn_more'),
Expand All @@ -207,11 +231,15 @@ const SRPQuiz = () => {
label: strings('srp_security_quiz.question_two.right_answer'),
onPress: () => setStage(QuizStage.rightAnswerQuestionTwo),
variant: ButtonVariants.Secondary,
testID:
SecurityQuestionTwoModelSelectorsIDs.QUIZ_QUESTION_TWO_RIGHT_ANSWER,
},
{
label: strings('srp_security_quiz.question_two.wrong_answer'),
onPress: () => setStage(QuizStage.wrongAnswerQuestionTwo),
variant: ButtonVariants.Secondary,
testID:
SecurityQuestionTwoModelSelectorsIDs.QUIZ_QUESTION_TWO_WRONG_ANSWER,
},
{
label: strings('srp_security_quiz.learn_more'),
Expand All @@ -233,6 +261,8 @@ const SRPQuiz = () => {
title={{
content: strings('srp_security_quiz.question_two.right_answer_title'),
style: styles.rightText,
testID:
SecurityQuizQuestionTwoModalSelectorsText.QUIZ_QUESTION_TWO_RIGHT_ANSWER_RESPONSE_TITLE,
}}
content={strings(
'srp_security_quiz.question_two.right_answer_description',
Expand All @@ -242,6 +272,8 @@ const SRPQuiz = () => {
label: strings('srp_security_quiz.continue'),
onPress: goToRevealPrivateCredential,
variant: ButtonVariants.Primary,
testID:
SecurityQuestionTwoModelSelectorsIDs.QUIZ_QUESTION_TWO_RIGHT_CONTINUE,
},
{
label: strings('srp_security_quiz.learn_more'),
Expand All @@ -268,6 +300,8 @@ const SRPQuiz = () => {
title={{
content: strings('srp_security_quiz.question_two.wrong_answer_title'),
style: styles.wrongText,
testID:
SecurityQuizQuestionOneModalSelectorsText.QUIZ_QUESTION_ONE_WRONG_ANSWER_RESPONSE_TITLE,
}}
content={strings(
'srp_security_quiz.question_two.wrong_answer_description',
Expand All @@ -277,6 +311,8 @@ const SRPQuiz = () => {
label: strings('srp_security_quiz.try_again'),
onPress: () => setStage(QuizStage.questionTwo),
variant: ButtonVariants.Primary,
testID:
SecurityQuestionTwoModelSelectorsIDs.QUIZ_QUESTION_TWO_WRONG_ANSWER_TRY_AGAIN_BUTTON,
},
{
label: strings('srp_security_quiz.learn_more'),
Expand Down
3 changes: 3 additions & 0 deletions app/components/Views/Quiz/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export interface IQuizInformationProps {
// TODO: Replace "any" with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
style?: any;
testID?: string;
};
buttons: {
onPress: () => void;
label: string;
variant: ButtonVariants;
testID?: string;
}[];
dismiss: () => void;
header?: string;
Expand All @@ -30,4 +32,5 @@ export interface IQuizInformationProps {
// TODO: Replace "any" with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
icon?: any;
testID?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import { isHardwareAccount } from '../../../util/address';
import AppConstants from '../../../core/AppConstants';
import { createStyles } from './styles';
import { getNavigationOptionsTitle } from '../../../components/UI/Navbar';
import generateTestId from '../../../../wdio/utils/generateTestId';
import { RevealSeedViewSelectorsIDs } from '../../../../e2e/selectors/Settings/SecurityAndPrivacy/RevealSeedView.selectors';

import { selectSelectedInternalAccountChecksummedAddress } from '../../../selectors/accountsController';
Expand Down Expand Up @@ -467,10 +466,9 @@ const RevealPrivateCredential = ({
: strings('reveal_credential.srp_abbreviation_text'),
})}
onLongPress={() => revealCredential(privCredentialName)}
{...generateTestId(
Platform,
RevealSeedViewSelectorsIDs.SECRET_RECOVERY_PHRASE_LONG_PRESS_BUTTON_ID,
)}
testID={
RevealSeedViewSelectorsIDs.SECRET_RECOVERY_PHRASE_LONG_PRESS_BUTTON_ID
}
/>
</>
}
Expand Down
10 changes: 10 additions & 0 deletions e2e/pages/Settings/SecurityAndPrivacy/SecurityAndPrivacyView.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class SecurityAndPrivacy {
);
}

get revealSecretRecoveryPhraseButton() {
return Matchers.getElementByID(
SecurityPrivacyViewSelectorsIDs.REVEAL_SEED_BUTTON,
);
}

get deleteWalletButton() {
return device.getPlatform() === 'ios'
? Matchers.getElementByID(SECURITY_PRIVACY_DELETE_WALLET_BUTTON)
Expand Down Expand Up @@ -70,6 +76,10 @@ class SecurityAndPrivacy {
);
}

async tapRevealSecretRecoveryPhraseButton() {
await Gestures.waitAndTap(this.revealSecretRecoveryPhraseButton);
}

async tapChangePasswordButton() {
await Gestures.waitAndTap(this.changePasswordButton);
}
Expand Down
Loading
Loading