Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
chore: upgrade to node 11 and fix all failing unit tests (#1075)
Browse files Browse the repository at this point in the history
  • Loading branch information
luciorubeens authored and j-a-m-l committed Feb 20, 2019
1 parent a11c7b2 commit f3069aa
Show file tree
Hide file tree
Showing 36 changed files with 327 additions and 201 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
@@ -1,21 +1,21 @@
version: 2
jobs:
test-node-9:
test-node-11:
working_directory: ~/new-desktop-wallet
docker:
- image: circleci/node:9.11-browsers
- image: circleci/node:11-browsers
steps:
- checkout
- run:
name: Install required packages
command: |
sudo apt-get update
sudo apt-get -t jessie-backports install libudev-dev libusb-1.0-0-dev
sudo apt-get install libudev-dev libusb-1.0-0-dev
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install packages
command: yarn global add node-gyp && yarn install
command: yarn global add node-gyp && yarn install && npm rebuild
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
Expand All @@ -40,4 +40,4 @@ workflows:
version: 2
test:
jobs:
- test-node-9
- test-node-11
2 changes: 1 addition & 1 deletion .nvmrc
@@ -1 +1 @@
9
11
10 changes: 7 additions & 3 deletions README.md
Expand Up @@ -61,10 +61,14 @@ sudo apt-get install libudev-dev libusb-1.0-0-dev
- Python 2.7
- Visual Studio 2017

#### Node 9
There are certain packages (such as the ledger HID packages) which do not work on Node 10.
#### Node 11
To download, head over to [here](https://nodejs.org/en/) and download Node 11.

To download Node 9, head over to [here](https://nodejs.org/en/blog/release/v9.11.1/)
If you already have npm installed, you can run
```
npm install -g n
sudo n 11
```

#### Yarn
Install the Yarn dependency manager
Expand Down
4 changes: 3 additions & 1 deletion __tests__/e2e.jest.conf.js
Expand Up @@ -8,14 +8,16 @@ module.exports = {
'json'
],
moduleNameMapper: {
'^@setup$': '<rootDir>/__tests__/e2e/__utils__/setup.js'
'^@setup$': '<rootDir>/__tests__/e2e/__utils__/setup.js',
'^@package.json$': '<rootDir>/package.json'
},
transform: {
'^.+\\.js$': 'babel-jest'
},
testPathIgnorePatterns: [
'<rootDir>/__tests__/e2e.jest.conf.js',
'<rootDir>/__tests__/e2e/__utils__',
'<rootDir>/__tests__/e2e/pages',
'<rootDir>/__tests__/unit'
],
setupTestFrameworkScriptFile: 'jest-extended',
Expand Down
3 changes: 2 additions & 1 deletion __tests__/e2e/__utils__/setup.js
@@ -1,8 +1,9 @@
import electron from 'electron'
import { Application } from 'spectron'

process.env.TEMP_USER_DATA = 'true'
const timeout = 30000
const shortcuts = ['element', 'getAttribute', 'getSource', 'getText', 'isExisting', 'isVisible', 'url']
const shortcuts = ['element', 'getAttribute', 'getSource', 'getText', 'isExisting', 'isVisible', 'url', 'click']

jest.setTimeout(timeout)

Expand Down
20 changes: 20 additions & 0 deletions __tests__/e2e/app.spec.js
@@ -0,0 +1,20 @@
import setup from '@setup'

import windowSpecs from './pages/1-window.spec'
import welcomeSpecs from './pages/2-welcome.spec'
import profileNewSpecs from './pages/3-profile-new.spec'

describe('App', () => {
let scope = {}

beforeAll(async () => {
await setup.startApp(scope)
await scope.app.client.waitUntilWindowLoaded()
})

afterAll(() => setup.stopApp(scope))

describe('Window', () => windowSpecs(scope))
describe('Welcome', () => welcomeSpecs(scope))
describe('Profile new', () => profileNewSpecs(scope))
})
22 changes: 0 additions & 22 deletions __tests__/e2e/first-screen.spec.js

This file was deleted.

8 changes: 8 additions & 0 deletions __tests__/e2e/pages/1-window.spec.js
@@ -0,0 +1,8 @@
import packageJson from '@package.json'

export default (scope) => {
it('shows the proper application title', async () => {
const title = await scope.app.client.getTitle()
expect(title.toLowerCase()).toContain(packageJson.build.productName.toLowerCase())
})
}
25 changes: 25 additions & 0 deletions __tests__/e2e/pages/2-welcome.spec.js
@@ -0,0 +1,25 @@
export default (scope) => {
it('should render', async () => {
const welcomeElement = await scope.isExisting('.AppIntro')
expect(welcomeElement).toBeTrue()
})

it('click on start button', async () => {
const buttonText = await scope.getText('.AppIntro__1__start-button')
expect(buttonText).toEqual('Start')

await scope.click('.AppIntro__1__start-button').pause(200)
const hasIntroScreen = await scope.isExisting('.AppIntroScreen')
expect(hasIntroScreen).toBeTrue()
})

it('read intro screens', async () => {
while (await scope.isExisting('.AppIntroScreen__container__right__next')) {
await scope.click('.AppIntroScreen__container__right__next')
await scope.app.client.waitUntilWindowLoaded()
}

const hasProfileNew = await scope.isExisting('.ProfileNew')
expect(hasProfileNew).toBeTrue()
})
}
6 changes: 6 additions & 0 deletions __tests__/e2e/pages/3-profile-new.spec.js
@@ -0,0 +1,6 @@
export default (scope) => {
it('shows the instructions section', async () => {
const hasInstructions = await scope.isExisting('.ProfileNew__instructions')
expect(hasInstructions).toBeTrue()
})
}
31 changes: 0 additions & 31 deletions __tests__/e2e/profile-new.js

This file was deleted.

3 changes: 2 additions & 1 deletion __tests__/unit.jest.conf.js
Expand Up @@ -14,7 +14,8 @@ module.exports = {
'^@config': '<rootDir>/config/index.js',
'^@config/(.*)$': '<rootDir>/config/$1',
'^@/(.*)$': '<rootDir>/src/renderer/$1',
'^@tests/(.*)$': '<rootDir>/__tests__/$1'
'^@tests/(.*)$': '<rootDir>/__tests__/$1',
'vue$': '<rootDir>/node_modules/vue/dist/vue.common.js'
},
transform: {
'^.+\\.js$': 'babel-jest',
Expand Down
31 changes: 31 additions & 0 deletions __tests__/unit/__fixtures__/store/network.js
@@ -0,0 +1,31 @@
const network1 = {
id: 'main',
symbol: 'm',
token: 'MAI',
subunit: 'mainito',
fractionDigits: 8,
server: 'http://127.0.0.1',
apiVersion: 1,
constants: {}
}

const network2 = {
id: 'other',
symbol: 'o',
token: 'OTH',
subunit: 'another',
fractionDigits: 8,
server: 'http://127.0.0.1',
apiVersion: 1,
constants: {}
}

export default {
network1,
network2
}

export {
network1,
network2
}
12 changes: 12 additions & 0 deletions __tests__/unit/__fixtures__/store/profile.js
@@ -0,0 +1,12 @@
const profile1 = {
id: 'profile1',
networkId: 'main'
}

export default {
profile1
}

export {
profile1
}
3 changes: 3 additions & 0 deletions __tests__/unit/__utils__/setup.js
Expand Up @@ -3,8 +3,10 @@ import VueTestUtils from '@vue/test-utils'
import VTooltip from 'v-tooltip'
import eventBus from '@/plugins/event-bus'
import directives from '@/directives'
import filters from '@/filters'

require('babel-plugin-require-context-hook/register')()
global.Intl = require('intl')

HTMLCanvasElement.prototype.getContext = jest.fn()

Expand All @@ -13,6 +15,7 @@ Vue.use(VTooltip, {
defaultContainer: '#app'
})
Vue.use(directives)
Vue.use(filters)

VueTestUtils.config.mocks.$eventBus = eventBus
VueTestUtils.config.mocks.$client = {
Expand Down
3 changes: 3 additions & 0 deletions __tests__/unit/components/Contact/ContactRenameModal.spec.js
Expand Up @@ -6,6 +6,9 @@ const i18n = useI18nGlobally()
let wrapper
beforeEach(() => {
wrapper = shallowMount(ContactRenameModal, {
propsData: {
wallet: {}
},
i18n
})
})
Expand Down
15 changes: 11 additions & 4 deletions __tests__/unit/components/Menu/MenuDropdown.spec.js
Expand Up @@ -6,7 +6,8 @@ describe('MenuDropdown', () => {
it('should render component', () => {
const wrapper = mount(MenuDropdownItem, {
propsData: {
value: 'Test'
value: 'Test',
item: 'Item text'
}
})
expect(wrapper.contains('.MenuDropdownItem')).toBeTruthy()
Expand All @@ -16,7 +17,8 @@ describe('MenuDropdown', () => {
const wrapper = mount(MenuDropdownItem, {
propsData: {
value: 'Test',
isActive: true
isActive: true,
item: 'Item text'
}
})
expect(wrapper.contains('.MenuDropdownItem--active')).toBeTruthy()
Expand All @@ -25,7 +27,8 @@ describe('MenuDropdown', () => {
it('should emit click event', () => {
const wrapper = mount(MenuDropdownItem, {
propsData: {
value: 'Test'
value: 'Test',
item: 'Item text'
}
})
const element = wrapper.find('.MenuDropdownItem__button')
Expand Down Expand Up @@ -80,6 +83,7 @@ describe('MenuDropdown', () => {
items: [1, 2, 3]
}
})
wrapper.vm.open()
expect(wrapper.contains('.MenuDropdown')).toBeTruthy()
})

Expand All @@ -90,6 +94,7 @@ describe('MenuDropdown', () => {
items: ['first', 'second']
}
})
wrapper.vm.open()
expect(wrapper.findAll('.MenuDropdownItem').length).toBe(2)
})

Expand Down Expand Up @@ -120,6 +125,7 @@ describe('MenuDropdown', () => {
}
}
})
wrapper.vm.open()
expect(wrapper.findAll('.MenuDropdownItem').length).toBe(2)
})

Expand Down Expand Up @@ -159,7 +165,8 @@ describe('MenuDropdown', () => {
it('should render component with slots', () => {
const item = mount(MenuDropdownItem, {
propsData: {
value: 'Test'
value: 'Test',
item: 'Item text'
}
})
const wrapper = mount(MenuDropdown, {
Expand Down
3 changes: 3 additions & 0 deletions __tests__/unit/components/Modal/ModalRename.spec.js
Expand Up @@ -6,6 +6,9 @@ const i18n = useI18nGlobally()
let wrapper
beforeEach(() => {
wrapper = mount(ModalRename, {
stubs: {
Portal: true
},
i18n
})
})
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/components/Modal/ModalWindow.spec.js
Expand Up @@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
import ModalWindow from '@/components/Modal'

const stubs = {
'portal': true
'Portal': true
}

describe('ModalWindow', () => {
Expand Down
Expand Up @@ -29,6 +29,9 @@ describe('TransactionModal', () => {
error: jest.fn()
},
$store
},
stubs: {
PortalTarget: true
}
})
})
Expand Down
8 changes: 6 additions & 2 deletions __tests__/unit/components/Wallet/WalletDelegates.spec.js
Expand Up @@ -24,10 +24,14 @@ describe('WalletDelegates', () => {
getters: {
'app/showVotingExplanation': showExplanation
}
}
},
$logger: {
error: () => {}
},
$error: () => {}
},
stubs: {
'Table': true
'TableWrapper': true
}
})
}
Expand Down

0 comments on commit f3069aa

Please sign in to comment.