mirror of
https://github.com/zhigang1992/wallet.git
synced 2026-04-30 21:52:28 +08:00
chore: init new integration tests
This commit is contained in:
committed by
edu-stx
parent
0d193aff8d
commit
5de2613315
122
tests-legacy/integration/settings/settings.spec.ts
Normal file
122
tests-legacy/integration/settings/settings.spec.ts
Normal file
@@ -0,0 +1,122 @@
|
||||
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`, () => {
|
||||
const numOfAccountsToTest = 3;
|
||||
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 create a new account', async () => {
|
||||
await wallet.waitForSettingsButton();
|
||||
await wallet.clickSettingsButton();
|
||||
await wallet.page.click(createTestSelector(SettingsSelectors.CreateAccountBtn));
|
||||
|
||||
const expectedText = 'Account 2';
|
||||
await wallet.page.waitForSelector(`text=${expectedText}`);
|
||||
const displayName = await wallet.page.textContent(
|
||||
createTestSelector(SettingsSelectors.CurrentAccountDisplayName)
|
||||
);
|
||||
expect(displayName).toEqual(expectedText);
|
||||
});
|
||||
|
||||
it(`should be able to create ${numOfAccountsToTest} new accounts then switch between them`, async () => {
|
||||
for (let i = 0; i < numOfAccountsToTest - 1; i++) {
|
||||
await wallet.waitForSettingsButton();
|
||||
await wallet.clickSettingsButton();
|
||||
await wallet.page.click(createTestSelector(SettingsSelectors.CreateAccountBtn));
|
||||
await delay(500);
|
||||
await wallet.waitForHomePage();
|
||||
}
|
||||
|
||||
for (let i = 0; i < numOfAccountsToTest; i++) {
|
||||
await wallet.waitForSettingsButton();
|
||||
await wallet.clickSettingsButton();
|
||||
await wallet.page.click(createTestSelector(SettingsSelectors.SwitchAccount));
|
||||
await delay(500);
|
||||
await wallet.page.click(createTestSelector(`switch-account-item-${i}`));
|
||||
await wallet.page.waitForSelector(
|
||||
createTestSelector(`account-checked-${i - 1 + numOfAccountsToTest}`),
|
||||
{ state: 'hidden' }
|
||||
);
|
||||
await delay(500);
|
||||
await wallet.waitForHomePage();
|
||||
const displayName = await wallet.page.textContent(
|
||||
createTestSelector(SettingsSelectors.CurrentAccountDisplayName)
|
||||
);
|
||||
expect(displayName).toEqual(`Account ${i + 1}`);
|
||||
}
|
||||
});
|
||||
|
||||
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.$signOutDeleteWalletBtn);
|
||||
await wallet.clickDenyAnalytics();
|
||||
await wallet.clickSignIn();
|
||||
await wallet.enterSecretKey(secretKey);
|
||||
const password = randomString(15);
|
||||
await wallet.enterNewPassword(password);
|
||||
await wallet.clickSkipFundAccountButton();
|
||||
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(3);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user