1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Add unhappypath test case for importing ERC1155 (#17923)

* add unhappypath test case for importing ERC1155 token
This commit is contained in:
chloeYue 2023-02-28 15:23:06 +01:00 committed by GitHub
parent e015e027b6
commit 5419f9414c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 5 deletions

View File

@ -3,7 +3,7 @@ const { convertToHexValue, withFixtures } = require('../helpers');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
const FixtureBuilder = require('../fixture-builder');
describe('Import NFT', function () {
describe('Import ERC1155 NFT', function () {
const smartContract = SMART_CONTRACTS.ERC1155;
const ganacheOptions = {
accounts: [
@ -61,4 +61,41 @@ describe('Import NFT', function () {
},
);
});
it('should not be able to import an ERC1155 NFT that does not belong to user', async function () {
await withFixtures(
{
dapp: true,
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
smartContract,
title: this.test.title,
},
async ({ driver, _, contractRegistry }) => {
const contractAddress =
contractRegistry.getContractAddress(smartContract);
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
// After login, go to NFTs tab, open the import NFT form
await driver.clickElement('[data-testid="home__nfts-tab"]');
await driver.clickElement({ text: 'Import NFTs', tag: 'a' });
// Enter an NFT that not belongs to user with a valid address and an invalid token id
await driver.fill('[data-testid="address"]', contractAddress);
await driver.fill('[data-testid="token-id"]', '4');
await driver.clickElement({ text: 'Add', tag: 'button' });
// Check error message appears
const invalidNftNotification = await driver.findElement({
text: 'NFT cant be added as the ownership details do not match. Make sure you have entered correct information.',
tag: 'h6',
});
assert.equal(await invalidNftNotification.isDisplayed(), true);
},
);
});
});

View File

@ -72,10 +72,7 @@ async function main() {
testPaths = await getTestPathsForTestDir(testDir);
} else if (nft) {
const testDir = path.join(__dirname, 'nft');
testPaths = [
...(await getTestPathsForTestDir(testDir)),
...(await getTestPathsForTestDir(path.join(__dirname, 'erc1155'))),
];
testPaths = await getTestPathsForTestDir(testDir);
} else {
const testDir = path.join(__dirname, 'tests');
testPaths = [