-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #964 from Keith-CY/add-skip-data-toggle
Add skip data toggle
- Loading branch information
Showing
19 changed files
with
159 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 20 additions & 7 deletions
27
packages/neuron-ui/src/components/GeneralSetting/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { controllerMethodWrapper } from './controllerMethodWrapper' | ||
|
||
const CONTROLLER_NAME = 'skip-data-and-type' | ||
|
||
export const setSkipDataAndType = controllerMethodWrapper(CONTROLLER_NAME)( | ||
(controller: any) => (params: Controller.SetSkipAndTypeParam) => { | ||
return controller.update(params) | ||
} | ||
) | ||
|
||
export default { setSkipDataAndType } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/neuron-ui/src/states/stateProvider/actionCreators/skipDataAndType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { setSkipDataAndType as setRemoteSkipDataAndType } from 'services/remote' | ||
import { failureResToNotification } from 'utils/formatters' | ||
import { StateDispatch, NeuronWalletActions } from '../reducer' | ||
import { addNotification } from './app' | ||
|
||
export const setSkipDataAndType = (skip: Controller.SetSkipAndTypeParam) => (dispatch: StateDispatch) => { | ||
setRemoteSkipDataAndType(skip).then(res => { | ||
if (res.status === 1) { | ||
dispatch({ | ||
type: NeuronWalletActions.UpdateSkipDataAndType, | ||
payload: res.result, | ||
}) | ||
} else { | ||
addNotification(failureResToNotification(res))(dispatch) | ||
} | ||
}) | ||
} | ||
|
||
export default { | ||
setSkipDataAndType, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,4 +70,5 @@ declare namespace Controller { | |
hash: string | ||
description: string | ||
} | ||
type SetSkipAndTypeParam = boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Application from '../application' | ||
|
||
/** | ||
* 1. navigate to the general settings handleViewError | ||
* 2. the toggle of address book and skip data and type script should be off | ||
* 3. click on the toggles and their statuses should be updated | ||
* 4. refresh the view and the statuses should be preserved | ||
*/ | ||
export default (app: Application) => { | ||
beforeAll(async () => { | ||
app.clickMenu(['Electron', 'Preferences...']) | ||
await app.waitUntilLoaded() | ||
}) | ||
|
||
describe('Test general settings', () => { | ||
app.test('Check the initialized statuses', async () => { | ||
const { client } = app.spectron | ||
const toggles = await client.$$('button[role=switch]') | ||
expect(toggles).toHaveLength(2) | ||
expect((await client.elementIdAttribute(toggles[0].value.ELEMENT, 'aria-checked')).value).toBe('false') | ||
expect((await client.elementIdAttribute(toggles[1].value.ELEMENT, 'aria-checked')).value).toBe('true') | ||
}) | ||
|
||
app.test('toggle AddressBook to true and SkipDataAndType to false', async () => { | ||
const { client } = app.spectron | ||
await app.waitUntilLoaded() | ||
const toggles = await client.$$('button[role=switch]') | ||
|
||
toggles.forEach((_, idx) => { | ||
client.elementIdClick(toggles[idx].value.ELEMENT) | ||
}) | ||
|
||
await app.waitUntilLoaded() | ||
expect((await client.elementIdAttribute(toggles[0].value.ELEMENT, 'aria-checked')).value).toBe('true') | ||
expect((await client.elementIdAttribute(toggles[1].value.ELEMENT, 'aria-checked')).value).toBe('false') | ||
}) | ||
|
||
test.skip('Toggle statuses should be preserved', async () => {}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters