-
Notifications
You must be signed in to change notification settings - Fork 159
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 #5130 from owncloud/20052021_correctly-update-reso…
…urce-in-filestable Introduce UPSERT_RESOURCE to files mutations
- Loading branch information
Showing
4 changed files
with
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Bugfix: Upsert resource in filestable | ||
|
||
When uploading an already existing resource in the filestable, we sometimes displayed both | ||
files in the filestable until the page got refreshed. We now check when uploading a file if | ||
it exists in the filestable and replace it there if that is the case. | ||
|
||
https://github.com/owncloud/web/pull/5130 |
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,61 @@ | ||
import mutations from '../../src/store/mutations' | ||
import { cloneDeep } from 'lodash-es' | ||
|
||
const stateFixture = { | ||
files: [ | ||
{ | ||
id: 1, | ||
name: 'test1' | ||
}, | ||
{ | ||
id: 2, | ||
name: 'test2' | ||
}, | ||
{ | ||
id: 5, | ||
name: 'test5' | ||
} | ||
] | ||
} | ||
let stateMock = {} | ||
const resetState = () => { | ||
stateMock = cloneDeep(stateFixture) | ||
} | ||
|
||
describe('vuex store mutations', () => { | ||
describe('update resources by id', () => { | ||
beforeEach(resetState) | ||
it.each([ | ||
[mutations.UPSERT_RESOURCE.name, mutations.UPSERT_RESOURCE], | ||
[mutations.UPDATE_RESOURCE.name, mutations.UPDATE_RESOURCE] | ||
])('succeeds using mutation %s', (name, m) => { | ||
expect(stateMock.files).toEqual(stateFixture.files) | ||
expect(stateMock.files[1].name).toBe('test2') | ||
m(stateMock, { | ||
id: 2, | ||
name: 'test2-updated' | ||
}) | ||
expect(stateMock.files[1].name).toBe('test2-updated') | ||
expect(stateMock.files.length).toBe(stateFixture.files.length) | ||
}) | ||
}) | ||
describe('insert resources', () => { | ||
beforeEach(resetState) | ||
it('succeeds using mutation UPSERT_RESOURCE', () => { | ||
expect(stateMock.files).toEqual(stateFixture.files) | ||
mutations.UPSERT_RESOURCE(stateMock, { | ||
id: 3, | ||
name: 'test3-inserted' | ||
}) | ||
expect(stateMock.files).toEqual([...stateFixture.files, { id: 3, name: 'test3-inserted' }]) | ||
}) | ||
it('is ignored using mutation UPDATE_RESOURCE', () => { | ||
expect(stateMock.files).toEqual(stateFixture.files) | ||
mutations.UPDATE_RESOURCE(stateMock, { | ||
id: 3, | ||
name: 'test3-inserted' | ||
}) | ||
expect(stateMock.files).toEqual(stateFixture.files) | ||
}) | ||
}) | ||
}) |