All files / app/tests/features global.feature.ts

0% Statements 0/28
0% Branches 0/3
0% Functions 0/3
0% Lines 0/25

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                                                                                                         
import { delay } from '../../utils/delay';
import { createTestSelector } from '../integration-helpers';
import { createOnboardingFeature } from './onboarding.feature';
import { createSettingsFeature } from './settings.feature';
import type { Page } from 'playwright';
 
export function createGlobalFeature(page: Page) {
  return {
    settingsPageSelector: createTestSelector('btn-settings'),
 
    findSettingsBtn() {
      return page.$(this.settingsPageSelector);
    },
  };
}
 
export async function resetWallet(page: Page) {
  const settingsFeature = createSettingsFeature(page);
 
  //
  // Settings steps
  await page.waitForSelector(createTestSelector('btn-settings'));
 
  await page.screenshot({
    path: `screenshots/${String(process.env.STX_NETWORK)}-01-reset-wallet.png`,
  });
 
  const settingsButton = await page.$(createTestSelector('btn-settings'));
  Iif (!settingsButton) throw new Error('Should be defined');
  await settingsButton.click();
 
  const openResetWalletModalBtn = await settingsFeature.findOpenResetModalBtn();
  Iif (!openResetWalletModalBtn) throw new Error('Should be defined');
  await openResetWalletModalBtn.click();
 
  await page.screenshot({
    path: `screenshots/${String(process.env.STX_NETWORK)}-02-reset-wallet.png`,
  });
 
  const resetWalletButton = await page.$('[data-test="btn-reset-wallet"]');
  Iif (!resetWalletButton) throw new Error('Should be defined.');
  await resetWalletButton.click();
  await delay(4000);
 
  await page.screenshot({
    path: `screenshots/${String(process.env.STX_NETWORK)}-03-reset-wallet.png`,
  });
 
  // Reset should return to Tos page
  const onboarding = createOnboardingFeature(page);
  return onboarding.findTermsOfServiceTitle();
}