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

refactor: fund test migrate, closes #4187 #4191

Merged
merged 4 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/app/components/request-password.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FormEvent, useCallback, useState } from 'react';

import { Box, Input, Stack } from '@stacks/ui';
import { SettingsSelectors } from '@tests-legacy/integration/settings.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';
import { styled } from 'leather-styles/jsx';
import { token } from 'leather-styles/tokens';

Expand Down
2 changes: 1 addition & 1 deletion src/app/features/current-account/current-account-name.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Suspense, memo } from 'react';

import { memoWithAs } from '@stacks/ui-core';
import { SettingsSelectors } from '@tests-legacy/integration/settings.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';
import { Box, BoxProps, styled } from 'leather-styles/jsx';

import { HasChildren } from '@app/common/has-children';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react';

import { SettingsSelectors } from '@tests-legacy/integration/settings.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';
import { Box, Flex, Stack, styled } from 'leather-styles/jsx';

import { LeatherButton } from '@app/components/button/button';
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/theme-drawer/theme-list.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback } from 'react';

import { Flex, FlexProps } from '@stacks/ui';
import { SettingsSelectors } from '@tests-legacy/integration/settings.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';

import { useAnalytics } from '@app/common/hooks/analytics/use-analytics';
import { UserSelectedTheme, themeLabelMap, useThemeSwitcher } from '@app/common/theme-provider';
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/fund/components/fiat-provider-item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FundPageSelectors } from '@tests-legacy/page-objects/fund.selectors';
import { FundPageSelectors } from '@tests/selectors/fund.selectors';

import { AvailableRegions } from '@app/query/common/remote-config/remote-config.query';

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/fund/components/fund-account-tile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Stack, color, transition } from '@stacks/ui';
import { FundPageSelectors } from '@tests-legacy/page-objects/fund.selectors';
import { FundPageSelectors } from '@tests/selectors/fund.selectors';
import { styled } from 'leather-styles/jsx';
import { token } from 'leather-styles/tokens';

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/fund/components/receive-stx-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import QRCodeIcon from '@assets/images/fund/qr-code-icon.png';
import ReceiveStxEllipses from '@assets/images/fund/receive-stx-ellipses.png';
import StacksIcon from '@assets/images/fund/stacks-icon.png';
import { Box } from '@stacks/ui';
import { FundPageSelectors } from '@tests-legacy/page-objects/fund.selectors';
import { FundPageSelectors } from '@tests/selectors/fund.selectors';

import { FundAccountTile } from './fund-account-tile';

Expand Down
3 changes: 1 addition & 2 deletions src/app/pages/home/components/account-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useNavigate } from 'react-router-dom';

import { HomePageSelectorsLegacy } from '@tests-legacy/page-objects/home.selectors';
import { HomePageSelectors } from '@tests/selectors/home.selectors';
import { Flex, FlexProps } from 'leather-styles/jsx';

Expand Down Expand Up @@ -30,7 +29,7 @@ export function AccountActions(props: FlexProps) {
onClick={() => navigate(isBitcoinEnabled ? RouteUrls.Receive : RouteUrls.ReceiveStx)}
/>
<ActionButton
data-testid={HomePageSelectorsLegacy.BtnFundAccount}
data-testid={HomePageSelectors.FundAccountBtn}
icon={<Plus2 />}
label="Buy"
onClick={() => navigate(RouteUrls.Fund)}
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/home/components/account-info-card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMediaQuery } from '@stacks/ui';
import { SettingsSelectors } from '@tests-legacy/integration/settings.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';
import { Box, Divider, Flex, styled } from 'leather-styles/jsx';

import { useCurrentAccountDisplayName } from '@app/common/hooks/account/use-account-names';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ButtonProps } from '@stacks/ui';
import { SettingsSelectors } from '@tests-legacy/integration/settings.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';
import { Flex } from 'leather-styles/jsx';

import { LeatherButton } from '@app/components/button/button';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FiTrash2 } from 'react-icons/fi';

import { Box, BoxProps, Button, Flex, Stack } from '@stacks/ui';
import { SettingsSelectors } from '@tests-legacy/integration/settings.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';
import { styled } from 'leather-styles/jsx';
import { token } from 'leather-styles/tokens';

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/sign-out-confirm/sign-out-confirm.layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Flex } from '@stacks/ui';
import { SettingsSelectors } from '@tests-legacy/integration/settings.selectors';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';
import { useFormik } from 'formik';
import { Box, HStack, styled } from 'leather-styles/jsx';
import { token } from 'leather-styles/tokens';
Expand Down
4 changes: 3 additions & 1 deletion src/app/query/common/remote-config/remote-config.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { GITHUB_ORG, GITHUB_REPO } from '@shared/constants';
import {
BRANCH_NAME,
IS_DEV_ENV,
IS_TEST_ENV,
LEDGER_BITCOIN_ENABLED,
WALLET_ENVIRONMENT,
} from '@shared/environment';
Expand Down Expand Up @@ -73,7 +74,8 @@ const githubWalletConfigRawUrl = `https://raw.githubusercontent.com/${GITHUB_ORG
}/config/wallet-config.json`;

