Skip to content

Commit

Permalink
refactor: migrate tx requests tests to playwright, closes #4151
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf committed Sep 4, 2023
1 parent 126b1e7 commit 8332e0c
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 210 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Suspense, memo } from 'react';

import { Stack, StackProps, color } from '@stacks/ui';
import { TransactionSigningSelectors } from '@tests-legacy/page-objects/transaction-signing.selectors';
import { TransactionRequestSelectors } from '@tests/selectors/requests.selectors';
import { styled } from 'leather-styles/jsx';

import { ErrorIcon } from '@app/components/icons/error-icon';
Expand Down Expand Up @@ -38,7 +38,7 @@ function MinimalErrorMessageSuspense(props: StackProps) {
bg="#FCEEED"
borderRadius="12px"
color={color('feedback-error')}
data-testid={TransactionSigningSelectors.TransactionErrorMessage}
data-testid={TransactionRequestSelectors.ErrorMessage}
isInline
p="base"
width="100%"
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/transaction-request/components/page-top.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { memo } from 'react';

import { Stack } from '@stacks/ui';
import { TransactionSigningSelectors } from '@tests-legacy/page-objects/transaction-signing.selectors';
import { TransactionRequestSelectors } from '@tests/selectors/requests.selectors';
import { styled } from 'leather-styles/jsx';

import { useDefaultRequestParams } from '@app/common/hooks/use-default-request-search-params';
Expand Down Expand Up @@ -29,7 +29,7 @@ function PageTopBase() {

return (
<Stack
data-testid={TransactionSigningSelectors.TxSigningPageContainer}
data-testid={TransactionRequestSelectors.TransactionRequestPage}
mb="loose"
spacing="base"
width="100%"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Suspense } from 'react';

import { TransactionSigningSelectors } from '@tests-legacy/page-objects/transaction-signing.selectors';
import { TransactionRequestSelectors } from '@tests/selectors/requests.selectors';
import { useFormikContext } from 'formik';

import { HIGH_FEE_AMOUNT_STX } from '@shared/constants';
Expand Down Expand Up @@ -41,7 +41,7 @@ export function SubmitAction() {
<Suspense fallback={<BaseConfirmButton aria-busy={isLoading} disabled={isDisabled} />}>
<BaseConfirmButton
aria-busy={isLoading}
data-testid={TransactionSigningSelectors.BtnConfirmTransaction}
data-testid={TransactionRequestSelectors.BtnConfirmTransaction}
disabled={isDisabled}
onClick={onConfirmTransaction}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Stack } from '@stacks/ui';
import { TestAppSelectors } from '@tests/selectors/test-app.selectors';
import { UpdateProfileRequestSelectors } from '@tests/selectors/requests.selectors';

interface UpdateActionProfileProps {
onUpdateProfile: () => Promise<void>;
Expand All @@ -18,7 +18,7 @@ export function UpdateActionLayout({
Cancel
</Button>
<Button
data-testid={TestAppSelectors.BtnUpdateProfile}
data-testid={UpdateProfileRequestSelectors.BtnUpdateProfile}
type="submit"
flexGrow={1}
borderRadius="10px"
Expand Down
10 changes: 5 additions & 5 deletions test-app/src/components/debugger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import {
uintCV,
} from '@stacks/transactions';
import { Box, Button, ButtonGroup, Text } from '@stacks/ui';
import { TransactionSigningSelectors } from '@tests-legacy/page-objects/transaction-signing.selectors';
import { WalletPageSelectors } from '@tests-legacy/page-objects/wallet.selectors';
import { TestAppSelectors } from '@tests/selectors/test-app.selectors';
import BN from 'bn.js';

import { ExplorerLink } from './explorer-link';
Expand Down Expand Up @@ -374,28 +374,28 @@ export const Debugger = () => {
<Box>
<ButtonGroup spacing={4} my="base">
<Button
data-testid={TransactionSigningSelectors.BtnContractCall}
data-testid={TestAppSelectors.BtnContractCall}
mt={3}
onClick={() => callFaker(stacksTestnetNetwork, PostConditionMode.Allow)}
>
Contract call (ALLOW mode)
</Button>
<Button
data-testid={TransactionSigningSelectors.BtnContractCall}
data-testid={TestAppSelectors.BtnContractCall}
mt={3}
onClick={() => callFaker(stacksTestnetNetwork)}
>
Contract call (Testnet)
</Button>
<Button
data-testid={TransactionSigningSelectors.BtnContractCall}
data-testid={TestAppSelectors.BtnContractCall}
mt={3}
onClick={() => callFaker(stacksMainnetNetwork)}
>
Contract call (StacksMainnet)
</Button>
<Button
data-testid={TransactionSigningSelectors.BtnContractCall}
data-testid={TestAppSelectors.BtnContractCall}
mt={3}
onClick={() => callFaker(stacksLocalhostNetwork)}
>
Expand Down
128 changes: 0 additions & 128 deletions tests-legacy/integration/transactions/transactions.spec.ts

This file was deleted.

37 changes: 0 additions & 37 deletions tests-legacy/page-objects/transaction-signing.page.ts

This file was deleted.

6 changes: 0 additions & 6 deletions tests-legacy/page-objects/transaction-signing.selectors.ts

This file was deleted.

17 changes: 0 additions & 17 deletions tests/page-object-models/profile-updating.page.ts

This file was deleted.

5 changes: 5 additions & 0 deletions tests/page-object-models/test-app.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class TestAppPage {
static readonly url = 'http://localhost:3000';
page: Page;
readonly signInBtnSelector = createTestSelector(OnboardingSelectors.SignUpBtn);
readonly contractCallBtnSelector = createTestSelector(TestAppSelectors.BtnContractCall);
readonly updateProfileBtnSelector = createTestSelector(TestAppSelectors.BtnUpdateValidProfile);
readonly updateInvalidProfileBtnSelector = createTestSelector(
TestAppSelectors.BtnUpdateInvalidProfile
Expand All @@ -26,6 +27,10 @@ export class TestAppPage {
return this.page.click(this.signInBtnSelector, { timeout: 10000 });
}

async clickContractCallButton() {
return this.page.click(this.contractCallBtnSelector);
}

async clickUpdateProfileButton() {
return this.page.click(this.updateProfileBtnSelector);
}
Expand Down
36 changes: 36 additions & 0 deletions tests/page-object-models/transaction-request.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Page } from '@playwright/test';
import { TransactionRequestSelectors } from '@tests/selectors/requests.selectors';
import { SharedComponentsSelectors } from '@tests/selectors/shared-component.selectors';
import { createTestSelector } from '@tests/utils';

export class TransactionRequestPage {
readonly confirmTransactionBtnSelector = createTestSelector(
TransactionRequestSelectors.BtnConfirmTransaction
);
readonly feeToBePaidLabel = createTestSelector(SharedComponentsSelectors.FeeToBePaidLabel);
readonly transactionRequestPage = createTestSelector(
TransactionRequestSelectors.TransactionRequestPage
);

constructor(readonly page: Page) {}

async clickConfirmTransactionButton() {
return this.page.click(this.confirmTransactionBtnSelector);
}

async getDisplayedFeeValue() {
return this.page.locator(this.feeToBePaidLabel).innerText();
}

async getTransactionRequestError() {
return this.page.locator(TransactionRequestSelectors.ErrorMessage).innerText();
}

async waitForFee() {
await this.page.locator(this.feeToBePaidLabel).waitFor();
}

async waitForTransactionRequestPage() {
await this.page.locator(this.transactionRequestPage).waitFor();
}
}
19 changes: 19 additions & 0 deletions tests/page-object-models/update-profile-request.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Page } from '@playwright/test';
import { UpdateProfileRequestSelectors } from '@tests/selectors/requests.selectors';
import { createTestSelector } from '@tests/utils';

export class UpdateProfileRequestPage {
readonly updateProfileBtnSelector = createTestSelector(
UpdateProfileRequestSelectors.BtnUpdateProfile
);

constructor(readonly page: Page) {}

async clickUpdateProfileButton() {
return this.page.click(this.updateProfileBtnSelector);
}

async waitForUpdateProfileRequestError(msg: string) {
return this.page.waitForSelector(`text=${msg}`);
}
}
10 changes: 10 additions & 0 deletions tests/selectors/requests.selectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum TransactionRequestSelectors {
BtnConfirmTransaction = 'btn-confirm-transaction',
ErrorMessage = 'transaction-request-error-message',
TransactionRequestPage = 'transaction-signing-page',
}

export enum UpdateProfileRequestSelectors {
BtnUpdateProfile = 'btn-update-profile',
ErrorMessage = 'update-profile-request-error-message',
}
3 changes: 1 addition & 2 deletions tests/selectors/test-app.selectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export enum TestAppSelectors {
BtnContractCall = 'btn-contract-call',
BtnUpdateValidProfile = 'btn-update-valid-profile',
BtnUpdateInvalidProfile = 'btn-update-invalid-profile',
BtnUpdateProfile = 'btn-update-profile',
ErrorMessage = 'error-message',
}
Loading

0 comments on commit 8332e0c

Please sign in to comment.