-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to clear recent libraries #10027
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d2e6d7c
Add option to clear recent libraries
dkokkotas be4404d
Include item's reference to properties file
dkokkotas 2e59084
Add unit test regarding option's operations
dkokkotas 972e2b1
Add operation description in CHANGELOG file
dkokkotas 1b852fb
Remove redundant access modifier from test method
dkokkotas 2fc0a24
Improve test method by removing irrelevant assertion
dkokkotas b0eef2a
Refactor operation and reconstruct tests
dkokkotas 7769766
Update properties file
dkokkotas fc238ab
Rename method properly in FileHistoryMenu class
dkokkotas 7f23912
Invoke clearLibrariesHistory() method directly in tests
dkokkotas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
45 changes: 45 additions & 0 deletions
45
src/test/java/org/jabref/gui/menus/FileHistoryMenuTest.java
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,45 @@ | ||
package org.jabref.gui.menus; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.importer.actions.OpenDatabaseAction; | ||
import org.jabref.logic.util.io.FileHistory; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.testfx.framework.junit5.ApplicationExtension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.MockitoAnnotations.openMocks; | ||
|
||
@ExtendWith(ApplicationExtension.class) | ||
public class FileHistoryMenuTest { | ||
private static final String BIBTEX_LIBRARY_PATH = "src/test/resources/org/jabref/"; | ||
|
||
private FileHistoryMenu fileHistoryMenu; | ||
@Mock | ||
private FileHistory fileHistory; | ||
@Mock | ||
private DialogService dialogService; | ||
@Mock | ||
private OpenDatabaseAction openDatabaseAction; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
openMocks(this); | ||
fileHistoryMenu = new FileHistoryMenu(fileHistory, dialogService, openDatabaseAction); | ||
} | ||
|
||
@Test | ||
void recentLibrariesAreCleared() { | ||
fileHistoryMenu.newFile(Path.of(BIBTEX_LIBRARY_PATH.concat("bibtexFiles/test.bib"))); | ||
|
||
fileHistoryMenu.clearLibrariesHistory(); | ||
assertTrue(fileHistoryMenu.isDisable()); | ||
assertEquals(0, fileHistory.size()); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would disable the button when recent libraries are empty, but I don't see any code that would re-enable it when recent library item is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that
FileHistoryMenu#newFile(Path file)
invocation within theOpenDatabaseAction
class, will re-enable the item as the aforementioned method declares :setDisable(false)
. To my understanding, the menuRecent Libraries
shall be disabled unless the user opens a library.I also tested it manually and the system's behavior is as expected. When we open a new library the
Recent libraries
menu will be correctly enabled and the recent libraries will be listed.