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

Wallet 441 cw automation backup secret phrase #1075

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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
13 changes: 13 additions & 0 deletions e2e-tests/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import {Page, Locator} from '@playwright/test'

export const vaultPassword = '3hQqzYn4C7Y8rEZTVEZb';
export const twentyFourWordsSecretPhrase =
Expand Down Expand Up @@ -109,6 +110,18 @@ export const NEW_VALIDATOR_FOR_STAKE = {
export const URLS = {
rpc: 'https://node.testnet.cspr.cloud/rpc'
};
export function createLocators(page: Page) {
return {
accountSwitcher: page.getByTestId('connection-status-modal'),
firstAccount: page.locator("span[type='bodySemiBold'].sc-iOeugr.hnMrar.sc-iJbNxu.bAimRi"),
CSPRtotalBalance: page.locator('span[type="CSPRBold"]'),
liquidBalance: page.locator('#layout-content-container > div > div.sc-gGvHcT.LEYqH > div > div.sc-hLBbgP.sc-kDvujY.bxIaNA.czrHSx > div.sc-hLBbgP.sc-kDvujY.nnmro.czrHSx > div.sc-hLBbgP.sc-kDvujY.sc-fmixVB.eJhjZ.czrHSx.jIbqvc > div:nth-child(1) > div > span.sc-iOeugr.fFyyCL'),
delegatedBalance: page.locator('//*[@id="layout-content-container"]/div/div[1]/div/div[2]/div[2]/div[2]/div[2]/div/span[1]'),
undelegatingBalance: page.locator('//*[@id="layout-content-container"]/div/div[1]/div/div[2]/div[2]/div[2]/div[3]/div/span[1]'),
totalBalanceUSD: page.locator('//span[@type="captionRegular" and @color="contentSecondary"]'),
threeDotsMenu: page.locator("//*[contains(@class, 'sc-eJDSGI') and contains(@class, 'bMCuLR')]")
};
}

export const RPC_RESPONSE = {
success: {
Expand Down
36 changes: 34 additions & 2 deletions e2e-tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ export const popup = test.extend<{
createAccount: (newAccountName: string) => Promise<void>;
connectAccounts: () => Promise<void>;
addContact: () => Promise<void>;
providePassword: (popupPage?: Page) => Promise<void>;
passwordTimeout: (popupPage?: Page) => Promise<void>;
}>({
popupPage: async ({ extensionId, page }, use) => {
await page.goto(`chrome-extension://${extensionId}/popup.html`);
Expand Down Expand Up @@ -291,7 +293,37 @@ export const popup = test.extend<{
};

await use(addContact);
}
});
},


providePassword: async ({ page }, use) => {
const providePassword = async (popupPage?: Page) => {
const currentPage = popupPage || page;

await currentPage
.getByPlaceholder('Password', { exact: true })
.fill(vaultPassword);
await currentPage.getByRole('button', { name: 'Continue' }).click();
};

await use(providePassword);
},

passwordTimeout: async ({ page }, use) => {
const passwordTimeout = async (popupPage?: Page) => {
const currentPage = popupPage || page;

await currentPage
.getByPlaceholder('Password', { exact: true })
.fill('wrong password');

for (let i = 0; i < 5; i++) {
await currentPage.getByRole('button', { name: 'Continue' }).click();
}

};

await use(passwordTimeout);
}
});
export const popupExpect = popup.expect;
21 changes: 21 additions & 0 deletions e2e-tests/onboarding-flow/confirm-secret-phrase-flow.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { onboardingExpect, onboarding } from '../fixtures';
import { DEFAULT_FIRST_ACCOUNT } from '../constants';
import { createLocators } from '../constants';

onboarding.describe('Onboarding UI: confirm secret phrase flow', () => {
onboarding(
Expand Down Expand Up @@ -30,6 +31,26 @@ onboarding.describe('Onboarding UI: confirm secret phrase flow', () => {
await onboardingExpect(
page.getByText(DEFAULT_FIRST_ACCOUNT.accountName)
).toBeVisible();
//Fresh account should have empty balances, no nft or deploy history
await onboardingExpect(
page.getByText("NFTs")).toBeVisible();

await page.getByText("NFTs").click();

await onboardingExpect(
await page.getByText("No NFT tokens")).toBeVisible();

await page.getByText("Deploys").click();

await onboardingExpect(
await page.getByText("No activity")).toBeVisible();

const locators = createLocators(page);
const accountSwitcher = locators.accountSwitcher;
const firstAccount = locators.firstAccount;

// Perform actions and assertions
await accountSwitcher.click();
Comment on lines +48 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this code do?

}
);

Expand Down
111 changes: 111 additions & 0 deletions e2e-tests/popup/settings/backup secret phrase.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import {
DEFAULT_FIRST_ACCOUNT,
DEFAULT_SECOND_ACCOUNT,
vaultPassword
} from '../../constants';
import { popup, popupExpect } from '../../fixtures';


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the name-name format for file naming.

//TODO
// add check to comparedisplayed phrase with the one used in onboarding
popup.describe('Popup UI: back up secret phrase', () => {
popup(
"should display a secret phrase after providing password and copy phrase",
async ({ popupPage, unlockVault, providePassword }) => {
await unlockVault();
await popupPage.getByTestId('menu-open-icon').click();
await popupPage.getByText('Back up your secret recovery phrase').click();
await providePassword();


await popupExpect(
popupPage.getByRole('heading', { name: 'Back up your secret recovery phrase' })
).toBeVisible();
await popupPage.getByText('Click to reveal secret recovery phrase').click();
await popupPage.getByText('Copy secret recovery phrase').click();



await popupExpect(
popupPage.getByText(
'Copied to clipboard'
)
).toBeVisible();
}
Comment on lines +12 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to let you know that you didn't check if the secret phrase was displayed and if it was copied.
You test if the text changed after the user clicks on the copy text


);
popup(
'should display safety tips',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need this test. Here we test UI text and no functionality

async ({ popupPage, unlockVault, providePassword }) => {
await unlockVault();
await popupPage.getByTestId('menu-open-icon').click();
await popupPage.getByText('Back up your secret recovery phrase').click();
await providePassword();


await popupExpect(
popupPage.getByRole('heading', { name: 'Back up your secret recovery phrase' })
).toBeVisible();


await popupExpect(
popupPage.getByText(
'Save a backup in multiple secure locations.'
)
).toBeVisible();


await popupExpect(
popupPage.getByText(
'Never share the phrase with anyone.'
)
).toBeVisible();


await popupExpect(
popupPage.getByText(
'Be careful of phishing! Casper Wallet will never spontaneously ask you for your secret recovery phrase.'
)
).toBeVisible();


await popupExpect(
popupPage.getByText(
'If you need to back up your secret recovery phrase again, you can find it in Settings.'
)
).toBeVisible();


await popupExpect(
popupPage.getByText(
'Casper Wallet cannot recover your secret recovery phrase! If you lose it, you may not be able to recover your funds.'
)
).toBeVisible();
})


popup(
"should timeout after providing wrong password 5 times",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have a test for locking the wallet for 5 minutes when the user types the wrong password 5 times
common/wallet.spec.ts

async ({ popupPage, unlockVault, passwordTimeout }) => {
await unlockVault();

await popupPage.getByTestId('menu-open-icon').click();
await popupPage.getByText('Back up your secret recovery phrase').click();

await passwordTimeout();


await popupExpect(
popupPage.getByRole('heading', { name: 'Please wait before the next attempt to unlock your wallet' })
).toBeVisible();
})
});









Loading