Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unskip MetaMask add/switch network tests #835

Merged
merged 4 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ FROM --platform=linux/amd64 synthetixio/docker-e2e:18.16-ubuntu as base
RUN mkdir /app
WORKDIR /app

RUN apt update && apt install -y nginx

COPY nginx.conf /etc/nginx/sites-available/default

Comment on lines +7 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is good place to add this piece. The issue is that people use this Dockerfile as a reference to run their setup and nginx in most cases is redundant there and is very specific to our use case.

Nevertheless, sooner or later there may be more cases with specific things to our setup, so maybe it's not a huge issue at all. We can provide proper examples in synpress-examples repo.

COPY package.json ./
COPY pnpm-lock.yaml ./

Expand Down
16 changes: 15 additions & 1 deletion docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
- ./docker/videos:/app/tests/e2e/videos
- ./docker/screenshots:/app/tests/e2e/screenshots
command: >
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && pnpm test:e2e:ci:anvil'
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && nginx && pnpm test:e2e:ci:anvil'
networks:
- x11

Expand Down Expand Up @@ -113,5 +113,19 @@ services:
networks:
- x11

foundry-metamask-test-dapp:
profiles:
- foundry
container_name: foundry-metamask-test-dapp
image: synthetixio/foundry:457bb48776c3b14de232d9dda620ba9188dc40ac-base
# Port and chain id as required by the MetaMask Test Dapp
command: [ 'anvil --no-cors --port 8546 --chain-id 1338' ]
environment:
- ANVIL_IP_ADDR=0.0.0.0
ports:
- '8546:8546'
networks:
- x11

networks:
x11:
16 changes: 15 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
- ./docker/videos:/app/tests/e2e/videos
- ./docker/screenshots:/app/tests/e2e/screenshots
command: >
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && pnpm test:e2e:anvil'
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && pnpm wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && nginx && pnpm test:e2e:anvil'
networks:
- x11

Expand Down Expand Up @@ -84,5 +84,19 @@ services:
networks:
- x11

foundry-metamask-test-dapp:
profiles:
- foundry
container_name: foundry-metamask-test-dapp
image: synthetixio/foundry:457bb48776c3b14de232d9dda620ba9188dc40ac-base
# Port and chain id as required by the MetaMask Test Dapp
command: [ 'anvil --no-cors --port 8546 --chain-id 1338' ]
environment:
- ANVIL_IP_ADDR=0.0.0.0
ports:
- '8546:8546'
networks:
- x11

networks:
x11:
25 changes: 25 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 8545;
server_name localhost;

location / {
proxy_pass http://foundry:8545;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

server {
listen 8546;
server_name localhost;

location / {
proxy_pass http://foundry-metamask-test-dapp:8546;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
15 changes: 6 additions & 9 deletions tests/e2e/specs/metamask-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ describe('Metamask', () => {
if (Cypress.env('USE_ANVIL')) {
cy.addMetamaskNetwork({
networkName: 'anvil',
rpcUrl: Cypress.env('DOCKER_RUN')
? 'http://foundry:8545'
: 'http://127.0.0.1:8545',
rpcUrl: 'http://127.0.0.1:8545',
chainId: 11155111,
symbol: 'aETH',
isTestnet: true,
Expand Down Expand Up @@ -436,25 +434,24 @@ describe('Metamask', () => {
expect(approved).to.be.true;
});
});
// todo: this feature is broken inside test-dapp, needs to be fixed (unable to switch to DAI chain)
it.skip(`rejectMetamaskToAddNetwork should reject permission to add network`, () => {
it(`rejectMetamaskToAddNetwork should reject permission to add network`, () => {
cy.get('#addEthereumChain').click();
cy.rejectMetamaskToAddNetwork().then(rejected => {
expect(rejected).to.be.true;
});
});
it.skip(`allowMetamaskToAddNetwork should approve permission to add network`, () => {
it(`allowMetamaskToAddNetwork should approve permission to add network`, () => {
cy.get('#addEthereumChain').click();
cy.allowMetamaskToAddNetwork('close').then(approved => {
cy.allowMetamaskToAddNetwork().then(approved => {
expect(approved).to.be.true;
});
});
it.skip(`rejectMetamaskToSwitchNetwork should reject permission to switch network`, () => {
it(`rejectMetamaskToSwitchNetwork should reject permission to switch network`, () => {
cy.rejectMetamaskToSwitchNetwork().then(rejected => {
expect(rejected).to.be.true;
});
});
it.skip(`allowMetamaskToSwitchNetwork should approve permission to switch network`, () => {
it(`allowMetamaskToSwitchNetwork should approve permission to switch network`, () => {
cy.get('#switchEthereumChain').click();
cy.allowMetamaskToSwitchNetwork().then(approved => {
expect(approved).to.be.true;
Expand Down