Skip to content

Commit

Permalink
finished e2e nft test script
Browse files Browse the repository at this point in the history
Closes #571
  • Loading branch information
Zhixin Zhou committed Mar 7, 2025
1 parent 6644085 commit 0491fa1
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 189 deletions.
96 changes: 1 addition & 95 deletions e2e/sendTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,56 +57,7 @@ export const moveTokenCoaHomepage = async ({ page, tokenname, amount = '0.000000
// Wait for the transaction to be completed
await waitForTransaction({ page, successtext: 'success', amount });
};
export const sendNftCOA = async ({ page, nftname, receiver, successtext }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page.getByRole('tab', { name: 'NFTs' }).click();
await page.getByRole('button', { name: nftname }).click();
await page.getByRole('link').nth(0).click();
await page.getByRole('button', { name: 'Send' }).click();
await page.getByPlaceholder('Search, Address(0x) or Flow').click();
await page.getByPlaceholder('Search, Address(0x) or Flow').fill(receiver);
await page.getByRole('button', { name: 'Send' }).click();
// // Wait for the transaction to be completed
await waitForTransaction({ page, successtext });
};
export const moveNftCOA = async ({ page, nftname, receiver, successtext }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page.getByRole('tab', { name: 'NFTs' }).click();
await page.getByRole('button', { name: nftname }).click();
await page.getByRole('link').nth(0).click();
await page.getByRole('button', { name: 'Move' }).click();
await page.getByRole('combobox').click();
await page.getByRole('option', { name: receiver }).click();
await page.getByRole('button', { name: 'Move' }).click();
// // Wait for the transaction to be completed
await waitForTransaction({ page, successtext });
};
export const batchmoveNftCOA = async ({ page, nftname, receiver, successtext }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page
.locator('div')
.filter({ hasText: /^Move$/ })
.getByRole('button')
.click();
await page.getByRole('button', { name: 'Move NFTs' }).click();
await page.getByRole('combobox').click();
await page.getByRole('option', { name: receiver }).click();
await page.getByRole('button').nth(1).click();
await page.getByRole('button', { name: 'TopShot' }).click();
await page.getByRole('button', { name: '#' }).nth(0).click();
await page.getByRole('button', { name: 'Move' }).click();
// Wait for the transaction to be completed
await waitForTransaction({ page, successtext });
};
test.beforeEach(async ({ page, extensionId }) => {
// Login to our sender account
await loginToSenderAccount({ page, extensionId });
// switch to EVM account
await switchToEvm({ page, extensionId });
});

//Send Fts from COA to COA
test('send Flow COA to COA', async ({ page }) => {
// Send FLOW token from COA to COA
Expand Down Expand Up @@ -213,48 +164,3 @@ test('move USDC token COA to FLOW homepage', async ({ page }) => {
amount: '0.000123',
});
}); */
//Send NFT from COA to COA
test('send top shot COA to COA', async ({ page }) => {
await sendNftCOA({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_EVM_ADDR!,
successtext: 'success',
});
});
//Send NFT from COA to FLOW
test('send top shot COA to FLOW', async ({ page }) => {
await sendNftCOA({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_ADDR!,
successtext: 'success',
});
});
//Send NFT from COA to EOA
test('send top shot COA to EOA', async ({ page }) => {
await sendNftCOA({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_METAMASK_EVM_ADDR!,
successtext: 'success',
});
});
//Move NFT from COA to FLOW
test('Move top shot COA to FLOW', async ({ page }) => {
await moveNftCOA({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_SENDER_ADDR!,
successtext: 'success',
});
});
//Batch move NFT from COA to FLOW
test('Batch Move top shot COA to FLOW', async ({ page }) => {
await batchmoveNftCOA({
page,
nftname: 'TopShot',
receiver: process.env.TEST_SENDER_ADDR!,
successtext: 'success',
});
});
94 changes: 0 additions & 94 deletions e2e/sendTransactionFromFlow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,57 +56,6 @@ export const moveTokenFlowHomepage = async ({
// Wait for the transaction to be completed
await waitForTransaction({ page, successtext: 'sealed', amount, ingoreFlowCharge });
};

export const sendNftFlow = async ({ page, nftname, receiver, ingoreFlowCharge = false }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page.getByRole('tab', { name: 'NFTs' }).click();
await page.getByRole('button', { name: nftname }).click();
await page.getByRole('link').nth(0).click();
await page.getByRole('button', { name: 'Send' }).click();
await page.getByPlaceholder('Search, Address(0x) or Flow').click();
await page.getByPlaceholder('Search, Address(0x) or Flow').fill(receiver);
await page.getByRole('button', { name: 'Send' }).click();
// // Wait for the transaction to be completed
await waitForTransaction({ page, successtext: 'sealed', ingoreFlowCharge });
};
export const moveNftFlow = async ({ page, nftname, receiver, ingoreFlowCharge = false }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page.getByRole('tab', { name: 'NFTs' }).click();
await page.getByRole('button', { name: nftname }).click();
await page.getByRole('link').nth(0).click();
await page.getByRole('button', { name: 'Move' }).click();
await page.getByRole('combobox').click();
await page.getByRole('option', { name: receiver.substring(receiver.length - 8) }).click();
await page.getByRole('button', { name: 'Move' }).click();
// // Wait for the transaction to be completed
await waitForTransaction({ page, successtext: 'sealed', ingoreFlowCharge });
};
export const batchmoveNftFlow = async ({ page, nftname, receiver, ingoreFlowCharge = false }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page
.locator('div')
.filter({ hasText: /^Move$/ })
.getByRole('button')
.click();
await page.getByRole('button', { name: 'Move NFTs' }).click();
await page.getByRole('combobox').click();
await page.getByRole('option', { name: receiver.substring(receiver.length - 8) }).click();
await page.getByRole('button').nth(1).click();
await page.getByRole('button', { name: nftname }).click();
await page.pause();
// await page.getByRole('button').nth(2).click();
// await page.getByRole('button', { name: 'Move' }).click();
// // Wait for the transaction to be completed
// await waitForTransaction({ page, successtext: 'sealed', ingoreFlowCharge });
};

test.beforeEach(async ({ page, extensionId }) => {
// Login to our sender account
await loginToSenderAccount({ page, extensionId });
});
//Send FLOW token from Flow to Flow
test('send FLOW flow to flow', async ({ page }) => {
// This can take a while
Expand Down Expand Up @@ -207,46 +156,3 @@ test('move USDC token Flow to COA homepage', async ({ page }) => {
});
});
*/
test('send top shot FLOW to COA', async ({ page }) => {
await sendNftFlow({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_EVM_ADDR!,
ingoreFlowCharge: true,
});
});
//Send NFT from COA to FLOW
test('send top shot FLOW to FLOW', async ({ page }) => {
await sendNftFlow({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_ADDR!,
});
});
//Send NFT from COA to EOA
test('send top shot FLOW to EOA', async ({ page }) => {
await sendNftFlow({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_METAMASK_EVM_ADDR!,
ingoreFlowCharge: true,
});
});
//Move NFT from COA to FLOW
test('Move top shot FLOW to COA', async ({ page }) => {
await moveNftFlow({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_SENDER_EVM_ADDR!,
ingoreFlowCharge: true,
});
});
//Batch move NFT from COA to FLOW
test('Batch Move top shot FLOW to COA', async ({ page }) => {
await batchmoveNftFlow({
page,
nftname: 'TopShot',
receiver: process.env.TEST_SENDER_EVM_ADDR!,
ingoreFlowCharge: true,
});
});
103 changes: 103 additions & 0 deletions e2e/transferNftFromCoa.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import {
test,
loginToSenderAccount,
getCurrentAddress,
switchToEvm,
waitForTransaction,
} from './utils/helper';

export const sendNftCoa = async ({ page, nftname, receiver, successtext }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page.getByRole('tab', { name: 'NFTs' }).click();
await page.getByRole('button', { name: nftname }).click();
await page.getByRole('link').nth(0).click();
await page.getByRole('button', { name: 'Send' }).click();
await page.getByPlaceholder('Search, Address(0x) or Flow').click();
await page.getByPlaceholder('Search, Address(0x) or Flow').fill(receiver);
await page.getByRole('button', { name: 'Send' }).click();
// // Wait for the transaction to be completed
await waitForTransaction({ page, successtext });
};
export const moveNftCoa = async ({ page, nftname, receiver, successtext }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page.getByRole('tab', { name: 'NFTs' }).click();
await page.getByRole('button', { name: nftname }).click();
await page.getByRole('link').nth(0).click();
await page.getByRole('button', { name: 'Move' }).click();
await page.getByRole('combobox').click();
await page.getByRole('option', { name: receiver }).click();
await page.getByRole('button', { name: 'Move' }).click();
// // Wait for the transaction to be completed
await waitForTransaction({ page, successtext });
};
export const batchmoveNftCoa = async ({ page, nftname, receiver, successtext }) => {
// Wait for the EVM account to be loaded
await getCurrentAddress(page);
await page
.locator('div')
.filter({ hasText: /^Move$/ })
.getByRole('button')
.click();
await page.getByRole('button', { name: 'Move NFTs' }).click();
await page.getByRole('combobox').click();
await page.getByRole('option', { name: receiver }).click();
await page.getByRole('button').nth(1).click();
await page.getByRole('button', { name: 'TopShot' }).click();
await page.getByTestId('nft-selector').getByRole('button').first().click();
await page.getByRole('button', { name: 'Move' }).click();
// Wait for the transaction to be completed
await waitForTransaction({ page, successtext });
};
test.beforeEach(async ({ page, extensionId }) => {
// Login to our sender account
await loginToSenderAccount({ page, extensionId });
// switch to EVM account
await switchToEvm({ page, extensionId });
});
//Send NFT from COA to COA
test('send top shot COA to COA', async ({ page }) => {
await sendNftCoa({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_EVM_ADDR!,
successtext: 'success',
});
});
//Send NFT from COA to FLOW
test('send top shot COA to FLOW', async ({ page }) => {
await sendNftCoa({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_ADDR!,
successtext: 'success',
});
});
//Send NFT from COA to EOA
test('send top shot COA to EOA', async ({ page }) => {
await sendNftCoa({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_RECEIVER_METAMASK_EVM_ADDR!,
successtext: 'success',
});
});
//Move NFT from COA to FLOW
test('move top shot COA to FLOW', async ({ page }) => {
await moveNftCoa({
page,
nftname: 'NBA Top Shot',
receiver: process.env.TEST_SENDER_ADDR!,
successtext: 'success',
});
});
//Batch move NFT from COA to FLOW
test('batch Move top shot COA to FLOW', async ({ page }) => {
await batchmoveNftCoa({
page,
nftname: 'TopShot',
receiver: process.env.TEST_SENDER_ADDR!,
successtext: 'success',
});
});
Loading

0 comments on commit 0491fa1

Please sign in to comment.