Skip to content

Commit

Permalink
Find file to edit in all available files
Browse files Browse the repository at this point in the history
This resolves #7458

Signed-off-by: Wessel van der Linden <wessel.linden@gmail.com>
  • Loading branch information
wesselvanderlinden committed Aug 19, 2020
1 parent 331b738 commit ce9ee91
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const reducer = (state, action) =>
}
case 'SET_FILE_TO_EDIT': {
draftState.fileToEdit = formatFileForEditing(
state.files.find(file => file.id.toString() === action.fileId.toString())
[...state.files, ...state.selectedFiles].find(file => file.id.toString() === action.fileId.toString())
);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2046,6 +2046,7 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
const state = {
currentStep: 'test',
fileToEdit: null,
selectedFiles: [],
files: [
{
id: 13252341,
Expand Down Expand Up @@ -2089,6 +2090,59 @@ describe('UPLOAD | containers | ModalStepper | reducer', () => {
},
};

expect(reducer(state, action)).toEqual(expected);
});
it('should add a selected file to edit', () => {
const action = {
type: 'SET_FILE_TO_EDIT',
fileId: 13252341,
};
const state = {
currentStep: 'test',
fileToEdit: null,
selectedFiles: [
{
id: 13252341,
alternativeText: 'My first picture',
caption: null,
name: 'picture1',
updated_at: '2020-03-30T10:48:26+02:00',
created_at: '2020-03-30T10:48:26+02:00',
},
{ id: 5564723, alternativeText: 'My second picture', caption: '', name: '' },
],
};
const expected = {
currentStep: 'test',
selectedFiles: [
{
id: 13252341,
alternativeText: 'My first picture',
caption: null,
name: 'picture1',
updated_at: '2020-03-30T10:48:26+02:00',
created_at: '2020-03-30T10:48:26+02:00',
},
{ id: 5564723, alternativeText: 'My second picture', caption: '', name: '' },
],
fileToEdit: {
id: 13252341,
abortController: new AbortController(),
file: {
name: 'picture1',
created_at: '2020-03-30T10:48:26+02:00',
},
fileInfo: {
alternativeText: 'My first picture',
caption: null,
name: 'picture1',
},
hasError: false,
errorMessage: null,
isUploading: false,
},
};

expect(reducer(state, action)).toEqual(expected);
});
});
Expand Down

0 comments on commit ce9ee91

Please sign in to comment.