This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: tweaking e2e; pera connect support (#137)
* refactor: tweaking e2e * refactor: tweaking e2e * refactor: tweaking e2e * refactor: testing ci * refactor: testing ci * refactor: testing ci * refactor: testing ci * refactor: testing ci * test(new unit tests): adding more unit tests * test: adding more unit tests * refactor: adding pera wallet connect support
- Loading branch information
1 parent
b8eba84
commit 47d0962
Showing
28 changed files
with
574 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import LoadingBackdrop from './Backdrop'; | ||
|
||
describe(`Backdrop`, () => { | ||
it(`should render the loading message and progress bar when isLoading is true`, () => { | ||
const { getByText, queryByText } = render( | ||
<LoadingBackdrop isLoading={true} />, | ||
); | ||
expect(getByText(`Loading...`)).toBeInTheDocument(); | ||
expect(queryByText(`Custom message`)).not.toBeInTheDocument(); | ||
expect( | ||
queryByText(`Custom message`, { exact: false }), | ||
).not.toBeInTheDocument(); | ||
}); | ||
|
||
it(`should not render the loading message or progress bar when isLoading is false`, () => { | ||
const { queryByText } = render( | ||
<LoadingBackdrop isLoading={false} message={``} />, | ||
); | ||
expect(queryByText(`Loading...`)).not.toBeInTheDocument(); | ||
expect(queryByText(/linear/i)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it(`should render a custom message if provided`, () => { | ||
const { getByText } = render( | ||
<LoadingBackdrop isLoading={true} message="Custom message" />, | ||
); | ||
expect(getByText(`Custom message`)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { render, queryByAttribute } from '@testing-library/react'; | ||
import ViewOnAlgoExplorerButton from './ViewOnAlgoExplorerButton'; | ||
import { ChainType } from '@/models/Chain'; | ||
import { VIEW_ON_EXPLORER_BTN_ID } from './constants'; | ||
|
||
const getById = queryByAttribute.bind(null, `id`); | ||
|
||
describe(`ViewOnAlgoExplorerButton`, () => { | ||
it(`renders the button with the correct text and href`, () => { | ||
const txId = `abc123`; | ||
const chain = ChainType.MainNet; | ||
const result = render( | ||
<ViewOnAlgoExplorerButton txId={txId} chain={chain} />, | ||
); | ||
|
||
const button = getById( | ||
result.container, | ||
VIEW_ON_EXPLORER_BTN_ID, | ||
) as Element; | ||
expect(button).toHaveTextContent(`View on AlgoExplorer`); | ||
expect(button).toHaveAttribute( | ||
`href`, | ||
`https://algoexplorer.io/tx/${txId}`, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const VIEW_ON_EXPLORER_BTN_ID = `AWViewOnExplorerButton`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import AboutDialog from './AboutDialog'; | ||
|
||
describe(`AboutDialog`, () => { | ||
it(`renders the correct content and handles the close button correctly`, () => { | ||
const changeStateMock = jest.fn(); | ||
const { getByText } = render( | ||
<AboutDialog open={true} changeState={changeStateMock} />, | ||
); | ||
|
||
// Check that the dialog renders with the correct title and content | ||
expect( | ||
getByText( | ||
`AlgoWorld Swapper is a free and open-source tool for swapping assets on Algorand blockchain.`, | ||
{ exact: false }, | ||
), | ||
).toBeInTheDocument(); | ||
|
||
// Check that clicking the close button calls the changeState function with the correct argument | ||
fireEvent.click(getByText(`Close`)); | ||
expect(changeStateMock).toHaveBeenCalledWith(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
import { render, queryByAttribute } from '@testing-library/react'; | ||
import ConfirmDialog from './ConfirmDialog'; | ||
|
||
describe(`ConfirmDialog`, () => { | ||
it(`renders the correct content and handles the buttons correctly`, () => { | ||
const setOpenMock = jest.fn(); | ||
const onConfirmMock = jest.fn(); | ||
const onSwapVisibilityChangeMock = jest.fn(); | ||
const { getByText } = render( | ||
<ConfirmDialog | ||
title="Test Dialog" | ||
open={true} | ||
setOpen={setOpenMock} | ||
onConfirm={onConfirmMock} | ||
isPublicSwap={false} | ||
onSwapVisibilityChange={onSwapVisibilityChangeMock} | ||
transactionsFee={10} | ||
> | ||
<p>Test content</p> | ||
</ConfirmDialog>, | ||
); | ||
|
||
// Check that the dialog renders with the correct title and content | ||
expect(getByText(`Test Dialog`)).toHaveTextContent(`Test Dialog`); | ||
expect(getByText(`Test content`)).toBeInTheDocument(); | ||
expect(getByText(`Transaction fees: ~10 Algo`)).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import renderWithProviders from '@/__utils__/renderWithProviders'; | ||
import Footer from './Footer'; | ||
|
||
describe(`Footer`, () => { | ||
it(`should render nav bar items`, () => { | ||
const { container } = renderWithProviders(<Footer />); | ||
|
||
expect(container).toBeInTheDocument(); | ||
expect(container).toHaveTextContent(`Home`); | ||
expect(container).toHaveTextContent(`My Swaps`); | ||
expect(container).toHaveTextContent(`About`); | ||
}); | ||
|
||
it(`should render reference buttons`, () => { | ||
const { container } = renderWithProviders(<Footer />); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
|
||
it(`should render copyright text`, () => { | ||
const { container } = renderWithProviders(<Footer />); | ||
|
||
expect(container).toBeInTheDocument(); | ||
expect(container).toHaveTextContent( | ||
`Copyright © AlgoWorld ${new Date().getFullYear()}`, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { queryByAttribute, render } from '@testing-library/react'; | ||
import ParticlesContainer from './ParticlesContainer'; | ||
|
||
const getById = queryByAttribute.bind(null, `id`); | ||
|
||
describe(`ParticlesContainer`, () => { | ||
it(`renders the particle container correctly`, () => { | ||
const { container } = render(<ParticlesContainer />); | ||
const tsparticles = getById(container, `tsparticles`); | ||
expect(tsparticles).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/utils/api/transactions/createTransactionToSign.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import createTransactionToSign from './createTransactionToSign'; | ||
import { TransactionToSign, TransactionToSignType } from '@/models/Transaction'; | ||
import { Transaction, LogicSigAccount } from 'algosdk'; | ||
|
||
describe(`createTransactionToSign`, () => { | ||
it(`should create a TransactionToSign object with the correct properties`, () => { | ||
const transaction: Transaction = { | ||
fee: 10, | ||
firstRound: 1000, | ||
lastRound: 2000, | ||
note: Buffer.from(`note`), | ||
genesisID: `test-genesis-id`, | ||
genesisHash: `test-genesis-hash`, | ||
} as unknown as Transaction; | ||
const signer: LogicSigAccount = { | ||
address: `test-address`, | ||
logicSig: { | ||
msig: { | ||
subsignatures: [], | ||
threshold: 1, | ||
}, | ||
}, | ||
} as unknown as LogicSigAccount; | ||
const type: TransactionToSignType = TransactionToSignType.LsigTransaction; | ||
|
||
const result = createTransactionToSign(transaction, signer, type); | ||
expect(result).toEqual({ | ||
transaction: transaction, | ||
signer: signer, | ||
type: type, | ||
} as TransactionToSign); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
47d0962
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for algoworld-swapper ready!
✅ Preview
https://algoworld-swapper-ax6nz6l1e-algoworldexplorer.vercel.app
Built with commit 47d0962.
This pull request is being automatically deployed with vercel-action