Merge pull request #2272 from resin-io/fix-store-warning-deselect

fix(store): keep single warning-drives selected
This commit is contained in:
Jonas Hermsmeier 2018-04-25 14:39:58 +02:00 committed by GitHub
commit 8f969374c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View File

@ -199,7 +199,9 @@ const storeReducer = (state = DEFAULT_STATE, action) => {
const AUTOSELECT_DRIVE_COUNT = 1
const numberOfDrives = drives.length
if (numberOfDrives === AUTOSELECT_DRIVE_COUNT) {
const nonStaleSelectedDevices = nonStaleNewState.getIn([ 'selection', 'devices' ]).toJS()
const hasSelectedDevices = nonStaleSelectedDevices.length >= AUTOSELECT_DRIVE_COUNT
if (numberOfDrives === AUTOSELECT_DRIVE_COUNT && !hasSelectedDevices) {
const [ drive ] = drives
// Even if there's no image selected, we need to call several

View File

@ -80,6 +80,40 @@ describe('Model: selectionState', function () {
})
})
describe('given one available drive', function () {
beforeEach(function () {
this.drives = [
{
device: '/dev/disk2',
name: 'USB Drive',
size: 999999999,
isReadOnly: false
}
]
})
afterEach(function () {
selectionState.clear()
availableDrives.setDrives([])
})
describe('.selectDrive()', function () {
it('should not deselect when warning is attached to image-drive pair', function () {
this.drives[0].size = 64e10
availableDrives.setDrives(this.drives)
selectionState.selectDrive('/dev/disk2')
availableDrives.setDrives(this.drives)
m.chai.expect(selectionState.getCurrentDrive()).to.deep.equal({
device: '/dev/disk2',
name: 'USB Drive',
size: 64e10,
isReadOnly: false
})
})
})
})
describe('given a drive', function () {
beforeEach(function () {
availableDrives.setDrives([