|
3 | 3 | defaultGanacheOptions, |
4 | 4 | withFixtures, |
5 | 5 | unlockWallet, |
| 6 | + findAnotherAccountFromAccountList, |
| 7 | + waitForAccountRendered, |
6 | 8 | } = require('../../helpers'); |
7 | 9 | const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); |
8 | 10 | const FixtureBuilder = require('../../fixture-builder'); |
@@ -57,6 +59,96 @@ describe('Import NFT', function () { |
57 | 59 | ); |
58 | 60 | }); |
59 | 61 |
|
| 62 | + it('should continue to display an imported NFT after importing, adding a new account, and switching back', async function () { |
| 63 | + await withFixtures( |
| 64 | + { |
| 65 | + dapp: true, |
| 66 | + fixtures: new FixtureBuilder() |
| 67 | + .withPermissionControllerConnectedToTestDapp() |
| 68 | + .build(), |
| 69 | + ganacheOptions: defaultGanacheOptions, |
| 70 | + smartContract, |
| 71 | + title: this.test.fullTitle(), |
| 72 | + }, |
| 73 | + async ({ driver, _, contractRegistry }) => { |
| 74 | + const contractAddress = |
| 75 | + contractRegistry.getContractAddress(smartContract); |
| 76 | + await unlockWallet(driver); |
| 77 | + |
| 78 | + // After login, go to NFTs tab, open the import NFT form |
| 79 | + await driver.clickElement('[data-testid="home__nfts-tab"]'); |
| 80 | + await driver.clickElement({ text: 'Import NFT', tag: 'button' }); |
| 81 | + |
| 82 | + // Enter a valid NFT that belongs to user and check success message appears |
| 83 | + await driver.fill('#address', contractAddress); |
| 84 | + await driver.fill('#token-id', '1'); |
| 85 | + await driver.clickElement( |
| 86 | + '[data-testid="import-nfts-modal-import-button"]', |
| 87 | + ); |
| 88 | + |
| 89 | + const newNftNotification = await driver.findElement({ |
| 90 | + text: 'NFT was successfully added!', |
| 91 | + tag: 'h6', |
| 92 | + }); |
| 93 | + assert.equal(await newNftNotification.isDisplayed(), true); |
| 94 | + |
| 95 | + // Check the imported NFT and its image are displayed in the NFT tab |
| 96 | + const importedNft = await driver.waitForSelector({ |
| 97 | + css: 'h5', |
| 98 | + text: 'TestDappNFTs', |
| 99 | + }); |
| 100 | + const importedNftImage = await driver.findElement( |
| 101 | + '.nft-item__container', |
| 102 | + ); |
| 103 | + assert.equal(await importedNft.isDisplayed(), true); |
| 104 | + assert.equal(await importedNftImage.isDisplayed(), true); |
| 105 | + |
| 106 | + await driver.clickElement({ text: 'Tokens', tag: 'button' }); |
| 107 | + await driver.clickElement('[data-testid="account-menu-icon"]'); |
| 108 | + await driver.clickElement( |
| 109 | + '[data-testid="multichain-account-menu-popover-action-button"]', |
| 110 | + ); |
| 111 | + await driver.clickElement({ text: 'Add a new account', tag: 'button' }); |
| 112 | + |
| 113 | + // set account name |
| 114 | + await driver.fill('[placeholder="Account 2"]', '2nd account'); |
| 115 | + await driver.delay(400); |
| 116 | + await driver.clickElement({ text: 'Create', tag: 'button' }); |
| 117 | + |
| 118 | + await driver.isElementPresent({ |
| 119 | + tag: 'span', |
| 120 | + text: '2nd account', |
| 121 | + }); |
| 122 | + |
| 123 | + const accountOneSelector = await findAnotherAccountFromAccountList( |
| 124 | + driver, |
| 125 | + 1, |
| 126 | + 'Account 1', |
| 127 | + ); |
| 128 | + await waitForAccountRendered(driver); |
| 129 | + await driver.clickElement(accountOneSelector); |
| 130 | + |
| 131 | + await driver.clickElement({ text: 'NFTs', tag: 'button' }); |
| 132 | + const nftIsStillDisplayed = await driver.isElementPresentAndVisible({ |
| 133 | + css: 'h5', |
| 134 | + text: 'TestDappNFTs', |
| 135 | + }); |
| 136 | + const nftImageIsStillDisplayed = |
| 137 | + await driver.isElementPresentAndVisible('.nft-item__container'); |
| 138 | + assert.equal( |
| 139 | + nftIsStillDisplayed, |
| 140 | + true, |
| 141 | + 'Nft is no longer displayed after adding an account and switching back to account 1', |
| 142 | + ); |
| 143 | + assert.equal( |
| 144 | + nftImageIsStillDisplayed, |
| 145 | + true, |
| 146 | + 'Nft image is no longer displayed after adding an account and switching back to account 1', |
| 147 | + ); |
| 148 | + }, |
| 149 | + ); |
| 150 | + }); |
| 151 | + |
60 | 152 | it('should not be able to import an NFT that does not belong to user', async function () { |
61 | 153 | await withFixtures( |
62 | 154 | { |
|
0 commit comments