mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
110 lines
3.8 KiB
JavaScript
110 lines
3.8 KiB
JavaScript
const { convertToHexValue, withFixtures } = require('../helpers');
|
|
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
|
|
const FixtureBuilder = require('../fixture-builder');
|
|
|
|
describe('ERC1155', function () {
|
|
const smartContract = SMART_CONTRACTS.ERC1155;
|
|
const ganacheOptions = {
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
balance: convertToHexValue(25000000000000000000),
|
|
},
|
|
],
|
|
};
|
|
|
|
it('should mint', async function () {
|
|
await withFixtures(
|
|
{
|
|
dapp: true,
|
|
fixtures: new FixtureBuilder()
|
|
.withPermissionControllerConnectedToTestDapp()
|
|
.build(),
|
|
ganacheOptions,
|
|
smartContract,
|
|
title: this.test.title,
|
|
failOnConsoleError: false,
|
|
},
|
|
async ({ driver, _, contractRegistry }) => {
|
|
const contract = contractRegistry.getContractAddress(smartContract);
|
|
await driver.navigate();
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
// Open Dapp and wait for deployed contract
|
|
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
|
|
await driver.findClickableElement('#deployButton');
|
|
|
|
// Mint
|
|
await driver.fill('#batchMintTokenIds', '1, 2, 3');
|
|
await driver.fill('#batchMintIdAmounts', '1, 1, 1000000000000000');
|
|
await driver.clickElement('#batchMintButton');
|
|
|
|
// Notification
|
|
await driver.waitUntilXWindowHandles(3);
|
|
const windowHandles = await driver.getAllWindowHandles();
|
|
const [extension] = windowHandles;
|
|
await driver.switchToWindowWithTitle(
|
|
'MetaMask Notification',
|
|
windowHandles,
|
|
);
|
|
|
|
// Confirm Mint
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
await driver.waitUntilXWindowHandles(2);
|
|
await driver.switchToWindow(extension);
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
await driver.waitForSelector(
|
|
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
|
{ timeout: 10000 },
|
|
);
|
|
},
|
|
);
|
|
});
|
|
|
|
it('should batch transfers', async function () {
|
|
await withFixtures(
|
|
{
|
|
dapp: true,
|
|
fixtures: new FixtureBuilder()
|
|
.withPermissionControllerConnectedToTestDapp()
|
|
.build(),
|
|
ganacheOptions,
|
|
smartContract,
|
|
title: this.test.title,
|
|
failOnConsoleError: false,
|
|
},
|
|
async ({ driver, _, contractRegistry }) => {
|
|
const contract = contractRegistry.getContractAddress(smartContract);
|
|
await driver.navigate();
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
await driver.openNewPage(`http://127.0.0.1:8080/?contract=${contract}`);
|
|
|
|
await driver.fill('#batchTransferTokenIds', '1, 2, 3');
|
|
await driver.fill('#batchTransferTokenAmounts', '1, 1, 1000000000000');
|
|
await driver.clickElement('#batchTransferFromButton');
|
|
|
|
await driver.waitUntilXWindowHandles(3);
|
|
const windowHandles = await driver.getAllWindowHandles();
|
|
const [extension] = windowHandles;
|
|
await driver.switchToWindowWithTitle(
|
|
'MetaMask Notification',
|
|
windowHandles,
|
|
);
|
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
await driver.waitUntilXWindowHandles(2);
|
|
await driver.switchToWindow(extension);
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
await driver.waitForSelector(
|
|
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
|
{ timeout: 10000 },
|
|
);
|
|
},
|
|
);
|
|
});
|
|
});
|