All files / app/tests restore-wallet.spec.ts

0% Statements 0/39
0% Branches 0/2
0% Functions 0/6
0% Lines 0/36

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71                                                                                                                                             
import { delay } from '../utils/delay';
import { whenNetwork } from '../utils/network-utils';
import { setUpElectronApp } from './_setup-tests';
import { createGlobalFeature, resetWallet } from './features/global.feature';
import { HomeFeature } from './features/home.feature';
import { initSoftwareWallet } from './features/onboarding.feature';
import { getTestConfigPath } from './get-test-config-path';
import { _electron, ElectronApplication, Page } from 'playwright';
import rimraf from 'rimraf';
 
const PASSWORD = 'hello9*&^*^*dkfskjdfskljdfsj';
const SEED_PHRASE =
  'across okay clerk forum chief law around nuclear vacuum miss brown predict mushroom fix west quit mother afford bamboo neutral pioneer crime open call';
 
describe('Restore wallet flow', () => {
  let app: ElectronApplication;
  let page: Page;
 
  beforeEach(async () => {
    rimraf(`${getTestConfigPath()}/config.json`, err => {
      Iif (err) console.log('Issue deleting file');
    });
    app = await setUpElectronApp();
    page = await app.firstWindow();
  });
 
  async function takeScreenshot(name: string) {
    await page.screenshot({ path: `screenshots/${process.platform}/${name}.png` });
  }
 
  afterEach(async () => await app.close());
 
  test('Restore wallet', async () => {
    await initSoftwareWallet(page)(SEED_PHRASE, PASSWORD);
 
    const globalFeature = createGlobalFeature(page);
 
    //
    // Home steps
    const homeFeature = new HomeFeature(page);
    await page.waitForSelector(globalFeature.settingsPageSelector);
 
    await homeFeature.click('receiveStxBtn');
 
    await homeFeature.fillPasswordInput(PASSWORD);
 
    await homeFeature.click('revealStxAddressBtn');
 
    await homeFeature.waitFor('stxAddressText');
    const stxAddressLabel = await homeFeature.$('stxAddressText');
    Iif (!stxAddressLabel) throw new Error('Should be defined.');
 
    await takeScreenshot('restore-wallet-address');
 
    expect(await stxAddressLabel.textContent()).toEqual(
      whenNetwork({
        testnet: 'ST28VRDJ3TMB268BRMZXTJJ6Q4PABH108QNY5BSK1',
        mainnet: 'SP28VRDJ3TMB268BRMZXTJJ6Q4PABH108QM9GH8JG',
      })
    );
 
    await homeFeature.click('receiveStxModalCloseBtn');
 
    await takeScreenshot(`${String(process.env.STX_NETWORK)}-after-close-stx-modal.png`);
 
    await resetWallet(page);
    await delay(1000);
    await takeScreenshot('finished-page');
  }, 120_0000);
});