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

remove automatic username generation #114

Merged
merged 1 commit into from
Feb 12, 2020
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
5 changes: 1 addition & 4 deletions src/components/onboarding/screens/username.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Box, Flex, Input, Text, Button } from '@blockstack/ui';
import { Screen, ScreenBody, ScreenActions, Title } from '@blockstack/connect';
import { ScreenHeader } from '@components/connected-screen-header';

import { getRandomWord } from '@common/utils';
import { useAppDetails } from '@common/hooks/useAppDetails';
import { useDispatch, useSelector } from 'react-redux';
import { doSetUsername, doFinishSignIn } from 'store/onboarding/actions';
Expand All @@ -15,8 +14,6 @@ import { registerSubdomain, Subdomains } from '@blockstack/keychain';
import { didGenerateWallet } from '@store/wallet';
import { gaiaUrl } from '@common/constants';

const randomUsername = `${getRandomWord()}-${getRandomWord()}-${getRandomWord()}-${getRandomWord()}`;

interface UsernameProps {
next: () => void;
}
Expand All @@ -31,7 +28,7 @@ export const Username: React.FC<UsernameProps> = ({ next }) => {

const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const [username, setUsername] = useState(randomUsername);
const [username, setUsername] = useState('');

const handleInput = (evt: React.FormEvent<HTMLInputElement>) => {
setError('');
Expand Down
23 changes: 15 additions & 8 deletions tests/integration/authentication.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Wallet } from '@blockstack/keychain';
import { validateMnemonic, generateMnemonic } from 'bip39';
import { validateMnemonic, generateMnemonic, wordlists } from 'bip39';
import { Page } from 'puppeteer';

import { AuthPageObject } from './page-objects/auth.page';
Expand All @@ -14,12 +14,15 @@ async function bootstrapConnectModalPageTest(demo: DemoPageObject, auth: AuthPag
const authPage = await newWindow.page();
expect(authPage.url().startsWith(auth.url)).toBeTruthy();
await authPage.waitFor(auth.$inputUsername, { timeout: 15000 });
authPage.on('console', event => {
console.log(event.type(), event.text());
});
return { authPage };
}

const getRandomWord = () => {
const list = wordlists.EN;
const word = list[Math.floor(Math.random() * list.length)];
return word;
};

describe('Authentication', () => {
let authPageObject: AuthPageObject;
let demoPageObject: DemoPageObject;
Expand All @@ -37,6 +40,10 @@ describe('Authentication', () => {
if (!$usernameInputElement) {
throw 'Could not find username field';
}
await authPage.type(
authPageObject.$inputUsername,
`${getRandomWord()}-${getRandomWord()}-${getRandomWord()}-${getRandomWord()}`
);
await authPage.click(authPageObject.$buttonUsernameContinue);

await authPage.waitFor(authPageObject.$textareaReadOnlySeedPhrase);
Expand Down Expand Up @@ -73,12 +80,13 @@ describe('Authentication', () => {

authPage = pages.authPage;

await authPage.type(
authPageObject.$inputUsername,
`${getRandomWord()}-${getRandomWord()}-${getRandomWord()}-${getRandomWord()}`
);
await authPage.click(authPageObject.$buttonUsernameContinue);
await authPage.screenshot({ path: 'tests/screenshot2.png' });
await authPage.waitFor(authPageObject.$textareaReadOnlySeedPhrase);
await authPage.screenshot({ path: 'tests/screenshot3.png' });
await authPage.click(authPageObject.$buttonCopySecretKey);
await authPage.screenshot({ path: 'tests/screenshot4.png' });
await authPage.waitFor(authPageObject.$buttonHasSavedSeedPhrase);
await authPage.click(authPageObject.$buttonHasSavedSeedPhrase);
await authPage.waitFor(authPageObject.$buttonConfirmReenterSeedPhrase);
Expand All @@ -89,7 +97,6 @@ describe('Authentication', () => {
test('it does not let you proceed when entering an incorrect seed phrase', async done => {
const nonsenseRhymingSeed = 'You might encounter some delays, if you forget your seed phrase';

await authPage.screenshot({ path: 'tests/screenshot.png' });
await authPage.type(authPageObject.$textareaSeedPhraseInput, nonsenseRhymingSeed);
await authPage.click(authPageObject.$buttonConfirmReenterSeedPhrase);

Expand Down