Skip to content

Commit

Permalink
Merge pull request #3266 from owncloud/fix-delete-from-search
Browse files Browse the repository at this point in the history
remove deleted files from search result
  • Loading branch information
Vincent Petry authored Apr 27, 2020
2 parents f25a155 + 5cddb2d commit fd7f266
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions apps/files/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ export default {
.then(() => {
context.commit('REMOVE_FILE', file)
context.commit('REMOVE_FILE_SELECTION', file)
context.commit('REMOVE_FILE_FROM_SEARCHED', file)
})
.catch(error => {
let translated = $gettext('Error while deleting "%{file}"')
Expand Down
7 changes: 5 additions & 2 deletions apps/files/src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export default {
LOAD_FILES_SEARCHED(state, files) {
state.filesSearched = files
},
REMOVE_FILE_FROM_SEARCHED(state, file) {
state.filesSearched = state.filesSearched.filter(i => file.id !== i.id)
},
SET_FILES_SORT(state, { field, directionIsDesc }) {
state.fileSortDirectionDesc = directionIsDesc
state.fileSortField = field
Expand All @@ -72,7 +75,7 @@ export default {
},
REMOVE_FILE_SELECTION(state, file) {
if (state.selected.length > 1) {
state.selected = state.selected.filter(i => ![file].includes(i))
state.selected = state.selected.filter(i => file.id !== i.id)
return
}
state.selected = []
Expand All @@ -91,7 +94,7 @@ export default {
state.files.push(file)
},
REMOVE_FILE(state, file) {
state.files = state.files.filter(i => ![file].includes(i))
state.files = state.files.filter(i => file.id !== i.id)
},
SET_SEARCH_TERM(state, searchTerm) {
state.searchTermGlobal = searchTerm
Expand Down
8 changes: 8 additions & 0 deletions changelog/unreleased/3266
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Remove deleted files from search result

Deleted file has been removed from filesSearched state by adding a new mutation.
Also, filter condition in remove file mutations has been changed from object reference to unique file id.

https://github.com/owncloud/phoenix/pull/3266
https://github.com/owncloud/phoenix/issues/3043
https://github.com/owncloud/phoenix/issues/3044
17 changes: 6 additions & 11 deletions tests/acceptance/features/webUIFiles/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,10 @@ Feature: Search
Then folder "favorite folder" should be listed on the webUI
And folder "not favorite folder" should be listed on the webUI

@issue-3044
Scenario: Delete file from search list
Given the following files have been deleted by user "user1"
| name |
| lorem-big.txt |
And user "user1" has uploaded file with content "uploaded content" to "lorem-big.txt"
When the user searches for "lorem-big" using the webUI
And the user deletes file "lorem-big.txt" using the webUI
Then file "lorem-big.txt" should be listed on the webUI
#Then file "lorem-big.txt" should not be listed on the webUI
And as "user1" file "lorem-big.txt" should not exist
And as "user1" the file with original path "lorem-big.txt" should exist in the trashbin
Given user "user1" has uploaded file with content "uploaded content" to "file-to-delete.txt"
When the user searches for "file-to" using the webUI
And the user deletes file "file-to-delete.txt" using the webUI
Then file "file-to-delete.txt" should not be listed on the webUI
And as "user1" file "file-to-delete.txt" should not exist
And as "user1" the file with original path "file-to-delete.txt" should exist in the trashbin
6 changes: 3 additions & 3 deletions tests/acceptance/stepDefinitions/filesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ Then('the last uploaded folder should be listed on the webUI', async function()
return client
})

Then('file {string} should not be listed on the webUI', async function(folder) {
const state = await client.page.FilesPageElement.filesList().isElementListed(folder, 'file')
return client.assert.ok(!state, `Error: Resource ${folder} is listed on the filesList`)
Then('file {string} should not be listed on the webUI', async function(file) {
const state = await client.page.FilesPageElement.filesList().isElementListed(file, 'file')
return client.assert.ok(!state, `Error: Resource ${file} is listed on the filesList`)
})

Then('folder {string} should not be listed on the webUI', async folder => {
Expand Down

0 comments on commit fd7f266

Please sign in to comment.