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

[DRAFT] feat: new e2e test covering SPL list #29959

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b8914db
feat: new e2e test covering SPL list
javiergarciavera Jan 28, 2025
c892cf0
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Jan 29, 2025
df826d4
feat: added more logic to the token list test
javiergarciavera Jan 29, 2025
3126b3f
feat: adding more logic
javiergarciavera Jan 29, 2025
8516bd4
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Jan 30, 2025
040950c
feat: added SLP token workingm pending refinments
javiergarciavera Feb 3, 2025
52eafbd
feat: added send SPL token flow
javiergarciavera Feb 3, 2025
c2fff4d
feat: activity list
javiergarciavera Feb 4, 2025
717d439
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 5, 2025
7d29226
feat: rebase done
javiergarciavera Feb 5, 2025
2289c0c
feat: yarn updated
javiergarciavera Feb 5, 2025
58d54d5
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 6, 2025
e51451a
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 6, 2025
cb8d677
feat: transaction activity added
javiergarciavera Feb 6, 2025
3c858b9
feat: lint fix done
javiergarciavera Feb 6, 2025
54ed6d0
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 11, 2025
6bf0612
feat: testing activity list for SOL txs
javiergarciavera Feb 11, 2025
2f53414
feat: added activity list
javiergarciavera Feb 11, 2025
0cca7bc
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 11, 2025
5452b43
feat: fixing currency on the activity list
javiergarciavera Feb 11, 2025
cfa0de3
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 12, 2025
251a9b2
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 12, 2025
fe98920
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 17, 2025
bb76672
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 18, 2025
877667a
Merge branch 'main' into SOL-112-token-list-e2e
javiergarciavera Feb 18, 2025
e263efe
feat: rebase
javiergarciavera Feb 18, 2025
d359730
feat: rebase
javiergarciavera Feb 18, 2025
d4a6c20
feat: added send SPL token flow
javiergarciavera Feb 3, 2025
2e68c47
feat: rebase
javiergarciavera Feb 18, 2025
7cdfc4a
feat: rebased
javiergarciavera Feb 18, 2025
32014ac
feat: rebase
javiergarciavera Feb 18, 2025
1af917d
feat: rebase
javiergarciavera Feb 18, 2025
6d03741
feat: rebased and fix
javiergarciavera Feb 19, 2025
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
Prev Previous commit
Next Next commit
feat: added more logic to the token list test
javiergarciavera committed Jan 29, 2025
commit df826d4b8c6c6370c19e43ae34d4ee43cc55259e
29 changes: 29 additions & 0 deletions test/e2e/flask/solana/common-solana.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Mockttp } from 'mockttp';
import { Suite } from 'mocha';

Check failure on line 2 in test/e2e/flask/solana/common-solana.ts

GitHub Actions / Test lint / Test lint

'Suite' is defined but never used
import { withFixtures } from '../../helpers';
import { Driver } from '../../webdriver/driver';
import HeaderNavbar from '../../page-objects/pages/header-navbar';
@@ -420,6 +420,34 @@
});
}

export async function mockGetAccountInfo(mockServer: Mockttp) {
const response = {
statusCode: 200,
json: {
result: {
context: { apiVersion: '2.0.15', slot: 341197053 },
value: {
data: ['', 'base58'],
executable: true,
lamports: 88849814690250,
owner: '11111111111111111111111111111111',
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
rentEpoch: 18446744073709551615,
space: 0,
},
},
},
};
return await mockServer
.forPost(SOLANA_URL_REGEX)
.withJsonBodyIncluding({
method: 'getAccountInfo',
})
.thenCallback(() => {
return response;
});
}

