mirror of
https://github.com/zhigang1992/wallet.git
synced 2026-01-12 17:53:19 +08:00
81 lines
3.0 KiB
TypeScript
81 lines
3.0 KiB
TypeScript
import { RouteUrls } from '@shared/route-urls';
|
|
|
|
import { delay } from '@app/common/utils';
|
|
|
|
import { WalletPage } from '../../page-objects/wallet.page';
|
|
import { SettingsSelectors } from '../settings.selectors';
|
|
import { BrowserDriver, createTestSelector, randomString, setupBrowser } from '../utils';
|
|
|
|
jest.setTimeout(60_000);
|
|
jest.retryTimes(process.env.CI ? 2 : 0);
|
|
|
|
describe(`Settings integration tests`, () => {
|
|
let secretKey = '';
|
|
let browser: BrowserDriver;
|
|
let wallet: WalletPage;
|
|
|
|
beforeAll(async () => {
|
|
browser = await setupBrowser();
|
|
wallet = await WalletPage.init(browser, RouteUrls.Onboarding);
|
|
await wallet.signUp();
|
|
await wallet.waitForHideOnboardingsStepsButton();
|
|
await wallet.clickHideSteps();
|
|
await delay(500);
|
|
});
|
|
|
|
afterAll(async () => {
|
|
try {
|
|
await browser.context.close();
|
|
} catch (error) {}
|
|
});
|
|
|
|
it('should be able to view and save secret key to clipboard', async () => {
|
|
await wallet.goToSecretKey();
|
|
await wallet.waitForEnterPasswordInput();
|
|
await wallet.enterPasswordAndUnlockWallet();
|
|
secretKey = await wallet.getSecretKey();
|
|
await wallet.page.click(createTestSelector(SettingsSelectors.CopyKeyToClipboardBtn));
|
|
const copySuccessMessage = await wallet.page.textContent(
|
|
createTestSelector(SettingsSelectors.CopyKeyToClipboardBtn)
|
|
);
|
|
expect(copySuccessMessage).toContain('Copied!');
|
|
});
|
|
|
|
it('should be able to sign out, lock and unlock the extension', async () => {
|
|
await wallet.waitForSettingsButton();
|
|
await wallet.clickSettingsButton();
|
|
await wallet.page.click(createTestSelector(SettingsSelectors.SignOutListItem));
|
|
await wallet.page.click(wallet.$signOutConfirmHasBackupCheckbox);
|
|
await wallet.page.click(wallet.$signOutConfirmPasswordDisable);
|
|
await wallet.page.click(wallet.$signOutDeleteWalletBtn);
|
|
await wallet.clickDenyAnalytics();
|
|
await wallet.clickSignIn();
|
|
await wallet.enterSecretKey(secretKey);
|
|
const password = randomString(15);
|
|
await wallet.enterNewPassword(password);
|
|
await wallet.waitForSettingsButton();
|
|
await wallet.clickSettingsButton();
|
|
await wallet.page.click(createTestSelector(SettingsSelectors.LockListItem));
|
|
await wallet.enterPasswordAndUnlockWallet(password);
|
|
const displayName = await wallet.page.textContent(
|
|
createTestSelector(SettingsSelectors.CurrentAccountDisplayName)
|
|
);
|
|
expect(displayName).toEqual('Account 1');
|
|
});
|
|
|
|
it('should be able to change network', async () => {
|
|
await wallet.waitForSettingsButton();
|
|
await wallet.clickSettingsButton();
|
|
const currentNetwork = await wallet.page.textContent(
|
|
createTestSelector(SettingsSelectors.CurrentNetwork)
|
|
);
|
|
expect(currentNetwork).toContain('mainnet');
|
|
await wallet.page.click(createTestSelector(SettingsSelectors.ChangeNetworkAction));
|
|
await wallet.page.waitForTimeout(850);
|
|
const networkListItems = await wallet.page.$$(
|
|
createTestSelector(SettingsSelectors.NetworkListItem)
|
|
);
|
|
expect(networkListItems).toHaveLength(4);
|
|
});
|
|
});
|