-
Notifications
You must be signed in to change notification settings - Fork 363
Conversation
CLA Assistant Lite All Contributors have signed the CLA. |
ESLint Summary View Full Report
[failure] @typescript-eslint/no-unused-vars
Report generated by eslint-plus-action |
Pull Request Test Coverage Report for Build 2197117793
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work dude! More than happy to go through my suggestions with you
cy.visit("/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/settings/details") | ||
cy.get('footer').should('exist') | ||
|
||
cy.visit("/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/transactions/history") | ||
cy.get('footer').should('not.exist') | ||
|
||
cy.visit("/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/balances") | ||
cy.get('footer').should('not.exist') | ||
|
||
cy.visit("/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/apps") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably best we use the generateSafeRoute
function and our pre-defined route variables here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. IMHO the dumber the better.
cy.visit("/") | ||
cy.get('footer').should('exist') | ||
|
||
cy.visit("/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/settings/details") | ||
cy.get('footer').should('exist') | ||
|
||
cy.visit("/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/transactions/history") | ||
cy.get('footer').should('not.exist') | ||
|
||
cy.visit("/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/balances") | ||
cy.get('footer').should('not.exist') | ||
|
||
cy.visit("/rin:0xFfDC1BcdeC18b1196e7FA04246295DE3A17972Ac/apps") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should all begin with the PUBLIC_URL
, '/app'.
cy.wait(1000) //Have to wait because clicking the switch network fails sometimes if not | ||
|
||
//Step 1 | ||
cy.get('[data-testid="select-network-step"]').find('button').click() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use cy.findByTestId
instead of cy.get('[data-testid=...
.
I won't mark the other instances of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would even say to find by text whenever possible
@@ -0,0 +1,22 @@ | |||
/// <reference types="cypress" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this file? It doesn't seem to add anything and failing the linter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what I read is for the intellisense
cypress/plugins/index.js
Outdated
* @type {Cypress.PluginConfig} | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
module.exports = (on, config) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace on
with _
, then it won't complain.
Edit: actually, just remove both on
and config
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove them to see if it still works
const { createArrayTypeNode } = require("typescript") | ||
|
||
describe('App layout', () =>{ | ||
it('Check footer presence', () =>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, this functionality (which pages show the footer) is too trivial to cover.
Tests run slowly, so we need to prefer more complex scenarios to fit in a reasonable time budget.
The slowest part is loading new pages, and this test does a lot of it, just to check for the footer.
There's a mix of single and double quotes, no new lines at the end of files but out linter didn't catch that. |
const OWNER_ADDRESS = "0x6f965E48347AF3Df65c14CCc176A9CbeCEa0eDb5" | ||
|
||
describe("Load Safe", () => { | ||
it("Load safe", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('should load an existing Safe'
it("Load safe", () => { | ||
cy.visit("/") | ||
cy.findByText('Accept selection').click() | ||
|
||
cy.get('[data-track="load-safe: Open stepper"]').click() | ||
cy.findByText('Add existing Safe').should('exist') | ||
cy.wait(1000) //Have to wait because clicking the switch network fails sometimes if not | ||
|
||
//Step 1 | ||
cy.get('[data-testid="select-network-step"]').find('button').click() | ||
cy.get('[aria-labelledby="select-network"]').should('exist') | ||
cy.findByText('Ethereum').click() | ||
cy.get('nav').findByText('Ethereum').should('exist') | ||
cy.get('[data-testid="select-network-step"]').findByText('Ethereum').should('exist') | ||
cy.get('[data-testid="select-network-step"]').find('button').click() | ||
cy.findByText('Rinkeby').click() | ||
cy.get('[data-track="load-safe: Continue"]').click() | ||
|
||
//Step2 | ||
cy.get('[data-testid="load-safe-name-field"]').should('have.attr', 'placeholder').should('contain','rinkeby-safe') | ||
cy.get('[data-testid="load-safe-name-field"]').type('Test safe name').should('have.value', 'Test safe name') | ||
|
||
cy.get('[data-testid="load-safe-address-field"]').type('RandomText') | ||
cy.findByText(INVALID_INPUT_ERROR_MSG).should('exist') | ||
cy.get('[data-testid="load-safe-address-field"]').clear().type(NON_CONTRACT_ADDRESS) | ||
cy.findByText(INVALID_ADDRESS_ERROR_MSG).should('exist') | ||
cy.get('[data-testid="load-safe-address-field"]').clear().type(SAFE_ENS_NAME).should('have.value', SAFE_ENS_NAME_TRANSLATED) | ||
cy.get('[data-testid="qr-icon"]').click() | ||
cy.get('[class="paper"]').find('button').contains('Upload an image').click() | ||
cy.get('[type="file"]').attachFile('../utils/files/rinkeby_safe_QR.png') | ||
cy.get('[data-testid="load-safe-address-field"]').should('have.value', SAFE_QR_CODE_ADDRESS) | ||
cy.get('[data-testid="safeAddress-valid-address-adornment"]').should('exist') | ||
cy.wait(3000) //have to wait or after clicking next what loads is the owners of the previous valids safe, not the one from the QR code | ||
cy.get('[type="submit"]').click() | ||
|
||
//Step3 | ||
cy.findByPlaceholderText(OWNER_ENS_DEFAULT_NAME).parents('div[data-testid="owner-row"]').findByText(OWNER_ADDRESS) | ||
cy.findByPlaceholderText(OWNER_ENS_DEFAULT_NAME).type('Test Owner Name').should('have.value', 'Test Owner Name') | ||
cy.get('[data-track="load-safe: Continue"]').click() | ||
|
||
//Review Step | ||
cy.findByText('Test safe name').should('exist') | ||
cy.findByText('Test Owner Name').should('exist') | ||
cy.get('[data-track="load-safe: Add"]').click() | ||
|
||
//Safe Loaded | ||
cy.get('[data-testid="sidebar"]').findByText('Test safe name') | ||
cy.get('[data-testid="sidebar"]').find('nav').findByText('Settings').click() | ||
cy.get('[data-testid="sidebar"]').find('nav').findByText('Owners').click() | ||
cy.findByText('Test Owner Name') | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this scenario tests only the happy path.
It would be nice to also check possible input errors, Safes that don't exist (or on a diff network), adding and discarding owners, going back etc.
Doesn't need to be in the PR, just an idea for future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check for the safe address that wrong values and address that are not safes (like mm accounts).
I think it was because we used the |
Prettier currently only formats |
@@ -0,0 +1,65 @@ | |||
import 'cypress-file-upload'; | |||
const path = require("path"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is used to upload the QR file
const SAFE_ENS_NAME = "safe.test" | ||
const SAFE_ENS_NAME_TRANSLATED = "0x83eC7B0506556a7749306D69681aDbDbd08f0769" | ||
const SAFE_QR_CODE_ADDRESS = "0x9913B9180C20C6b0F21B6480c84422F6ebc4B808" | ||
const NON_CONTRACT_ADDRESS = "0x61a0c717d18232711bC788F19C9Cd56a43cc8872" | ||
const INVALID_INPUT_ERROR_MSG = "Must be a valid address, ENS or Unstoppable domain" | ||
const INVALID_ADDRESS_ERROR_MSG = "Address given is not a valid Safe address" | ||
const OWNER_ENS_DEFAULT_NAME = "francoledger.eth" | ||
const OWNER_ADDRESS = "0x6f965E48347AF3Df65c14CCc176A9CbeCEa0eDb5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest moving to a constants.ts
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to create a bunch of test that work individually first. At some point as the test grow I'll create files to share constant, selectors and such.
|
||
cy.get('[data-track="load-safe: Open stepper"]').click() | ||
cy.findByText('Add existing Safe').should('exist') | ||
cy.wait(1000) //Have to wait because clicking the switch network fails sometimes if not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we wait for data-testid="select-network-step"
to exist? as opposite to timeouts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is the application, if you click too fast it fails to load. Is not that the button is missing or anything, is that you can click it before it loads properly
cy.wait(1000) //Have to wait because clicking the switch network fails sometimes if not | ||
|
||
//Step 1 | ||
cy.get('[data-testid="select-network-step"]').find('button').click() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would even say to find by text whenever possible
cy.findByText('Ethereum').click() | ||
cy.get('nav').findByText('Ethereum').should('exist') | ||
cy.get('[data-testid="select-network-step"]').findByText('Ethereum').should('exist') | ||
cy.get('[data-testid="select-network-step"]').find('button').click() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we changing network unnecessarily? I would keep the test as straightforward as possible and do not bloat to much the tested scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making sure the network works back and forth. I'll do the same whenever we can make a safe creation test
cy.findByText(INVALID_ADDRESS_ERROR_MSG).should('exist') | ||
cy.get('[data-testid="load-safe-address-field"]').clear().type(SAFE_ENS_NAME).should('have.value', SAFE_ENS_NAME_TRANSLATED) | ||
cy.get('[data-testid="qr-icon"]').click() | ||
cy.get('[class="paper"]').find('button').contains('Upload an image').click() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does findByText
work here?
cy.get('[type="file"]').attachFile('../utils/files/rinkeby_safe_QR.png') | ||
cy.get('[data-testid="load-safe-address-field"]').should('have.value', SAFE_QR_CODE_ADDRESS) | ||
cy.get('[data-testid="safeAddress-valid-address-adornment"]').should('exist') | ||
cy.wait(3000) //have to wait or after clicking next what loads is the owners of the previous valids safe, not the one from the QR code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we wait for the submit
button not to be disabled instead of a timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is that if you clcik the button too fast when it reaches the owner steps it shows the owners for the safe that was loaded previously and not the safe loaded by the QR code. Is a case of the app not ready to have a user clicking the "next" button so fast
//Review Step | ||
cy.findByText('Test safe name').should('exist') | ||
cy.findByText('Test Owner Name').should('exist') | ||
cy.get('[data-track="load-safe: Add"]').click() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findByText
//Step3 | ||
cy.findByPlaceholderText(OWNER_ENS_DEFAULT_NAME).parents('div[data-testid="owner-row"]').findByText(OWNER_ADDRESS) | ||
cy.findByPlaceholderText(OWNER_ENS_DEFAULT_NAME).type('Test Owner Name').should('have.value', 'Test Owner Name') | ||
cy.get('[data-track="load-safe: Continue"]').click() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findByText
On a personal note, I'd not like to use the "findByText" as the first option, since that searches for the first occurrence of a text, so if it is not unique you are in trouble. I'd prefer to use any other selector as first option (a test-id, a class, an alt or title...) |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
What it solves
Add e2e for cypress test to verify the footer and the load safe workflow
How to test it
Write the command yarn cypress:open dev
The cypress ui test selector opens
Select the files "load_safe" and "app_layout"