export async function mockGetFeeForMessage(mockServer: Mockttp) {
const response = {
statusCode: 200,
@@ -482,6 +510,7 @@
await mockMultiCoinPrice(mockServer),
await mockGetLatestBlockhash(mockServer),
await mockGetFeeForMessage(mockServer),
await mockGetAccountInfo(mockServer),
]);
}
if (mockSendTransaction) {
24 changes: 17 additions & 7 deletions test/e2e/flask/solana/send-flow-token-list.spec.ts
Original file line number Diff line number Diff line change
@@ -34,14 +34,24 @@ describe('Send flow', function (this: Suite) {
false,
'Continue button is enabled when no address',
);
await driver.delay(10000000);
await sendSolanaPage.clickOnSwapCurrencyButton();
assert.equal(
await sendSolanaPage.isContinueButtonEnabled(),
false,
'Continue button is enabled when no address nor amount',
);
await console.log('openTokenList');
await sendSolanaPage.openTokenList();
await console.log('check_tokenByNameIsDisplayed SOL');
await sendSolanaPage.check_tokenByNameIsDisplayed('SOL');

await sendSolanaPage.check_tokenByNameIsDisplayed('soETH');
await sendSolanaPage.check_tokenByNameIsDisplayed('wUSDT');
await sendSolanaPage.check_tokenByNameIsDisplayed('HNT');

await sendSolanaPage.selectTokenFromTokenList('wUSDT');

await sendSolanaPage.check_amountCurrencyIsDisplayed('wUSDT');
await sendSolanaPage.check_tokenBalanceIsDisplayed('250,000', 'wUSDT');
await sendSolanaPage.setAmount('0.1');
await driver.delay(10000000);
await sendSolanaPage.clickOnContinue();
await driver.delay(10000000);

const confirmSolanaPage = new ConfirmSolanaTxPage(driver);
await sendSolanaPage.clickOnContinue();
assert.equal(
48 changes: 48 additions & 0 deletions test/e2e/page-objects/pages/send/solana-send-page.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { By } from 'selenium-webdriver';
import { Driver } from '../../../webdriver/driver';

class SendSolanaPage {
@@ -7,6 +8,11 @@ class SendSolanaPage {

private readonly toAddressInput = '#send-to';

private readonly amountCurrencyLabel = (tokenName: string) =>
By.xpath(
`//label[@for="send-amount-input"]/..//p[contains(text(), "${tokenName}")]`,
);

private readonly continueButton = {
text: 'Continue',
tag: 'button',
@@ -34,6 +40,48 @@ class SendSolanaPage {
await swapCurrencyButton.click();
}

async check_tokenByNameIsDisplayed(tokenName: string): Promise<void> {
await this.driver.waitForControllersLoaded();
await this.driver.waitForSelector(
{
text: tokenName,
tag: 'p',
},
{ timeout: 2000 },
);
}

async selectTokenFromTokenList(tokenName: string): Promise<void> {
await this.driver.waitForControllersLoaded();
await this.driver.clickElement({
text: tokenName,
tag: 'p',
});
}

async check_tokenBalanceIsDisplayed(
amount: string,
tokenName: string,
): Promise<void> {
await this.driver.waitForControllersLoaded();
await this.driver.clickElement({
text: `Balance: ${amount} ${tokenName}`,
tag: 'p',
});
}

async check_amountCurrencyIsDisplayed(currency: string): Promise<void> {
await this.driver.waitForControllersLoaded();
await this.driver.waitForSelector(this.amountCurrencyLabel(currency));
}

async openTokenList(): Promise<void> {
await this.driver.waitForControllersLoaded();
await this.driver.clickElement(
By.xpath('//label[@for="send-asset-selector"]/../button'),
);
}

async check_validationErrorAppears(
validationErrorText: string,
): Promise<boolean> {

Unchanged files with check annotations Beta

// TODO: Re think how to test this without exposing internal state
// it('should replace ethers instance when called with a different chainId than was current when the controller was instantiated', async function () {

Check warning on line 1265 in app/scripts/controllers/swaps/swaps.test.ts

GitHub Actions / Test lint / Test lint

Some tests seem to be commented
// fetchTradesInfoStub.mockReset();
// const _swapsController = getSwapsController();
// expect(currentEthersInstance).not.toStrictEqual(newEthersInstance);
// });
// it('should not replace ethers instance when called with the same chainId that was current when the controller was instantiated', async function () {

Check warning on line 1286 in app/scripts/controllers/swaps/swaps.test.ts

GitHub Actions / Test lint / Test lint

Some tests seem to be commented
// const _swapsController = new SwapsController({
// getBufferedGasLimit: MOCK_GET_BUFFERED_GAS_LIMIT,
// provider,
// expect(currentEthersInstance).toStrictEqual(newEthersInstance);
// });
// it('should replace ethers instance, and _ethersProviderChainId, twice when called twice with two different chainIds, and successfully set the _ethersProviderChainId when returning to the original chain', async function () {

Check warning on line 1306 in app/scripts/controllers/swaps/swaps.test.ts

GitHub Actions / Test lint / Test lint

Some tests seem to be commented
// const _swapsController = new SwapsController({
// getBufferedGasLimit: MOCK_GET_BUFFERED_GAS_LIMIT,
// provider,
});
});
// it('clears polling timeout', function () {

Check warning on line 1390 in app/scripts/controllers/swaps/swaps.test.ts

GitHub Actions / Test lint / Test lint

Some tests seem to be commented
// swapsController._pollingTimeout = setTimeout(() => {
// throw new Error('Polling timeout not cleared');
// }, POLLING_TIMEOUT);
describe('stopPollingForQuotes', function () {
// TODO: Re think how to test this without exposing internal state
// it('clears polling timeout', function () {

Check warning on line 1406 in app/scripts/controllers/swaps/swaps.test.ts

GitHub Actions / Test lint / Test lint

Some tests seem to be commented
// swapsController._pollingTimeout = setTimeout(() => {
// throw new Error('Polling timeout not cleared');
// }, POLLING_TIMEOUT);
describe('resetPostFetchState', function () {
// TODO: Re think how to test this without exposing internal state
// it('clears polling timeout', function () {

Check warning on line 1429 in app/scripts/controllers/swaps/swaps.test.ts

GitHub Actions / Test lint / Test lint

Some tests seem to be commented
// swapsController._pollingTimeout = setTimeout(() => {
// throw new Error('Polling timeout not cleared');
// }, POLLING_TIMEOUT);
};
setTokensListDetected(newTokensList());
}, [

Check warning on line 117 in ui/components/app/detected-token/detected-token.js

GitHub Actions / Test lint / Test lint

React Hook useEffect has a missing dependency: 'tokensListDetected'. Either include it or remove the dependency array
isTokenNetworkFilterEqualCurrentNetwork,
detectedTokensMultichain,
detectedTokens,
* No name has been saved for the value and type.
*/
export const NoSavedName = {
name: 'No Saved Name',

Check warning on line 129 in ui/components/app/name/name.stories.tsx

GitHub Actions / Test lint / Test lint

Named exports should not use the name annotation if it is redundant to the name that would be generated by the export name
args: {
value: ADDRESS_MOCK,
type: NameType.ETHEREUM_ADDRESS,
useEffect(() => {
return () => interfaceId && dispatch(deleteInterface(interfaceId));
}, [interfaceId]);

Check warning on line 49 in ui/components/app/snaps/snap-home-page/snap-home-renderer.js

GitHub Actions / Test lint / Test lint

React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array
useEffect(() => {
// Snaps are allowed to redirect to their own pending confirmations (templated or not)
} else if (snapApproval) {
history.push(`${CONFIRM_TRANSACTION_ROUTE}/${snapApproval.id}`);
}
}, [unapprovedTemplatedConfirmations, unapprovedConfirmations, history]);

Check warning on line 65 in ui/components/app/snaps/snap-home-page/snap-home-renderer.js

GitHub Actions / Test lint / Test lint

React Hook useEffect has a missing dependency: 'snapId'. Either include it or remove the dependency array
if (error) {
return (