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

feat(neuron-ui): ignore the NodeDisconnected Errors from controller, … #996

Merged
merged 2 commits into from
Oct 17, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export const addPopup = (text: string) => (dispatch: StateDispatch) => {
}

export const addNotification = (message: State.Message<ErrorCode>) => (dispatch: StateDispatch) => {
if (message && message.code === ErrorCode.NodeDisconnected) {
return
}
dispatch({
type: AppActions.AddNotification,
payload: message,
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export enum ErrorCode {
AmountNotEnough = 100,
AmountTooSmall = 101,
PasswordIncorrect = 103,
NodeDisconnected = 104,
// Parameter validation errors from neuron-ui
FieldRequired = 201,
FieldUsed = 202,
Expand Down
11 changes: 4 additions & 7 deletions packages/neuron-wallet/tests-e2e/tests/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createWallet } from '../operations'
import { sleep } from '../application/utils'

/**
* 1. check the alert, it should be disconnected to the network
* 1. check the alert, it should be empty
* 2. navigate to wallet settingsState
* 3. delete a wallet
* 4. input a wrong password
Expand Down Expand Up @@ -33,15 +33,14 @@ export default (app: Application) => {

describe('Test alert message and notification', () => {
const messages = {
disconnected: 'Connection to the node is failed',
incorrectPassword: 'Password is incorrect',
}

app.test('It should have an alert message of disconnection', async () => {
app.test('There is no alerts after the app launched', async () => {
const { client } = app.spectron
const alertComponent = await client.$('.ms-MessageBar-text')
const msg = await client.elementIdText(alertComponent.value.ELEMENT)
expect(msg.value).toBe(messages.disconnected)
expect(msg.value).toBe('')
})

app.test('It should have an alert message of incorrect password', async () => {
Expand All @@ -58,14 +57,12 @@ export default (app: Application) => {
expect(msg.value).toBe(messages.incorrectPassword)
})

app.test('It should have two messages in the notification', async () => {
app.test('It should have a message in the notification', async () => {
const { client } = app.spectron
const messageComponents = await client.$$('.ms-Panel-content p')
expect(messageComponents.length).toBe(Object.keys(messages).length)
const incorrectPasswordMsg = await client.element(`//P[text()="${messages.incorrectPassword}"]`)
const disconnectMsg = await client.element(`//P[text()="${messages.disconnected}"]`)
expect(incorrectPasswordMsg.state).not.toBe('failure')
expect(disconnectMsg.state).not.toBe('failed')
})

// TODO: dismiss a message
Expand Down