async function fetchHiroMessages(): Promise<RemoteConfig> {
if (!BRANCH_NAME && WALLET_ENVIRONMENT !== 'production') return localConfig as RemoteConfig;
if ((!BRANCH_NAME && WALLET_ENVIRONMENT !== 'production') || IS_TEST_ENV)
return localConfig as RemoteConfig;
return fetch(githubWalletConfigRawUrl).then(msg => msg.json());
}

Expand Down
46 changes: 0 additions & 46 deletions tests-legacy/integration/fund/fund.spec.ts

This file was deleted.

3 changes: 2 additions & 1 deletion tests-legacy/integration/onboarding/onboarding.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { SettingsSelectors } from '@tests/selectors/settings.selectors';

import { RouteUrls } from '@shared/route-urls';

import { SECRET_KEY } from '../../mocks';
import { WalletPage } from '../../page-objects/wallet.page';
import { SettingsSelectors } from '../settings.selectors';
import { BrowserDriver, createTestSelector, setupBrowser } from '../utils';

jest.setTimeout(30_000);
Expand Down
22 changes: 0 additions & 22 deletions tests-legacy/integration/settings.selectors.ts

This file was deleted.

3 changes: 0 additions & 3 deletions tests-legacy/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,3 @@ export const STX_TRANSFER_DECODED = {
txType: 'token_transfer',
appDetails: { name: 'Testing App', icon: '/assets/messenger-app-icon.png' },
} as const;

export const SECRET_KEY_2 =
'derive plug aerobic cook until crucial school fine cushion panda ready crew photo typical nuclear ride steel indicate cupboard potato ignore bamboo script galaxy';
41 changes: 0 additions & 41 deletions tests-legacy/page-objects/fund.page.ts

This file was deleted.

6 changes: 6 additions & 0 deletions tests/page-object-models/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
readonly signOutDeleteWalletBtn: Locator;
readonly signOutSettingsListItem: Locator;
readonly lockSettingsListItem: Locator;
readonly fundAccountBtn: Locator;

readonly testNetworkSelector: string = createTestSelector(
WalletDefaultNetworkConfigurationIds.testnet
Expand All @@ -43,6 +44,7 @@
);
this.signOutSettingsListItem = page.getByTestId(SettingsSelectors.SignOutListItem);
this.lockSettingsListItem = page.getByTestId(SettingsSelectors.LockListItem);
this.fundAccountBtn = page.getByTestId(HomePageSelectors.FundAccountBtn);
}

async goToReceiveModal() {
Expand Down Expand Up @@ -96,7 +98,7 @@
}

async clickActivityTab() {
await this.page.getByTestId(HomePageSelectors.ActivityTabBtn).click();

Check failure on line 101 in tests/page-object-models/home.page.ts

View workflow job for this annotation

GitHub Actions / Shard 1 of 8

[chromium] › specs/ledger/ledger.spec.ts:20:7 › App with Ledger › that you can navigate to activity page

1) [chromium] › specs/ledger/ledger.spec.ts:20:7 › App with Ledger › that you can navigate to activity page Error: locator.click: Page closed =========================== logs =========================== waiting for getByTestId('tab-activity') ============================================================ at page-object-models/home.page.ts:101 99 | 100 | async clickActivityTab() { > 101 | await this.page.getByTestId(HomePageSelectors.ActivityTabBtn).click(); | ^ 102 | } 103 | 104 | async clickSettingsButton() { at HomePage.clickActivityTab (/home/runner/work/extension/extension/tests/page-object-models/home.page.ts:101:67) at /home/runner/work/extension/extension/tests/specs/ledger/ledger.spec.ts:21:20
}

async clickSettingsButton() {
Expand All @@ -120,4 +122,8 @@
await this.clickSettingsButton();
await this.lockSettingsListItem.click();
}

async goToFundPage() {
await this.fundAccountBtn.click();
}
}
1 change: 1 addition & 0 deletions tests/selectors/home.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export enum HomePageSelectors {
ActivityTabBtn = 'tab-activity',
BalancesTabBtn = 'tab-balances',
SwapBtn = 'swap-btn',
FundAccountBtn = 'fund-account-btn',
}
26 changes: 26 additions & 0 deletions tests/specs/fund/fund.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { FundPageSelectors } from '@tests/selectors/fund.selectors';

import { test } from '../../fixtures/fixtures';

test.describe('Buy tokens test', () => {
test.beforeEach(async ({ extensionId, globalPage, onboardingPage, homePage }) => {
await globalPage.setupAndUseApiCalls(extensionId);
await onboardingPage.signInWithTestAccount(extensionId);
await homePage.goToFundPage();
});

test('should redirect to provider URL', async ({ page }) => {
const providerNames = await page.getByTestId(FundPageSelectors.FiatProviderName).all();
const name = await providerNames[0].innerText();

const providerItems = await page.getByTestId(FundPageSelectors.FiatProviderItem).all();
await providerItems[0].click();

await page.waitForTimeout(2000);
const allPages = page.context().pages();
const recentPage = allPages.pop();
await recentPage?.waitForLoadState();
const URL = recentPage?.url();
test.expect(URL).toContain(name);
});
});
Loading