mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-28 23:06:37 +01:00
9acd4b4ea1
* feat(srp): add a quiz to the SRP reveal * fixed the popover header centering * lint fixes * converted from `ui/components/ui/popover` to `ui/components/component-library/modal` * responded to @darkwing review * added unit tests * renamed the folder to 'srp-quiz-modal' * responded to Monte's review * using i18n-helper in the test suite * small improvement to JSXDict comments * wrote a new webdriver.holdMouseDownOnElement() to assist with testing the "Hold to reveal SRP" button * Updating layout and some storybook naming and migrating to tsx * Apply suggestions from @georgewrmarshall Co-authored-by: George Marshall <george.marshall@consensys.net> * Unit test searches by data-testid instead of by text * new layout and copy for the Settings->Security page * now with 100% test coverage for /ui/pages/settings/security-tab fixes #16871 fixes #18140 * e2e tests to reveal SRP after quiz * e2e- Fix lint, remove unneeded extras * @coreyjanssen and @georgewrmarshall compromise Co-authored-by: George Marshall <george.marshall@consensys.net> Co-authored-by: Corey Janssen <corey.janssen@consensys.net> * trying isRequired again * transparent background on PNG * [e2e] moving functions to helpers and adding testid for SRP reveal quiz (#19481) * moving functions to helpers and adding testid * fix lint error * took out the IPFS gateway fixes * lint fix * translations of SRP Reveal Quiz * new Spanish translation from Guto * Update describe for e2e tests * Apply suggestion from @georgewrmarshall Co-authored-by: George Marshall <george.marshall@consensys.net> * fixed the Tab key problem --------- Co-authored-by: georgewrmarshall <george.marshall@consensys.net> Co-authored-by: Plasma Corral <32695229+plasmacorral@users.noreply.github.com> Co-authored-by: Corey Janssen <corey.janssen@consensys.net>
136 lines
4.1 KiB
JavaScript
136 lines
4.1 KiB
JavaScript
const { strict: assert } = require('assert');
|
|
const {
|
|
withFixtures,
|
|
passwordUnlockOpenSRPRevealQuiz,
|
|
completeSRPRevealQuiz,
|
|
tapAndHoldToRevealSRP,
|
|
closeSRPReveal,
|
|
} = require('../helpers');
|
|
const FixtureBuilder = require('../fixture-builder');
|
|
const { tEn } = require('../../lib/i18n-helpers');
|
|
|
|
describe('Reveal SRP through settings', function () {
|
|
const testPassword = 'correct horse battery staple';
|
|
const wrongTestPassword = 'test test test test';
|
|
const seedPhraseWords =
|
|
'spread raise short crane omit tent fringe mandate neglect detail suspect cradle';
|
|
|
|
it('should not reveal SRP text with incorrect password', async function () {
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder().build(),
|
|
title: this.test.title,
|
|
failOnConsoleError: false,
|
|
},
|
|
async ({ driver }) => {
|
|
await passwordUnlockOpenSRPRevealQuiz(driver);
|
|
await completeSRPRevealQuiz(driver);
|
|
await driver.fill('#password-box', wrongTestPassword);
|
|
await driver.press('#password-box', driver.Key.ENTER);
|
|
await driver.isElementPresent(
|
|
{
|
|
css: '.mm-help-text',
|
|
text: 'Incorrect password',
|
|
},
|
|
true,
|
|
);
|
|
},
|
|
);
|
|
});
|
|
|
|
it('completes quiz and reveals SRP text', async function () {
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder().build(),
|
|
title: this.test.title,
|
|
},
|
|
async ({ driver }) => {
|
|
await passwordUnlockOpenSRPRevealQuiz(driver);
|
|
await completeSRPRevealQuiz(driver);
|
|
|
|
// enter password
|
|
await driver.fill('#password-box', testPassword);
|
|
await driver.press('#password-box', driver.Key.ENTER);
|
|
|
|
await tapAndHoldToRevealSRP(driver);
|
|
|
|
// confirm SRP text matches expected
|
|
const displayedSRP = await driver.findVisibleElement(
|
|
'[data-testid="srp_text"]',
|
|
);
|
|
assert.equal(await displayedSRP.getText(), seedPhraseWords);
|
|
|
|
// copy SRP text to clipboard
|
|
await driver.clickElement({
|
|
text: tEn('copyToClipboard'),
|
|
tag: 'button',
|
|
});
|
|
await driver.findVisibleElement({
|
|
text: tEn('copiedExclamation'),
|
|
tag: 'button',
|
|
});
|
|
|
|
// confirm that CTA returns user to wallet view
|
|
await closeSRPReveal(driver);
|
|
},
|
|
);
|
|
});
|
|
|
|
it('completes quiz and reveals SRP QR after wrong answers', async function () {
|
|
await withFixtures(
|
|
{
|
|
fixtures: new FixtureBuilder().build(),
|
|
title: this.test.title,
|
|
},
|
|
async ({ driver }) => {
|
|
await passwordUnlockOpenSRPRevealQuiz(driver);
|
|
|
|
// start quiz
|
|
await driver.clickElement('[data-testid="srp-quiz-get-started"]');
|
|
|
|
// tap incorrect answer 1
|
|
await driver.clickElement('[data-testid="srp-quiz-wrong-answer"]');
|
|
|
|
// try again
|
|
await driver.clickElement('[data-testid="srp-quiz-try-again"]');
|
|
|
|
// tap correct answer 1
|
|
await driver.clickElement('[data-testid="srp-quiz-right-answer"]');
|
|
|
|
// tap Continue 1
|
|
await driver.clickElement('[data-testid="srp-quiz-continue"]');
|
|
|
|
// tap incorrect answer 2
|
|
await driver.clickElement('[data-testid="srp-quiz-wrong-answer"]');
|
|
|
|
// try again
|
|
await driver.clickElement('[data-testid="srp-quiz-try-again"]');
|
|
|
|
// tap correct answer 1
|
|
await driver.clickElement('[data-testid="srp-quiz-right-answer"]');
|
|
|
|
// tap Continue 2
|
|
await driver.clickElement('[data-testid="srp-quiz-continue"]');
|
|
|
|
// enter password
|
|
await driver.fill('#password-box', testPassword);
|
|
await driver.press('#password-box', driver.Key.ENTER);
|
|
|
|
// tap and hold to reveal
|
|
await tapAndHoldToRevealSRP(driver);
|
|
|
|
// confirm SRP QR is displayed
|
|
await driver.clickElement({
|
|
text: 'QR',
|
|
tag: 'button',
|
|
});
|
|
const qrCode = await driver.findElement('[data-testid="qr-srp"]');
|
|
assert.equal(await qrCode.isDisplayed(), true);
|
|
|
|
// confirm that CTA returns user to wallet view
|
|
await closeSRPReveal(driver);
|
|
},
|
|
);
|
|
});
|
|
});
|