Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 743cba6

Browse files
authored
Merge pull request #147 from Ibby-devv/main
2 parents bba1519 + a839cf0 commit 743cba6

File tree

12 files changed

+2473
-197
lines changed

12 files changed

+2473
-197
lines changed

frontend/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/node_modules
33
/.pnp
44
.pnp.js
5+
/.yarn
56

67
# testing
78
/coverage
@@ -15,6 +16,7 @@
1516
.env.development.local
1617
.env.test.local
1718
.env.production.local
19+
.yarnrc
1820

1921
npm-debug.log*
2022
yarn-debug.log*

frontend/_tests_/mocks/web3.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
let defaultAccounts = [];
2+
let defaultNetwork = '1';
3+
let accounts = defaultAccounts.slice();
4+
let network = defaultNetwork;
5+
6+
const web3Mock = {
7+
eth: {
8+
accounts: {
9+
wallet: {
10+
length: 0,
11+
},
12+
},
13+
getAccounts: (cb) => cb(null, accounts),
14+
net: {
15+
getId: (cb) => cb(null, network),
16+
},
17+
},
18+
currentProvider: {
19+
enable: () => {
20+
return Promise.resolve(accounts);
21+
},
22+
},
23+
setNetwork: (v) => (network = v),
24+
setAccounts: (v) => {
25+
accounts = v;
26+
accounts.forEach((address, i) => {
27+
web3.eth.accounts.wallet[i] = {
28+
address: address,
29+
};
30+
});
31+
web3.eth.accounts.wallet.length = accounts.length;
32+
},
33+
restore: () => {
34+
accounts = defaultAccounts.slice();
35+
network = defaultNetwork;
36+
web3.eth.accounts.wallet = { length: 0 };
37+
},
38+
version: '1.0.0-beta.20',
39+
};
40+
41+
export default web3Mock;

frontend/_tests_/pages/mint.test.jsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React from 'react';
2+
import { render, screen, fireEvent } from '@testing-library/react';
3+
import testCommonLink from '../utils/testCommons';
4+
import web3Mock from '../mocks/web3';
5+
6+
import MintPage from '../../src/pages/mint';
7+
8+
// Mocks
9+
10+
// - Wallet mock
11+
12+
// Tests
13+
14+
// - Expected Negative Interactions
15+
16+
// -- User unsuccessfully connects wallet
17+
18+
// -- Browser does not have web3 support
19+
describe('Browser does not support Web3', () => {
20+
it('Web3 not defined', () => {
21+
const originalEthereum = global.window.ethereum;
22+
render(<MintPage />);
23+
expect(originalEthereum).toBeUndefined();
24+
});
25+
});
26+
// -- Insufficient funds
27+
28+
// -- Transaction failed (could not connect)
29+
30+
// -- Token already minted
31+
32+
// - Expected Positive Interactions
33+
34+
// -- When user arrives on page mint button should be disabled, connect wallet should be enabled
35+
describe('Positive Interactions', () => {
36+
it('Render page default correctly', () => {
37+
render(<MintPage />);
38+
39+
const ddaoTokenSearch = screen.getByRole('link', {
40+
name: /here/,
41+
});
42+
43+
testCommonLink(ddaoTokenSearch, 'http://ddao.ibby.dev');
44+
45+
const connectWalletButton = screen.getByRole('button', {
46+
name: /connectWalletText/,
47+
});
48+
49+
// - [Button] - Connect Wallet
50+
expect(connectWalletButton).toBeInTheDocument();
51+
});
52+
});
53+
54+
// -- User Connects Wallet Successfully
55+
56+
// -- User sucessfully starts transacion to mint token
57+
58+
// -- User successfully mints token

frontend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@testing-library/jest-dom": "^5.11.4",
1414
"@testing-library/react": "^11.1.0",
1515
"@testing-library/user-event": "^12.1.10",
16+
"@walletconnect/web3-provider": "^1.6.5",
1617
"ethers": "^5.4.6",
1718
"framer-motion": "^4",
1819
"jest": "^27.2.0",
@@ -22,7 +23,8 @@
2223
"react-dom": "^17.0.2",
2324
"use-nft": "^0.10.1",
2425
"web-vitals": "^1.0.1",
25-
"web3": "^1.5.2"
26+
"web3": "^1.5.3",
27+
"web3modal": "^1.9.4"
2628
},
2729
"scripts": {
2830
"start": "next start",

frontend/public/locales/en/common.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,26 @@
2222
"hosting": "Hosting by:",
2323
"copyLinkToNFT": "Copy link to NFT",
2424
"linkCopied": "Link copied to clipboard",
25+
"tokenUnavailable": "Token ID may not be available",
26+
"NFTMintSuccess": "Your NFT should now be in your wallet!",
27+
"TokenMintMessage": "Token Minted",
28+
"tokenIDPlaceholder": "Enter Token ID",
29+
"mintTokenText" : "Mint your Token",
30+
"connectWalletText": "Connect Wallet",
31+
"ethereumNetworkPrompt": "Please Connect to the Ethereum Mainnet",
32+
"availableTokensText": "View the available Token IDs",
33+
"mintPageHeader": "DEVS Token Minter",
2534
"projectsList": "A list of community projects created by the Developer DAO community.",
2635
"ddaoTokenSearch": "DDAO Token Search",
2736
"ddaoUnofficalFrontend": "Developer DAO Unofficial Frontend",
2837
"ddaoTokenVisualizer": "Developer DAO Token Visualizer",
2938
"by": "by",
3039
"otherTokensOwnedByThisAddress":"Other Tokens owned by this address",
31-
"noOtherTokens":"No other tokens owned by this address"
32-
40+
"noOtherTokens":"No other tokens owned by this address",
41+
"userCancelTransaction": "Transaction Cancelled by User",
42+
"transactionSending": "Transaction Being Sent",
43+
"here": "here",
44+
"errorMinting": "Unable to Mint NFT",
45+
"disconnectWallet": "Disconnect Wallet",
46+
"etherscanMessage": "View your TX on Etherscan"
3347
}

0 commit comments

Comments
 (0)