Skip to content

Commit

Permalink
Fix failing tests (#582)
Browse files Browse the repository at this point in the history
* Add REACT_APP_OLD_CONTENT_RESOLVERS

* update mocke

* Fix failing test

* Wait longer
  • Loading branch information
makoto authored Feb 11, 2020
1 parent 7799c55 commit 2beef00
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
23 changes: 0 additions & 23 deletions cypress/integration/nameDetail.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,29 +350,6 @@ describe('Name detail view', () => {
})
})

// it('can set old content', () => {
// const content =
// '0xd1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162'

// cy.visit(`${NAME_ROOT}/oldresolver.eth`)

// cy.getByTestId('name-details').within(container => {
// cy.getByTestId('edit-content', { exact: false }).click({ force: true })
// cy.getByPlaceholderText('Enter a content', {
// exact: false
// }).type(content, { force: true })
// waitUntilInputResolves('Save').then(() => {
// cy.getByText('Save').click({ force: true })

// //form closed
// waitUntilTestIdDoesNotExist('action')
// waitUntilTestIdDoesNotExist('cancel')
// //Value updated
// cy.queryByText(content, { exact: false }).should('exist')
// })
// })
// })

it('can delete records', () => {
cy.visit(`${NAME_ROOT}/notsoawesome.eth`)
cy.getByTestId('name-details').within(container => {
Expand Down
17 changes: 17 additions & 0 deletions cypress/integration/resolverMigration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DISABLED_COLOUR = 'rgb(223, 223, 223)'
describe('Migrate resolver and records', () => {
it('can visit a name with an old resolver and migrate it', () => {
cy.visit(`${ROOT}/name/abittooawesome2.eth`)
cy.wait(3000)
cy.getByText('Migrate').click({ force: true })
cy.queryByText('migrate', { timeout: 50 }).should('not.exist')
cy.wait(1000)
Expand All @@ -16,6 +17,22 @@ describe('Migrate resolver and records', () => {
)
})

it('can visit a name with an old content resolver and migrate it as swarm contenthash', () => {
cy.visit(`${ROOT}/name/oldresolver.eth`)
cy.wait(3000) // this one took a while to render Migrate
cy.getByText('Migrate').click({ force: true })
cy.queryByText('migrate', { timeout: 50 }).should('not.exist')
cy.wait(1000)
cy.queryByTestId('edit-resolver').should(
'have.css',
'background-color',
ENABLED_COLOUR
)
cy.queryByText('bzz://', {
exact: false
}).should('exist')
})

it('cannot migrate resolver if the parent domain is not migrateed', () => {
cy.visit(`${ROOT}/name/a1.sub2.testing.eth`)
cy.wait(1000)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
}
},
"devDependencies": {
"@ensdomains/mock": "2.0.6",
"@ensdomains/mock": "2.0.7",
"apollo-client-mock": "0.0.8",
"babel-plugin-macros": "^2.4.2",
"cypress": "^3.5.0",
Expand Down
7 changes: 3 additions & 4 deletions src/api/manager/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import {
encodeContenthash,
getResolverContract,
getOldResolverContract,
getNamehash,
getProvider
getNamehash
} from '@ensdomains/ui'
import { formatsByName } from '@ensdomains/address-encoder'
import isEqual from 'lodash/isEqual'
Expand Down Expand Up @@ -544,8 +543,8 @@ const resolvers = {
'0xbf80bc10d6ebfee11bea9a157d762110a0b73d95'
]
const localResolvers =
process.env.REACT_APP_DEPRECATED_RESOLVERS &&
process.env.REACT_APP_DEPRECATED_RESOLVERS.split(',')
process.env.REACT_APP_OLD_CONTENT_RESOLVERS &&
process.env.REACT_APP_OLD_CONTENT_RESOLVERS.split(',')

const oldResolvers = [...oldContentResolvers, ...localResolvers].map(
a => {
Expand Down
16 changes: 15 additions & 1 deletion src/testing-utils/preTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ async function init() {

const addresses = await deployTestEns({ web3, accounts, dnssec, migrate })
console.log(addresses)
const { ensAddress, oldResolverAddresses } = addresses
const {
ensAddress,
oldResolverAddresses,
oldContentResolverAddresses
} = addresses
const envLocalFile = './.env.local'
fs.writeFileSync('./cypress.env.json', JSON.stringify(addresses))
fs.writeFileSync(envLocalFile, `REACT_APP_ENS_ADDRESS=${ensAddress}`)
Expand All @@ -53,11 +57,21 @@ async function init() {
envLocalFile,
`REACT_APP_DEPRECATED_RESOLVERS=${oldResolverAddresses.join(',')}`
)
fs.appendFileSync(envLocalFile, '\n')
fs.appendFileSync(
envLocalFile,
`REACT_APP_OLD_CONTENT_RESOLVERS=${oldContentResolverAddresses.join(',')}`
)
console.log(
`Successfully wrote Old resolver address ${oldResolverAddresses.join(
','
)} to .env.local`
)
console.log(
`Successfully wrote Old content resolver address ${oldContentResolverAddresses.join(
','
)} to .env.local`
)
}

init()
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1337,10 +1337,10 @@
truffle "^5.0.5"
web3-utils "^1.0.0-beta.48"

"@ensdomains/mock@2.0.6":
version "2.0.6"
resolved "https://registry.yarnpkg.com/@ensdomains/mock/-/mock-2.0.6.tgz#af8bc795c6d313efe4d8145b29d9c185f833b4e9"
integrity sha512-a74vfJHCWsTmal2dOAEiS7Mb1gZvob/7EmdpZjWXk+8XwFVIHsz2rXf8d//p/FN1T/Tct8XdJQrd1vXl9GEyTw==
"@ensdomains/mock@2.0.7":
version "2.0.7"
resolved "https://registry.yarnpkg.com/@ensdomains/mock/-/mock-2.0.7.tgz#657b14635473bbb2c312d8edf781a327b7190aa8"
integrity sha512-f8GiV/iQTBgax/6kHsErhbTzs/TD9uFEDmVDHrqEjB1yP0zlaMzhH+SIlO2mz7zHoEMzoey+R+qYBXE+IEDYNg==
dependencies:
"@0xproject/utils" "^2.0.2"
"@babel/runtime" "^7.4.4"
Expand Down

0 comments on commit 2beef00

Please sign in to comment.